13 #include <hrpModel/ModelLoaderUtil.h> 19 "implementation_id",
"StateHolder",
20 "type_name",
"StateHolder",
21 "description",
"state holder",
22 "version", HRPSYS_PACKAGE_VERSION,
24 "category",
"example",
25 "activity_type",
"DataFlowComponent",
28 "lang_type",
"compile",
38 m_currentQIn(
"currentQIn", m_currentQ),
41 m_basePosIn(
"basePosIn", m_basePos),
42 m_baseRpyIn(
"baseRpyIn", m_baseRpy),
43 m_zmpIn(
"zmpIn", m_zmp),
44 m_optionalDataIn(
"optionalDataIn", m_optionalData),
46 m_tqOut(
"tqOut", m_tq),
47 m_basePosOut(
"basePosOut", m_basePos),
48 m_baseRpyOut(
"baseRpyOut", m_baseRpy),
49 m_baseTformOut(
"baseTformOut", m_baseTform),
50 m_basePoseOut(
"basePoseOut", m_basePose),
51 m_zmpOut(
"zmpOut", m_zmp),
52 m_optionalDataOut(
"optionalDataOut", m_optionalData),
53 m_StateHolderServicePort(
"StateHolderService"),
54 m_TimeKeeperServicePort(
"TimeKeeperService"),
76 std::cerr <<
"[" <<
m_profile.instance_name <<
"] onInitialize()" << std::endl;
117 std::cout <<
"StateHolder: dt = " <<
m_dt << std::endl;
119 std::string nameServer = rtcManager.
getConfig()[
"corba.nameservers"];
120 int comPos = nameServer.find(
",");
122 comPos = nameServer.length();
124 nameServer = nameServer.substr(0, comPos);
126 OpenHRP::BodyInfo_var binfo;
128 CosNaming::NamingContext::_duplicate(
naming.getRootContext()));
129 OpenHRP::LinkInfoSequence_var lis = binfo->links();
130 const OpenHRP::LinkInfo& li = lis[0];
132 p << li.translation[0], li.translation[1], li.translation[2];
133 axis << li.rotation[0], li.rotation[1], li.rotation[2];
139 T[0] =
R(0,0); T[1] =
R(0,1); T[ 2] =
R(0,2); T[ 3] = p[0];
140 T[4] =
R(0,0); T[5] =
R(0,1); T[ 6] =
R(0,2); T[ 7] = p[1];
141 T[8] =
R(0,0); T[9] =
R(0,1); T[10] =
R(0,2); T[11] = p[2];
151 std::vector<std::string> fsensor_names;
153 for (
unsigned int k = 0; k < lis->length(); k++ ) {
154 OpenHRP::SensorInfoSequence& sensors = lis[k].sensors;
155 for (
unsigned int l = 0;
l < sensors.length();
l++ ) {
156 if ( std::string(sensors[
l].
type) ==
"Force" ) {
157 fsensor_names.push_back(std::string(sensors[
l].
name));
161 int npforce = fsensor_names.size();
164 unsigned int nvforce = virtual_force_sensor.size()/10;
165 for (
unsigned int i=0;
i<nvforce;
i++){
166 fsensor_names.push_back(virtual_force_sensor[
i*10+0]);
169 unsigned int nforce = npforce + nvforce;
173 for (
unsigned int i=0;
i<nforce;
i++){
180 registerOutPort(std::string(fsensor_names[i]+
"Out").c_str(), *m_wrenchesOut[i]);
234 tm.sec = coiltm.
sec();
235 tm.nsec = coiltm.
usec()*1000;
246 if (
m_q.data.length() !=
m_tq.data.length())
m_tq.data.length(
m_q.data.length());
306 if (
m_q.data.length() > 0){
309 if (
m_tq.data.length() > 0){
368 std::cout <<
"StateHolder::goActual()" << std::endl;
375 com.jointRefs.length(
m_q.data.length());
376 memcpy(com.jointRefs.get_buffer(),
m_q.data.get_buffer(),
sizeof(double)*
m_q.data.length());
377 com.baseTransform.length(12);
382 double *
a = com.baseTransform.get_buffer();
385 com.zmp[0] =
m_zmp.data.x; com.zmp[1] =
m_zmp.data.y; com.zmp[2] =
m_zmp.data.z;
401 RTC::Create<StateHolder>,
402 RTC::Delete<StateHolder>);
ComponentProfile m_profile
TimeKeeperService_impl m_service1
png_infop png_charpp int png_charpp profile
StateHolderService_impl m_service0
RTC::CorbaPort m_StateHolderServicePort
InPort< TimedDoubleSeq > m_tqIn
OutPort< TimedPoint3D > m_basePosOut
png_infop png_charp png_int_32 png_int_32 int * type
HRPMODEL_API OpenHRP::BodyInfo_var loadBodyInfo(const char *url, int &argc, char *argv[])
bool stringTo(To &val, const char *str)
InPort< TimedPoint3D > m_basePosIn
png_infop png_charpp name
OutPort< TimedDoubleSeq > m_tqOut
void setComponent(StateHolder *i_comp)
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
std::vector< InPort< TimedDoubleSeq > * > m_wrenchesIn
TimedOrientation3D m_baseRpy
void setComponent(StateHolder *i_comp)
coil::Properties & getProperties()
static Manager & instance()
OutPort< TimedOrientation3D > m_baseRpyOut
bool addOutPort(const char *name, OutPortBase &outport)
RTC::CorbaPort m_TimeKeeperServicePort
OutPort< TimedDoubleSeq > m_qOut
Matrix33 rotFromRpy(const Vector3 &rpy)
std::vector< std::string > vstring
void setMatrix33ToRowMajorArray(const Matrix33 &m33, Array &a, size_t top=0)
int gettimeofday(struct timeval *tv, struct timezone *tz)
coil::Properties & getConfig()
OutPort< TimedDoubleSeq > m_optionalDataOut
ExecutionContextHandle_t UniqueId
InPort< TimedDoubleSeq > m_optionalDataIn
void getCommand(StateHolderService::Command &com)
Matrix33 rodrigues(const Vector3 &axis, double q)
virtual ~StateHolder()
Destructor.
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
void wait(CORBA::Double tm)
HRP_UTIL_EXPORT Vector3 rpyFromRot(const Matrix33 &m)
InPort< TimedOrientation3D > m_baseRpyIn
OutPort< TimedPose3D > m_basePoseOut
void registerInPort(const char *name, InPortBase &inport)
std::vector< OutPort< TimedDoubleSeq > * > m_wrenchesOut
void StateHolderInit(RTC::Manager *manager)
InPort< TimedDoubleSeq > m_qIn
bool addPort(PortBase &port)
virtual bool write(DataType &value)
TimedDoubleSeq m_baseTform
InPort< TimedPoint3D > m_zmpIn
OutPort< TimedPoint3D > m_zmpOut
bool addInPort(const char *name, InPortBase &inport)
StateHolder(RTC::Manager *manager)
Constructor.
OutPort< TimedDoubleSeq > m_baseTformOut
TimedDoubleSeq m_currentQ
void registerOutPort(const char *name, OutPortBase &outport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
virtual RTC::ReturnCode_t onInitialize()
static const char * stateholder_spec[]
InPort< TimedDoubleSeq > m_currentQIn
std::vector< TimedDoubleSeq > m_wrenches
bool registerProvider(const char *instance_name, const char *type_name, PortableServer::RefCountServantBase &provider)