2 #include <hrpModel/Sensor.h> 10 const char *i_portName,
11 const std::vector<Link *> &i_joints,
12 std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo) :
22 const char *i_portName,
23 const std::vector<Link *> &i_joints) :
32 const char *i_portName,
33 const std::vector<Link *> &i_joints,
34 std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo) :
44 }
while(m_port.
isNew());
53 const char *i_portName,
54 const std::vector<Link *> &i_joints) :
69 const char *i_portName,
70 const std::vector<Link *> &i_joints,
71 std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo) :
81 }
while(m_port.
isNew());
90 const char *i_portName,
91 const std::vector<Link *> &i_joints) :
106 const char *i_portName,
107 const std::vector<Link *> &i_joints,
108 std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo) :
118 }
while(m_port.
isNew());
127 const char *i_portName,
128 const std::vector<Link *> &i_joints) :
143 const char *i_portName,
144 const std::vector<Link *> &i_joints,
145 std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo) :
155 }
while(m_port.
isNew());
156 if (m_data.data.length() !=
m_joints.size()){
157 std::cerr <<
"JointTorqueInPortHandler: data length mismatch(length of input data:" 158 << m_data.data.length() <<
"<->the number of joints:" <<
m_joints.size()
169 const char *i_portName,
170 const std::vector<Link *> &i_joints) :
185 const char *i_portName,
189 m_data.data.length(6);
201 const char *i_portName,
217 const char *i_portName,
233 const char *i_portName,
238 m_data.config.minAngle = -i_sensor->
scanAngle/2;
239 m_data.config.maxAngle = i_sensor->
scanAngle/2;
240 m_data.config.angularRes = i_sensor->
scanStep;
241 m_data.config.minRange = 0;
243 m_data.config.rangeRes = 0;
244 m_data.config.frequency = i_sensor->
scanRate;
263 const char *i_portName,
272 m_data.data.image.format = Img::CF_RGB;
274 m_data.data.image.raw_data.length(len);
275 m_data.data.intrinsic.distortion_coefficient.length(5);
276 for(
int i = 0;
i < 5;
i++){
277 m_data.data.intrinsic.distortion_coefficient[
i] = 0;
280 m_data.data.intrinsic.matrix_element[0]=0.5 *
m_sensor->
width/tan(fovx/2.0);
281 m_data.data.intrinsic.matrix_element[1]=0.0;
289 m_data.data.image.format = Img::CF_GRAY;
291 m_data.data.image.raw_data.length(len);
292 m_data.data.intrinsic.distortion_coefficient.length(5);
293 for(
int i = 0;
i < 5;
i++){
294 m_data.data.intrinsic.distortion_coefficient[
i] = 0;
297 m_data.data.intrinsic.matrix_element[0]=0.5 *
m_sensor->
width/tan(fovx/2.0);
298 m_data.data.intrinsic.matrix_element[1]=0.0;
312 if (m_data.data.image.raw_data.length() !=
m_sensor->
image.size()){
313 std::cerr <<
"BodyRTC: mismatch image length " 314 << m_data.data.image.raw_data.length()
317 memcpy(m_data.data.image.raw_data.get_buffer(),
323 std::ofstream ofs(filename, std::ios::out | std::ios::trunc | std::ios::binary );
333 ofs << std::endl << buf << std::endl <<
"255" << std::endl;
344 const char *i_portName,
350 case VisionSensor::DEPTH:
352 case VisionSensor::COLOR_DEPTH:
354 case VisionSensor::MONO_DEPTH:
358 <<
" doesn't have distance measuring function" << std::endl;
365 bool colored =
false;
367 m_data.fields.length(3);
369 m_data.fields.length(6);
372 std::cerr <<
"unknown point cloud format:[" <<
m_pcFormat <<
"]" << std::endl;
374 m_data.fields[0].name =
"x";
375 m_data.fields[0].offset = 0;
376 m_data.fields[0].data_type = PointCloudTypes::FLOAT32;
377 m_data.fields[0].count = 4;
378 m_data.fields[1].name =
"y";
379 m_data.fields[1].offset = 4;
380 m_data.fields[1].data_type = PointCloudTypes::FLOAT32;
381 m_data.fields[1].count = 4;
382 m_data.fields[2].name =
"z";
383 m_data.fields[2].offset = 8;
384 m_data.fields[2].data_type = PointCloudTypes::FLOAT32;
385 m_data.fields[2].count = 4;
387 m_data.fields[3].name =
"r";
388 m_data.fields[3].offset = 12;
389 m_data.fields[3].data_type = PointCloudTypes::UINT8;
390 m_data.fields[3].count = 1;
391 m_data.fields[4].name =
"g";
392 m_data.fields[4].offset = 13;
393 m_data.fields[4].data_type = PointCloudTypes::UINT8;
394 m_data.fields[4].count = 1;
395 m_data.fields[5].name =
"b";
396 m_data.fields[5].offset = 14;
397 m_data.fields[5].data_type = PointCloudTypes::UINT8;
398 m_data.fields[5].count = 1;
400 m_data.is_bigendian =
false;
401 m_data.point_step = 16;
402 m_data.is_dense =
true;
419 const char *i_portName,
426 void AbsTransformInPortHandler::update()
431 }
while(m_port.isNew());
433 m_data.data.position.x,
434 m_data.data.position.y,
435 m_data.data.position.z;
437 m_data.data.orientation.p,
438 m_data.data.orientation.y);
439 m_link->setSegmentAttitude(R);
445 const char *i_portName,
457 }
while(m_port.
isNew());
458 m_link->
v << m_data.data[0], m_data.data[1], m_data.data[2];
459 m_link->
w << m_data.data[3], m_data.data[4], m_data.data[5];
466 const char *i_portName,
478 }
while(m_port.
isNew());
479 m_link->
dv << m_data.data[0], m_data.data[1], m_data.data[2];
480 m_link->
dw << m_data.data[3], m_data.data[4], m_data.data[5];
486 const char *i_portName,
498 }
while(m_port.
isNew());
505 const char *i_portName,
517 }
while(m_port.
isNew());
524 const char *i_portName,
527 m_link(i_link), m_sensor(NULL)
533 const char *i_portName,
536 m_link(NULL), m_sensor(i_sensor)
540 void AbsTransformOutPortHandler::update(
double time)
546 R = m_link->attitude();
549 p = parent->
R*m_sensor->localPos+parent->
p;
550 R = parent->
R*m_sensor->localR;
552 m_data.data.position.x = p[0];
553 m_data.data.position.y = p[1];
554 m_data.data.position.z = p[2];
556 m_data.data.orientation.r = rpy[0];
557 m_data.data.orientation.p = rpy[1];
558 m_data.data.orientation.y = rpy[2];
565 const char *i_portName,
570 m_data.data.length(6);
584 const char *i_portName,
589 m_data.data.length(6);
604 const char *i_portName,
621 const char *i_portName,
626 rs =
new OpenHRP::RobotHardwareService::RobotState();
632 m_data.data.length(
rs->servoState.length());
633 for (
size_t i=0;
i <
rs->servoState.length();
i++) {
634 m_data.data[
i].length(
rs->servoState[
i].length());
635 for (
size_t j=0; j <
rs->servoState[
i].length(); j++) {
636 m_data.data[
i][j] =
rs->servoState[
i][j];
JointTorqueInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints, std::vector< OpenHRP::RobotHardwareService::SwitchStatus > *i_servo)
std::vector< double > distances
ServoStatePortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, BodyRTC *i_body)
JointAccelerationOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints)
BodyRTC::emg_reason m_emergencyReason
AccelSensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::AccelSensor *i_sensor)
JointOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints)
RangeSensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::RangeSensor *i_sensor)
EmergencySignalPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, BodyRTC *i_body)
std::vector< unsigned char > image
JointTorqueOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints)
JointVelocityInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints, std::vector< OpenHRP::RobotHardwareService::SwitchStatus > *i_servo)
void setVector3(const Vector3 &v3, V &v, size_t top=0)
JointVelocityOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints)
hrp::ForceSensor * m_sensor
ForceSensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::ForceSensor *i_sensor)
PointCloudPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::VisionSensor *i_sensor)
Matrix33 rotFromRpy(const Vector3 &rpy)
JointValueOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints)
std::vector< OpenHRP::RobotHardwareService::SwitchStatus > & m_servo
OpenHRP::RobotHardwareService::RobotState * rs
JointInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints, std::vector< OpenHRP::RobotHardwareService::SwitchStatus > *i_servo)
std::vector< hrp::Link * > m_joints
FrameRateInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::VisionSensor *i_sensor)
hrp::VisionSensor * m_sensor
VisionSensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::VisionSensor *i_sensor)
RateGyroSensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::RateGyroSensor *i_sensor)
HRP_UTIL_EXPORT Vector3 rpyFromRot(const Matrix33 &m)
std::vector< unsigned char > depth
JointAccelerationInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints, std::vector< OpenHRP::RobotHardwareService::SwitchStatus > *i_servo)
std::string sprintf(char const *__restrict fmt,...)
JointValueInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, const std::vector< hrp::Link *> &i_joints, std::vector< OpenHRP::RobotHardwareService::SwitchStatus > *i_servo)
AbsAccelerationInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::Link *i_link)
LightSwitchInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::Light *i_light)
AbsAccelerationOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::Link *i_link)
AbsVelocityInPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::Link *i_link)
std::vector< hrp::Link * > m_joints
void getStatus(OpenHRP::RobotHardwareService::RobotState *rs)
AbsVelocityOutPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, hrp::Link *i_link)