-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
180 changed files
with
5,331 additions
and
3,992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT) | ||
// All rights reserved. | ||
// | ||
// This software may be modified and distributed under the terms of the | ||
// BSD-3-Clause license. See the accompanying LICENSE file for details. | ||
|
||
%define RESET_CONSTANTS_IN_EXTENDED_ANALOG_SENSOR_INTERFACE | ||
#undef ThreeAxisGyroscopes_EXTENDED_INTERFACE | ||
#undef ThreeAxisLinearAccelerometers_EXTENDED_INTERFACE | ||
#undef ThreeAxisMagnetometers_EXTENDED_INTERFACE | ||
#undef OrientationSensors_EXTENDED_INTERFACE | ||
#undef TemperatureSensors_EXTENDED_INTERFACE | ||
#undef SixAxisForceTorqueSensors_EXTENDED_INTERFACE | ||
#undef ContactLoadCellArrays_EXTENDED_INTERFACE | ||
#undef EncoderArrays_EXTENDED_INTERFACE | ||
#undef SkinPatches_EXTENDED_INTERFACE | ||
%enddef | ||
|
||
%define EXTENDED_ANALOG_SENSOR_INTERFACE(sensor) | ||
|
||
RESET_CONSTANTS_IN_EXTENDED_ANALOG_SENSOR_INTERFACE | ||
|
||
#define sensor ## _EXTENDED_INTERFACE 1 | ||
|
||
std::string get ## sensor ## Name(int sens_index) const { | ||
std::string name; | ||
bool ok = self->get ## sensor ## Name(sens_index,name); | ||
if (!ok) return "unknown"; | ||
return name; | ||
} | ||
|
||
#if !ContactLoadCellArray_EXTENDED_INTERFACE \ | ||
&& !EncoderArray_EXTENDED_INTERFACE \ | ||
&& !SkinPatch_EXTENDED_INTERFACE | ||
std::string get ## sensor ## FrameName(int sens_index) const { | ||
std::string frameName; | ||
bool ok = self->get ## sensor ## FrameName(sens_index,frameName); | ||
if (!ok) return "unknown"; | ||
return frameName; | ||
} | ||
#endif | ||
|
||
#if OrientationSensor_EXTENDED_INTERFACE | ||
double get ## sensor ## MeasureAsRollPitchYaw(int sens_index, yarp::sig::Vector& rpy) const { | ||
double timestamp; | ||
bool ok = self->get ## sensor ## MeasureAsRollPitchYaw(sens_index, rpy, timestamp); | ||
#else | ||
double get ## sensor ## Measure(int sens_index, yarp::sig::Vector& out) const { | ||
double timestamp; | ||
bool ok = self->get ## sensor ## Measure(sens_index, out, timestamp); | ||
#endif | ||
if (!ok) return -1; | ||
return timestamp; | ||
} | ||
|
||
#undef sensor ## _EXTENDED_INTERFACE | ||
|
||
%enddef |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) | ||
// All rights reserved. | ||
// | ||
// This software may be modified and distributed under the terms of the | ||
// BSD-3-Clause license. See the accompanying LICENSE file for details. | ||
|
||
%define RESET_CONSTANTS_IN_TO_MATLAB | ||
#undef mxCreateDoubleMatrixHasComplexFlagParam | ||
#undef mxCreateLogicalMatrixHasComplexFlagParam | ||
%enddef | ||
|
||
%define TO_MATLAB(matlabType,mxArrayInitializer) | ||
|
||
// Convert to a Matlab vector | ||
mxArray * toMatlab() const | ||
{ | ||
// create Matlab vector and map it to pointer 'd' | ||
size_t selfDim = self->size(); | ||
#if mxArrayInitializer ## HasComplexFlagParam | ||
mxArray *p = mxArrayInitializer(selfDim, 1, mxREAL); | ||
#else | ||
mxArray *p = mxArrayInitializer(selfDim, 1); | ||
#endif | ||
matlabType* d = static_cast<matlabType*>(mxGetData(p)); | ||
|
||
// copy items from 'self' to 'd' | ||
for(size_t i=0; i<selfDim; i++) | ||
{ | ||
d[i] = static_cast<matlabType>(self->operator[](i)); | ||
} | ||
return p; | ||
} | ||
|
||
%enddef | ||
|
||
|
||
%define FROM_MATLAB(matlabType,cppType,mxArrayInitializer,vectorClass) | ||
|
||
// Convert from a Matlab vector | ||
void fromMatlab(mxArray * in) | ||
{ | ||
// check size | ||
const mwSize * dims = mxGetDimensions(in); | ||
size_t selfDim = self->size(); | ||
size_t matlabVecDim = (dims[0] == 1 ? dims[1] : dims[0]); | ||
|
||
if (matlabVecDim == selfDim) | ||
{ | ||
// map Matlab vector to pointer 'd' | ||
matlabType* d = static_cast<matlabType*>(mxGetData(in)); | ||
|
||
// copy items from 'd' to 'self' | ||
for(size_t i=0; i<selfDim; i++) | ||
{ | ||
self->operator[](i) = static_cast<cppType>(d[i]); | ||
} | ||
return; | ||
} else { | ||
mexErrMsgIdAndTxt("yarp::vectorClass::wrongDimension", | ||
"Wrong vector size. Matlab size: %d. vectorClass size: %d", matlabVecDim, selfDim); | ||
} | ||
} | ||
|
||
%enddef | ||
|
||
|
||
%define RESET(resetValue) | ||
|
||
// Reset values | ||
void zero() | ||
{ | ||
for(size_t i=0; i < self->size(); i++) | ||
{ | ||
self->operator[](i) = resetValue; | ||
} | ||
return; | ||
} | ||
|
||
%enddef | ||
|
||
RESET_CONSTANTS_IN_TO_MATLAB | ||
#define mxCreateDoubleMatrixHasComplexFlagParam 1 | ||
|
||
%extend std::vector<double> { | ||
TO_MATLAB(double,mxCreateDoubleMatrix) | ||
FROM_MATLAB(double,double,mxCreateDoubleMatrix,DVector) | ||
RESET(0) | ||
} | ||
|
||
%extend std::vector<bool> { | ||
TO_MATLAB(bool,mxCreateLogicalMatrix) | ||
FROM_MATLAB(bool,bool,mxCreateLogicalMatrix,BVector) | ||
RESET(false) | ||
} | ||
|
||
%extend std::vector<int> { | ||
TO_MATLAB(double,mxCreateDoubleMatrix) | ||
FROM_MATLAB(double,int,mxCreateDoubleMatrix,IVector) | ||
RESET(0) | ||
} | ||
|
||
%extend yarp::sig::VectorOf<double> { | ||
TO_MATLAB(double,mxCreateDoubleMatrix) | ||
FROM_MATLAB(double,double,mxCreateDoubleMatrix,yarp::sig::VectorOf<double>) | ||
RESET(0) | ||
} | ||
|
||
RESET_CONSTANTS_IN_TO_MATLAB |
Oops, something went wrong.