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

Connect encoderVelocities input #11

Merged
merged 1 commit into from
Jul 29, 2020
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
1 change: 1 addition & 0 deletions projects/JVRC1/cnoid/sim_mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def startMCControl():

def connectMCControl():
connectPorts(rh.port("q"), mc.port("qIn"))
connectPorts(rh.port("dq"), mc.port("alphaIn"))
connectPorts(rh.port("tauOut"), mc.port("taucIn"))
connectPorts(rh.port("gyrometer"), mc.port("rateIn"))
connectPorts(rh.port("gsensor"), mc.port("accIn"))
Expand Down
12 changes: 12 additions & 0 deletions src/MCControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MCControl::MCControl(RTC::Manager* manager)
m_timeStep(0.002),
m_enabled(false),
m_qInIn("qIn", m_qIn),
m_alphaInIn("alphaIn", m_alphaIn),
m_qInitIn("qInit", m_qInit),
m_pInIn("pIn", m_pIn),
m_rpyInIn("rpyIn", m_rpyIn),
Expand Down Expand Up @@ -116,6 +117,7 @@ RTC::ReturnCode_t MCControl::onInitialize()
// <rtc-template block="registration">
// Set InPort buffers
addInPort("qIn", m_qInIn);
addInPort("alphaIn", m_alphaInIn);
addInPort("qInit", m_qInitIn);
addInPort("pIn", m_pInIn);
addInPort("rpyIn", m_rpyInIn);
Expand Down Expand Up @@ -292,6 +294,15 @@ RTC::ReturnCode_t MCControl::onExecute(RTC::UniqueId ec_id)
qInit[i] = m_qInit.data[i];
}
}
if(m_alphaInIn.isNew())
{
m_alphaInIn.read();
alphaIn.resize(m_alphaIn.data.length());
for(unsigned int i = 0; i < alphaIn.size(); ++i)
{
alphaIn[i] = m_alphaIn.data[i];
}
}
if(m_qInIn.isNew())
{
m_qInIn.read();
Expand All @@ -310,6 +321,7 @@ RTC::ReturnCode_t MCControl::onExecute(RTC::UniqueId ec_id)
controller.setSensorLinearVelocity(velIn.linear());
controller.setSensorAcceleration(accIn);
controller.setEncoderValues(qIn);
controller.setEncoderVelocities(alphaIn);
controller.setWrenches(m_wrenches);
controller.setJointTorques(taucIn);

Expand Down
3 changes: 3 additions & 0 deletions src/MCControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class MCControl : public RTC::DataFlowComponentBase
TimedDoubleSeq m_qIn;
InPort<TimedDoubleSeq> m_qInIn;
std::vector<double> qIn;
TimedDoubleSeq m_alphaIn;
InPort<TimedDoubleSeq> m_alphaInIn;
std::vector<double> alphaIn;
TimedDoubleSeq m_qInit;
InPort<TimedDoubleSeq> m_qInitIn;
std::vector<double> qInit = {};
Expand Down