-
Notifications
You must be signed in to change notification settings - Fork 277
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
Adding MecanumDrive plugin with Odom and Tf, with Tests. #2297
base: gz-sim8
Are you sure you want to change the base?
Conversation
Thanks for your contribution @muttistefano. Do you mind fixing the linter issues and signing off on your commit (see https://github.com/gazebosim/gz-sim/pull/2297/checks?check_run_id=20866188364). |
Hi @azeey , thanks for the answer. |
There are some trailing white spaces in the code (see https://github.com/gazebosim/gz-sim/actions/runs/7765649621/job/21405089973?pr=2297). |
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Signed-off-by: Stefano Mutti <[email protected]>
Hello ! |
If I'm not mistaken, the checks are fine, the only thing missing is the review from @mjcarroll . |
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.
@muttistefano I think you've accidentally checked in a few files and directories (e.g. log
, .vscode
) to the pull request. Could you please remove them?
My bad; it should be fixed now. |
Can you fix DCO? |
Signed-off-by: Stefano Mutti <[email protected]>
#include "gz/sim/components/Model.hh" | ||
#include "gz/sim/components/Pose.hh" | ||
#include "gz/sim/Server.hh" | ||
#include "gz/sim/SystemLoader.hh" |
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.
This header seems to be unused. Can you remove?
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.
ok i take out #include "gz/sim/SystemLoader.hh"
// EXPECT_NEAR(poses.back().Pos().X(), finalModelFramePose.Pos().X(), 1e-2); | ||
// EXPECT_NEAR(poses.back().Pos().Y(), finalModelFramePose.Pos().Y(), 1e-2); |
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.
Is there a reason for commenting these out? finalModelFramePose
is now an unused variable.
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.
i missed them, i put them back in and tested them
///////////////////////////////////////////////// | ||
// See: https://github.com/gazebosim/gz-sim/issues/1175 | ||
// See: https://github.com/gazebosim/gz-sim/issues/630 | ||
TEST_P(MecanumDriveTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(PublishCmd)) |
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.
I know this is copied from the DiffDrive test, but can we first try to enable it and see if it doesn't work on the other platforms?
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.
i don't quite get what do you mean, since my testing skills are weak.
do you mean changing GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX to something that enables the tests on other OSs ?
testCmdVel(true /*test forward movement*/); | ||
testCmdVel(false /*test backward movement*/); |
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.
I was unaware that this MR existed and basically did the exact same work two weeks ago. I also refactored the TestPublishCmd
function to also test the sideways, diagonal and rotational movement of the drive instead of only forward and backward, which is what the diff drive test does.
Feel free to grab the function code from my changes in here to improve the coverage.
// Odometry calculates the pose of a point that is located half way | ||
// between the two wheels, not the origin of the model. For example, | ||
// if the vehicle is commanded to rotate in place, the vehicle will | ||
// rotate about the point half way between the two wheels, thus, | ||
// the odometry position will remain zero. | ||
// However, since the model origin is offset, the model position will | ||
// change. To find the final pose of the model, we have to do the | ||
// following similarity transformation | ||
|
||
math::Pose3d tOdomModel(0.554283,0,-0.325,0,0,0); |
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.
This transform is correct for the differential drive model, but not for the mecanum one. The mecanum math derivation places the origin at the center of the four wheels, which for the model in the xml is at math::Pose3d tOdomModel(-0.2, 0., 0., 0., 0., 0.);
This is not noticed in the test probably because no rotation is being applied to the drive.
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.
Hi @glpuga and thanks for the info.
I am merging your test with mine but I have some problems with rotation.
I will try to understand more , up to now the error is :
'
mecanum_drive_system.cc:220: Failure
Expected: (desiredAngVel * relativeMotionRot.Yaw()) > (0.0), actual: -0.570339 vs 0
'
where desiredAngVel and relativeMotionRot.Yaw() are -0.2 2.85169.
I guess I have an inconsistent rotation.
I will fix other comments for now and then I will get back here
any updates on this? It would be really great to have this implemented! Thanks! |
/// \param[in] _sdfFile SDF file to load. | ||
/// \param[in] _cmdVelTopic Command velocity topic. | ||
/// \param[in] _odomTopic Odometry topic. | ||
protected: void TestPublishCmd(const std::string &_sdfFile, |
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.
include <string>
// Create a system that records the vehicle poses | ||
test::Relay testSystem; | ||
|
||
std::vector<math::Pose3d> poses; |
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.
include <vector>
double period{1.0 / 50.0}; | ||
double lastMsgTime{1.0}; | ||
std::vector<math::Pose3d> odomPoses; | ||
std::function<void(const msgs::Odometry &)> odomCb = |
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.
include <functional>
// Start server | ||
ServerConfig serverConfig; | ||
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) + | ||
"/test/worlds/mecanum_drive.sdf"); |
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.
use gz::common::joinPath()
// Start server | ||
ServerConfig serverConfig; | ||
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) + | ||
"/test/worlds/mecanum_drive_custom_frame_id.sdf"); |
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.
use gz::common::joinPath()
// Start server | ||
ServerConfig serverConfig; | ||
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) + | ||
"/test/worlds/mecanum_drive_custom_tf_topic.sdf"); |
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.
use gz::common::joinPath()
|
||
msgs::Twist msg; | ||
msgs::Set(msg.mutable_linear(), math::Vector3d(0.5, 0, 0)); | ||
msgs::Set(msg.mutable_angular(), math::Vector3d(0.0, 0, 0.2)); |
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.
include `gz::math::Vector3.hh
</link> | ||
|
||
|
||
<joint name='front_left_wheel_joint' type='revolute'> |
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.
</link> | |
<joint name='front_left_wheel_joint' type='revolute'> | |
</link> | |
<joint name='front_left_wheel_joint' type='revolute'> |
Co-authored-by: Addisu Z. Taddese <[email protected]> Signed-off-by: muttistefano <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]> Signed-off-by: muttistefano <[email protected]>
I cannot work anymore on gz-sim8 cause I don't have an Ubuntu 22 PC. |
@muttistefano, |
🎉 New feature
Summary
Adding MecanumDrive plugin with Odom and Tf, with Tests.
Relative to #1665 , but targets gz-sim8, fixes an include error in the plugin and add tests.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸