Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

[ros2] Add ackermann drive plugin#947

Merged
chapulina merged 5 commits intoros-simulation:dashingfrom
shiveshkhaitan:ackermann
Jul 30, 2019
Merged

[ros2] Add ackermann drive plugin#947
chapulina merged 5 commits intoros-simulation:dashingfrom
shiveshkhaitan:ackermann

Conversation

@shiveshkhaitan
Copy link
Copy Markdown

Added ackermann drive plugin for ROS2. It subscribe to geometry_msgs/Twist for commands.

Example usage:

<plugin name="gazebo_ros_ackermann_drive" filename="libgazebo_ros_ackermann_drive.so">
  <ros>
    <namespace>demo</namespace>
    <argument>cmd_vel:=cmd_demo</argument>
    <argument>odom:=odom_demo</argument>
    <argument>distance:=distance_demo</argument>
  </ros>

  <update_rate>100.0</update_rate>

  <!-- wheels -->
  <front_left_joint>front_left_wheel_joint</front_left_joint>
  <front_right_joint>front_right_wheel_joint</front_right_joint>
  <rear_left_joint>rear_left_wheel_joint</rear_left_joint>
  <rear_right_joint>rear_right_wheel_joint</rear_right_joint>
  <left_steering_joint>front_left_steer_joint</left_steering_joint>
  <right_steering_joint>front_right_steer_joint</right_steering_joint>
  <steering_wheel_joint>steering_joint</steering_wheel_joint>

  <!-- Max absolute steer angle for tyre in radians-->
  <max_steer>0.6458</max_steer>
  <!-- Max absolute steering angle of steering wheel -->
  <max_steering_angle>7.85</max_steering_angle>
  <!-- Max absolute linear speed in m/s -->
  <max_speed>20</max_speed>

  <odometry_frame>odom_demo</odometry_frame>
  <robot_base_frame>chassis</robot_base_frame>
</plugin>

@chapulina chapulina self-requested a review July 8, 2019 14:04
@chapulina chapulina added the ros2 label Jul 8, 2019
Copy link
Copy Markdown
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a first pass, and the Prius is drivable 👍

Besides my other comments, I also noticed that there's a problem with the front wheels TF:

wheel_tf

Comment thread gazebo_plugins/src/gazebo_ros_ackermann_drive.cpp Outdated
Comment thread gazebo_plugins/worlds/gazebo_ros_ackermann_drive_demo.world Outdated
Comment thread gazebo_plugins/worlds/gazebo_ros_ackermann_drive_demo.world Outdated
Comment thread gazebo_plugins/include/gazebo_plugins/gazebo_ros_ackermann_drive.hpp Outdated
Comment thread gazebo_plugins/src/gazebo_ros_ackermann_drive.cpp Outdated
Comment thread gazebo_plugins/src/gazebo_ros_ackermann_drive.cpp Outdated
Comment thread gazebo_plugins/src/gazebo_ros_ackermann_drive.cpp
Comment thread gazebo_plugins/src/gazebo_ros_ackermann_drive.cpp
Comment thread gazebo_plugins/worlds/gazebo_ros_ackermann_drive_demo.world
@shiveshkhaitan
Copy link
Copy Markdown
Author

Besides my other comments, I also noticed that there's a problem with the front wheels TF:

Isn't it weird? The car seems to be fine in gazebo. Any idea what could be the problem?

Use gazebo database model
@chapulina
Copy link
Copy Markdown
Contributor

@shiveshkhaitan , mind fixing conflicts?

@chapulina
Copy link
Copy Markdown
Contributor

chapulina commented Jul 16, 2019

The car seems to be fine in gazebo. Any idea what could be the problem?

With the latest commits, the front wheels look and steering wheel look good to me, but the rear wheels are not showing.

This is printing some wrong info:

"Publishing wheel transforms between [%s], [%s] and [%s]",
impl_->robot_base_frame_.c_str(), joint->GetName().c_str(), joint->GetName().c_str());

More specifically:

[INFO] [demo.ackermann_drive]: Publishing wheel transforms between [chassis], [rear_right_wheel_joint] and [rear_right_wheel_joint]
[INFO] [demo.ackermann_drive]: Publishing wheel transforms between [chassis], [rear_left_wheel_joint] and [rear_left_wheel_joint]

Inspecting the TF tree on RViz, we can see that the rear wheels are disconnected from the rest of the tree. The parent of the rear wheels is the rear_axle, which is the child of chassis. We either need:

  • To publish transforms from rear_axle to chassis
  • To calculate transform from rear_* wheels to chassis and publish that.

I think the 2nd option is better to be generalized for other kinematic structures which don't have an intermediate link like rear_axle.

@shiveshkhaitan
Copy link
Copy Markdown
Author

To calculate transform from rear_* wheels to `chassis and publish that.

Should this be published only for the demo? Because if we integrate into the code, then it won't generalise again

@chapulina
Copy link
Copy Markdown
Contributor

The user chooses the base link (robot_base_frame) and the joints. So if we want to be general, we can provide the transform from that link to each joint. In some cases, that link will be the immediate parent of the joints. But in other cases, like this demo, there will be links in between.

So what we can do is get the parent until we find one which matches the base link name. Here:

auto pose_wheel = joint->GetChild()->RelativePose();

Instead of getting just the relative pose from the joint to its child link, we need to accumulate the relative poses of all joints and links until we find the base link. I think you'll need to use Joint::GetParent and Link::GetParentJointsLinks.

Or we can just, for now, not publish the wheel transforms in case the joint parent's name is different from robot_base_frame.

@chapulina
Copy link
Copy Markdown
Contributor

@osrf-jenkins run tests please

Copy link
Copy Markdown
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, LGTM!

@chapulina chapulina merged commit 150554d into ros-simulation:dashing Jul 30, 2019
@chapulina
Copy link
Copy Markdown
Contributor

I just realized that I merged this without checking CI and the test is failing sometimes. Can you take a look, @shiveshkhaitan ?

shiveshkhaitan added a commit to shiveshkhaitan/gazebo_ros_pkgs that referenced this pull request Aug 15, 2019
* [ros2] Add ackermann drive plugin

* Minor fixes

Use gazebo database model

* Update example usage

* Fix TF for demo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants