Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ports for offsets of limbCOP #538

Merged
merged 2 commits into from
Mar 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/hrpsys_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ def connectComps(self):
if self.abc:
connectPorts(self.sh.port(sen+"Out"),
self.abc.port("ref_" + sen))
if self.abc and self.st:
connectPorts(self.abc.port("limbCOPOffset_"+sen),
self.st.port("limbCOPOffset_"+sen))

# actual force sensors
if self.rmfo:
Expand Down
22 changes: 22 additions & 0 deletions rtc/AutoBalancer/AutoBalancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ RTC::ReturnCode_t AutoBalancer::onInitialize()
int nforce = npforce + nvforce;
m_ref_force.resize(nforce);
m_ref_forceIn.resize(nforce);
m_limbCOPOffset.resize(nforce);
m_limbCOPOffsetOut.resize(nforce);
for (unsigned int i=0; i<npforce; i++){
sensor_names.push_back(m_robot->sensor(hrp::Sensor::FORCE, i)->name);
}
Expand All @@ -248,6 +250,15 @@ RTC::ReturnCode_t AutoBalancer::onInitialize()
std::cerr << "[" << m_profile.instance_name << "] name = " << std::string("ref_"+sensor_names[i]) << std::endl;
ref_forces.push_back(hrp::Vector3(0,0,0));
}
// set limb cop offset port
std::cerr << "[" << m_profile.instance_name << "] limbCOPOffset ports (" << nforce << ")" << std::endl;
for (unsigned int i=0; i<nforce; i++){
std::string nm("limbCOPOffset_"+sensor_names[i]);
m_limbCOPOffsetOut[i] = new OutPort<TimedPoint3D>(nm.c_str(), m_limbCOPOffset[i]);
registerOutPort(nm.c_str(), *m_limbCOPOffsetOut[i]);
m_limbCOPOffset[i].data.x = m_limbCOPOffset[i].data.y = m_limbCOPOffset[i].data.z = 0.0;
std::cerr << "[" << m_profile.instance_name << "] name = " << nm << std::endl;
}
sbp_offset = hrp::Vector3(0,0,0);
sbp_cog_offset = hrp::Vector3(0,0,0);
//use_force = MODE_NO_FORCE;
Expand Down Expand Up @@ -481,6 +492,11 @@ RTC::ReturnCode_t AutoBalancer::onExecute(RTC::UniqueId ec_id)
m_controlSwingSupportTime.tm = m_qRef.tm;
m_controlSwingSupportTimeOut.write();

for (unsigned int i=0; i<m_limbCOPOffsetOut.size(); i++){
m_limbCOPOffset[i].tm = m_qRef.tm;
m_limbCOPOffsetOut[i]->write();
}

return RTC::RTC_OK;
}

Expand Down Expand Up @@ -513,6 +529,12 @@ void AutoBalancer::getTargetParameters()
for (size_t i = 0; i < 2; i++)
for (size_t j = 0; j < 3; j++)
default_zmp_offsets[i](j) = default_zmp_offsets_output[i*3+j];
m_limbCOPOffset[contact_states_index_map["rleg"]].data.x = default_zmp_offsets[0](0);
m_limbCOPOffset[contact_states_index_map["rleg"]].data.y = default_zmp_offsets[0](1);
m_limbCOPOffset[contact_states_index_map["rleg"]].data.z = default_zmp_offsets[0](2);
m_limbCOPOffset[contact_states_index_map["lleg"]].data.x = default_zmp_offsets[1](0);
m_limbCOPOffset[contact_states_index_map["lleg"]].data.y = default_zmp_offsets[1](1);
m_limbCOPOffset[contact_states_index_map["lleg"]].data.z = default_zmp_offsets[1](2);
if (DEBUGP) {
std::cerr << "[" << m_profile.instance_name << "] default_zmp_offsets (interpolated)" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] rleg = " << default_zmp_offsets[0].format(Eigen::IOFormat(Eigen::StreamPrecision, 0, ", ", ", ", "", "", " [", "]")) << "[m]" << std::endl;
Expand Down
2 changes: 2 additions & 0 deletions rtc/AutoBalancer/AutoBalancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ class AutoBalancer
OutPort<TimedBooleanSeq> m_contactStatesOut;
TimedDoubleSeq m_controlSwingSupportTime;
OutPort<TimedDoubleSeq> m_controlSwingSupportTimeOut;
std::vector<TimedPoint3D> m_limbCOPOffset;
std::vector<OutPort<TimedPoint3D> *> m_limbCOPOffsetOut;
// for debug
OutPort<TimedPoint3D> m_cogOut;

Expand Down
15 changes: 15 additions & 0 deletions rtc/Stabilizer/Stabilizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ RTC::ReturnCode_t Stabilizer::onInitialize()
int npforce = m_robot->numSensors(hrp::Sensor::FORCE);
m_wrenches.resize(npforce);
m_wrenchesIn.resize(npforce);
m_limbCOPOffset.resize(npforce);
m_limbCOPOffsetIn.resize(npforce);
for (unsigned int i=0; i<npforce; ++i){
hrp::Sensor *s = m_robot->sensor(hrp::Sensor::FORCE, i);
m_wrenchesIn[i] = new RTC::InPort<RTC::TimedDoubleSeq>(std::string(s->name+"Ref").c_str(), m_wrenches[i]);
Expand All @@ -172,6 +174,14 @@ RTC::ReturnCode_t Stabilizer::onInitialize()
std::cerr << "[" << m_profile.instance_name << "] force sensor" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] name = " << s->name << std::endl;
}
std::cerr << "[" << m_profile.instance_name << "] limbCOPOffset ports (" << npforce << ")" << std::endl;
for (unsigned int i=0; i<npforce; ++i){
hrp::Sensor *s = m_robot->sensor(hrp::Sensor::FORCE, i);
std::string nm("limbCOPOffset_"+s->name);
m_limbCOPOffsetIn[i] = new RTC::InPort<RTC::TimedPoint3D>(nm.c_str(), m_limbCOPOffset[i]);
registerInPort(nm.c_str(), *m_limbCOPOffsetIn[i]);
std::cerr << "[" << m_profile.instance_name << "] name = " << nm << std::endl;
}

// setting from conf file
// rleg,TARGET_LINK,BASE_LINK,x,y,z,rx,ry,rz,rth #<=pos + rot (axis+angle)
Expand Down Expand Up @@ -387,6 +397,11 @@ RTC::ReturnCode_t Stabilizer::onExecute(RTC::UniqueId ec_id)
m_wrenchesIn[i]->read();
}
}
for (size_t i = 0; i < m_limbCOPOffsetIn.size(); ++i) {
if ( m_limbCOPOffsetIn[i]->isNew() ) {
m_limbCOPOffsetIn[i]->read();
}
}

if (is_legged_robot) {
getCurrentParameters();
Expand Down
2 changes: 2 additions & 0 deletions rtc/Stabilizer/Stabilizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Stabilizer
RTC::TimedOrientation3D m_baseRpy;
RTC::TimedBooleanSeq m_contactStates;
RTC::TimedDoubleSeq m_controlSwingSupportTime;
std::vector<RTC::TimedPoint3D> m_limbCOPOffset;
RTC::TimedBooleanSeq m_actContactStates;
// for debug ouput
RTC::TimedPoint3D m_originRefZmp, m_originRefCog, m_originRefCogVel, m_originNewZmp;
Expand All @@ -186,6 +187,7 @@ class Stabilizer
RTC::InPort<RTC::TimedOrientation3D> m_baseRpyIn;
RTC::InPort<RTC::TimedBooleanSeq> m_contactStatesIn;
RTC::InPort<RTC::TimedDoubleSeq> m_controlSwingSupportTimeIn;
std::vector<RTC::InPort<RTC::TimedPoint3D> *> m_limbCOPOffsetIn;

std::vector<RTC::TimedDoubleSeq> m_wrenches;
std::vector<RTC::InPort<RTC::TimedDoubleSeq> *> m_wrenchesIn;
Expand Down