14 #include "hrpModel/ModelLoaderUtil.h" 22 "implementation_id",
"ForwardKinematics",
23 "type_name",
"ForwardKinematics",
24 "description",
"forward kinematics component",
25 "version", HRPSYS_PACKAGE_VERSION,
27 "category",
"example",
28 "activity_type",
"DataFlowComponent",
31 "lang_type",
"compile",
33 "conf.default.sensorAttachedLink",
"",
43 m_sensorRpyIn(
"sensorRpy", m_sensorRpy),
44 m_qRefIn(
"qRef", m_qRef),
45 m_basePosRefIn(
"basePosRef", m_basePosRef),
46 m_baseRpyRefIn(
"baseRpyRef", m_baseRpyRef),
47 m_ForwardKinematicsServicePort(
"ForwardKinematicsService"),
61 std::cerr <<
"[" <<
m_profile.instance_name <<
"] onInitialize()" << std::endl;
94 std::string nameServer = rtcManager.
getConfig()[
"corba.nameservers"];
95 int comPos = nameServer.find(
",");
97 comPos = nameServer.length();
99 nameServer = nameServer.substr(0, comPos);
103 CosNaming::NamingContext::_duplicate(
naming.getRootContext()))){
104 std::cerr <<
"[" <<
m_profile.instance_name <<
"] failed to load model[" << prop[
"model"] <<
"]" << std::endl;
105 return RTC::RTC_ERROR;
109 CosNaming::NamingContext::_duplicate(
naming.getRootContext()))){
110 std::cerr <<
"[" <<
m_profile.instance_name <<
"] failed to load model[" << prop[
"model"] <<
"]" << std::endl;
111 return RTC::RTC_ERROR;
145 std::cerr <<
"[" <<
m_profile.instance_name<<
"] onActivated(" << ec_id <<
")" << std::endl;
153 return RTC::RTC_ERROR;
161 std::cerr <<
"[" <<
m_profile.instance_name<<
"] onDeactivated(" << ec_id <<
")" << std::endl;
269 pose =
new RTC::TimedDoubleSeq();
272 if (!l)
return false;
277 std::cerr <<
"[getReferencePose] ERROR Could not find frame_name = " << frame_name << std::endl;
281 std::cerr <<
"[getReferencePose] linkaname = " << linkname <<
", frame_name = " << (frame_name?frame_name:
"(null)") << std::endl;
285 p = f->
attitude().transpose() * ( p - f->
p );
289 pose->data.length(16);
290 pose->data[ 0]=
R(0,0);pose->data[ 1]=
R(0,1);pose->data[ 2]=
R(0,2);pose->data[ 3]=p[0];
291 pose->data[ 4]=
R(1,0);pose->data[ 5]=
R(1,1);pose->data[ 6]=
R(1,2);pose->data[ 7]=p[1];
292 pose->data[ 8]=
R(2,0);pose->data[ 9]=
R(2,1);pose->data[10]=
R(2,2);pose->data[11]=p[2];
293 pose->data[12]=0; pose->data[13]=0; pose->data[14]=0; pose->data[15]=1;
299 pose =
new RTC::TimedDoubleSeq();
302 if (!l)
return false;
307 std::cerr <<
"[getCurrentPose] ERROR Could not find frame_name = " << frame_name << std::endl;
311 std::cerr <<
"[getCurrentPose] linkaname = " << linkname <<
", frame_name = " << (frame_name?frame_name:
"(null)") << std::endl;
317 p = f->
attitude().transpose() * ( p - f->
p);
321 pose->data.length(16);
322 pose->data[ 0]=
R(0,0);pose->data[ 1]=
R(0,1);pose->data[ 2]=
R(0,2);pose->data[ 3]=p[0];
323 pose->data[ 4]=
R(1,0);pose->data[ 5]=
R(1,1);pose->data[ 6]=
R(1,2);pose->data[ 7]=p[1];
324 pose->data[ 8]=
R(2,0);pose->data[ 9]=
R(2,1);pose->data[10]=
R(2,2);pose->data[11]=p[2];
325 pose->data[12]=0; pose->data[13]=0; pose->data[14]=0; pose->data[15]=1;
334 if (!from || !to)
return false;
335 hrp::Vector3 targetPrel(target[0], target[1], target[2]);
339 result[ 0]=p(0);result[ 1]=p(1);result[ 2]=p(2);
347 if (!l)
return false;
360 RTC::Create<ForwardKinematics>,
361 RTC::Delete<ForwardKinematics>);
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
std::string m_sensorAttachedLinkName
static const char * nullcomponent_spec[]
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
TimedOrientation3D m_baseRpyRef
InPort< TimedDoubleSeq > m_qIn
coil::Guard< coil::Mutex > Guard
InPort< TimedPoint3D > m_basePosRefIn
void ForwardKinematicsInit(RTC::Manager *manager)
InPort< TimedOrientation3D > m_sensorRpyIn
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
ForwardKinematicsService_impl m_service0
coil::Properties & getProperties()
static Manager & instance()
boost::shared_ptr< Body > BodyPtr
RTC::CorbaPort m_ForwardKinematicsServicePort
Matrix33 rotFromRpy(const Vector3 &rpy)
int gettimeofday(struct timeval *tv, struct timezone *tz)
coil::Properties & getConfig()
::CORBA::Boolean getRelativeCurrentPosition(const char *linknameFrom, const char *linknameTo, const OpenHRP::ForwardKinematicsService::position target, OpenHRP::ForwardKinematicsService::position result)
ExecutionContextHandle_t UniqueId
::CORBA::Boolean getReferencePose(const char *linkname, RTC::TimedDoubleSeq_out pose, const char *frame_name)
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
::CORBA::Boolean getCurrentPose(const char *linkname, RTC::TimedDoubleSeq_out pose, const char *frame_name)
int loadBodyFromModelLoader(::World *world, const char *name, const char *url, CosNaming::NamingContext_var cxt)
InPort< TimedDoubleSeq > m_qRefIn
hrp::Link * m_sensorAttachedLink
void setComp(ForwardKinematics *i_comp)
HRP_UTIL_EXPORT Vector3 rpyFromRot(const Matrix33 &m)
virtual RTC::ReturnCode_t onInitialize()
InPort< TimedOrientation3D > m_baseRpyRefIn
ForwardKinematics(RTC::Manager *manager)
Constructor.
TimedPoint3D m_basePosRef
bool addPort(PortBase &port)
::CORBA::Boolean selectBaseLink(const char *linkname)
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
TimedOrientation3D m_sensorRpy
bool registerProvider(const char *instance_name, const char *type_name, PortableServer::RefCountServantBase &provider)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
virtual ~ForwardKinematics()
Destructor.