-
Notifications
You must be signed in to change notification settings - Fork 46
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
Streaming odometry info, CoM and footsteps #145
base: master
Are you sure you want to change the base?
Changes from 2 commits
fa8eed8
2acaf82
4742c72
ece926f
34c958b
01ba7bc
d611ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,6 +264,23 @@ namespace WalkingControllers | |
* Reset the planner | ||
*/ | ||
void reset(); | ||
|
||
/** | ||
* Get the footprints planned by the unicycle generator | ||
* @param leftFootprints vector containing the desired poses of the left foot on the xy plane | ||
* @param rightFootprints vector containing the desired poses of the right foot on the xy plane | ||
* @return true/false in case of success/failure. | ||
*/ | ||
bool getFootprints(std::vector<iDynTree::Vector3>& leftFootprints, std::vector<iDynTree::Vector3>& rightFootprints); | ||
|
||
/** | ||
* Get the unicycle state from the feet of the robot in the odom frame (aka world frame) | ||
* @param virtualUnicyclePose pose of the virtual unicycle in the odom frame | ||
* @param referenceUnicyclePose pose of the reference virtual unicycle in the odom frame | ||
* @param stanceFoot returns a string with the stance foot used for the computation | ||
* @return true/false in case of success/failure. | ||
*/ | ||
bool getUnicycleState(iDynTree::Vector3& virtualUnicyclePose, iDynTree::Vector3& referenceUnicyclePose, const std::string& stanceFoot); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
}; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -853,3 +853,104 @@ bool TrajectoryGenerator::getDesiredZMPPosition(std::vector<iDynTree::Vector2> & | |
desiredZMP = m_dcmGenerator->getZMPPosition(); | ||
return true; | ||
} | ||
|
||
//TODO improve conversion | ||
bool TrajectoryGenerator::getFootprints(std::vector<iDynTree::Vector3>& leftFootprints, std::vector<iDynTree::Vector3>& rightFootprints) | ||
{ | ||
auto leftDequeue = m_trajectoryGenerator.getLeftFootPrint()->getSteps(); | ||
for (size_t i = 0; i < leftDequeue.size(); ++i) | ||
{ | ||
iDynTree::Vector3 pose; | ||
pose(0) = leftDequeue.at(i).position(0); | ||
pose(1) = leftDequeue.at(i).position(1); | ||
pose(2) = leftDequeue.at(i).angle; | ||
leftFootprints.push_back(pose); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect this method to fill the input vectors rather than appending new elements. I would suggest to resize them to the correct dimension at the beginning, and then edit the elements by index. In this way, you can avoid to allocate new memory if the number of footprints remains constant over time. |
||
} | ||
|
||
auto rightDeque = m_trajectoryGenerator.getRightFootPrint()->getSteps(); | ||
for (size_t i = 0; i < rightDeque.size(); ++i) | ||
{ | ||
iDynTree::Vector3 pose; | ||
pose(0) = rightDeque.at(i).position(0); | ||
pose(1) = rightDeque.at(i).position(1); | ||
pose(2) = rightDeque.at(i).angle; | ||
rightFootprints.push_back(pose); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool TrajectoryGenerator::getUnicycleState(iDynTree::Vector3& virtualUnicyclePose, iDynTree::Vector3& referenceUnicyclePose, const std::string& stanceFoot) | ||
{ | ||
double nominalWidth; | ||
bool correctLeft; | ||
iDynTree::Vector2 measuredPositionLeft, measuredPositionRight; | ||
iDynTree::Vector3 desiredDirectControl; | ||
double measuredAngleLeft, measuredAngleRight; | ||
double leftYawDeltaInRad, rightYawDeltaInRad; | ||
// left foot | ||
measuredPositionLeft(0) = m_measuredTransformLeft.getPosition()(0); | ||
measuredPositionLeft(1) = m_measuredTransformLeft.getPosition()(1); | ||
measuredAngleLeft = m_measuredTransformLeft.getRotation().asRPY()(2); | ||
leftYawDeltaInRad = m_leftYawDeltaInRad; | ||
// right foot | ||
measuredPositionRight(0) = m_measuredTransformRight.getPosition()(0); | ||
measuredPositionRight(1) = m_measuredTransformRight.getPosition()(1); | ||
measuredAngleRight = m_measuredTransformRight.getRotation().asRPY()(2); | ||
rightYawDeltaInRad = m_rightYawDeltaInRad; | ||
correctLeft = m_correctLeft; | ||
m_newFreeSpaceEllipse = false; | ||
nominalWidth = m_nominalWidth; | ||
|
||
iDynTree::Vector2 measuredPosition; | ||
double measuredAngle; | ||
measuredPosition = correctLeft ? measuredPositionLeft : measuredPositionRight; | ||
measuredAngle = correctLeft ? measuredAngleLeft : measuredAngleRight; | ||
|
||
Eigen::Vector2d unicyclePositionFromStanceFoot, footPosition, unicyclePosition, unicycleOdom; | ||
unicyclePositionFromStanceFoot(0) = 0.0; | ||
Eigen::Matrix2d unicycleRotation; //rotation world -> unicycle | ||
double unicycleAngle, unicycleAngleOdom; | ||
|
||
if (stanceFoot == "left") | ||
{ | ||
unicyclePositionFromStanceFoot(1) = -nominalWidth/2; | ||
unicycleAngle = measuredAngleLeft; //- leftYawDeltaInRad | ||
unicycleAngleOdom = measuredAngleLeft - leftYawDeltaInRad; | ||
footPosition = iDynTree::toEigen(measuredPositionLeft); | ||
//stanceFoot = "left"; | ||
} | ||
else if (stanceFoot == "right") | ||
{ | ||
unicyclePositionFromStanceFoot(1) = nominalWidth/2; | ||
unicycleAngle = measuredAngleRight; //- rightYawDeltaInRad | ||
unicycleAngleOdom = measuredAngleRight - rightYawDeltaInRad; | ||
footPosition = iDynTree::toEigen(measuredPositionRight); | ||
//stanceFoot = "right"; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
|
||
//Odom (expressed in odom frame) | ||
double s_theta = std::sin(unicycleAngleOdom); | ||
double c_theta = std::cos(unicycleAngleOdom); | ||
unicycleRotation(0,0) = c_theta; | ||
unicycleRotation(0,1) = -s_theta; | ||
unicycleRotation(1,0) = s_theta; | ||
unicycleRotation(1,1) = c_theta; | ||
unicyclePosition = unicycleRotation * unicyclePositionFromStanceFoot; // position in respect to the support foot | ||
unicycleOdom = unicyclePosition + footPosition; //postion in odom frame | ||
virtualUnicyclePose(0) = unicycleOdom(0); | ||
virtualUnicyclePose(1) = unicycleOdom(1); | ||
virtualUnicyclePose(2) = unicycleAngleOdom; | ||
|
||
iDynTree::Vector2 referencePointInAbsoluteFrame; | ||
iDynTree::toEigen(referencePointInAbsoluteFrame) = unicycleRotation * (iDynTree::toEigen(m_referencePointDistance)) + unicycleOdom; | ||
referenceUnicyclePose(0) = referencePointInAbsoluteFrame(0); | ||
referenceUnicyclePose(1) = referencePointInAbsoluteFrame(1); | ||
referenceUnicyclePose(2) = unicycleAngleOdom; | ||
|
||
Comment on lines
+939
to
+957
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return true; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,9 @@ sampling_time 0.01 | |
# Specify the frame to use to control the robot height. Currently, we support only the following options: com, root_link | ||
height_reference_frame root_link | ||
|
||
# Loop rate for the thread computing the navigation trigger | ||
navigationTriggerLoopRate 100 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in #144, this would fit well in a separate file named |
||
# include robot control parameters | ||
[include ROBOT_CONTROL "./dcm_walking/joypad_control/robotControl.ini"] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From here it is not clear that the first two elements are the position and the third element is the angle. I would suggest using a dedicated struct