14#include <yarp/os/ConnectionReader.h>
15#include <yarp/os/ConnectionWriter.h>
16#include <yarp/math/Math.h>
21using namespace yarp::os;
22using namespace yarp::sig;
23using namespace yarp::math;
38 init(_bodyPart, _linkNumber, _CoP);
42 init(_bodyPart, _linkNumber, _CoP, _Mu);
46 init(_bodyPart, _linkNumber, _CoP, _Mu, _Fdir);
49void dynContact::init(
const BodyPart &_bodyPart,
unsigned int _linkNumber,
const Vector &_CoP,
const Vector &_Mu,
const Vector &_Fdir){
114 fprintf(stderr,
"Error in dynContact: negative force module, %f\n", _Fmodule);
125 double FdirNorm =
norm(_Fdir);
127 Fdir = _Fdir / FdirNorm;
146 bool res =
setForce(_FMu.subVector(0,2));
147 return res &&
setMoment(_FMu.subVector(3,5));
201 connection.appendInt32(BOTTLE_TAG_LIST);
202 connection.appendInt32(4);
204 connection.appendInt32(BOTTLE_TAG_LIST + BOTTLE_TAG_INT32);
205 connection.appendInt32(3);
210 connection.appendInt32(BOTTLE_TAG_LIST + BOTTLE_TAG_FLOAT64);
211 connection.appendInt32(3);
212 for(
int i=0;i<3;i++) connection.appendFloat64(
CoP[i]);
214 connection.appendInt32(BOTTLE_TAG_LIST + BOTTLE_TAG_FLOAT64);
215 connection.appendInt32(3);
216 for(
int i=0;i<3;i++) connection.appendFloat64(
F[i]);
218 connection.appendInt32(BOTTLE_TAG_LIST + BOTTLE_TAG_FLOAT64);
219 connection.appendInt32(3);
220 for(
int i=0;i<3;i++) connection.appendFloat64(
Mu[i]);
224 connection.convertTextMode();
226 return !connection.isError();
231 connection.convertTextMode();
238 if(connection.expectInt32()!= BOTTLE_TAG_LIST || connection.expectInt32()!=4)
241 if(connection.expectInt32()!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT32 || connection.expectInt32()!=3)
247 if(connection.expectInt32()!=BOTTLE_TAG_LIST+BOTTLE_TAG_FLOAT64 || connection.expectInt32()!=3)
249 for(
int i=0;i<3;i++)
CoP[i] = connection.expectFloat64();
251 if(connection.expectInt32()!=BOTTLE_TAG_LIST+BOTTLE_TAG_FLOAT64 || connection.expectInt32()!=3)
253 for(
int i=0;i<3;i++)
F[i] = connection.expectFloat64();
256 if(connection.expectInt32()!=BOTTLE_TAG_LIST+BOTTLE_TAG_FLOAT64 || connection.expectInt32()!=3)
258 for(
int i=0;i<3;i++)
Mu[i] = connection.expectFloat64();
260 return !connection.isError();
266 CoP.toString(precision)<<
", F: "<<
F.toString(precision)<<
", M: "<<
Mu.toString(precision);
275 if(v.length() != dim){
277 fprintf(stderr,
"Error in dynContact: unexpected dimension of vector %s, %d\n", descr.c_str(), (
int)v.length());
double norm(const yarp::sig::Matrix &M, int col)
Returns the norm of the vector given in the form: matrix(:,col).
const std::string BodyPart_s[]