odrive_ros2_control icon indicating copy to clipboard operation
odrive_ros2_control copied to clipboard

Publish to topic cmd_val

Open MoonWalkerAZ opened this issue 4 years ago • 9 comments

Is there a good example how to control two motors for differential drive robot ? I would like to publish Twist message to cmd_val topic to control velocity of two motors.

MoonWalkerAZ avatar Dec 08 '21 13:12 MoonWalkerAZ

Hi, there's a good example provied by @kallaspriit. Please refer to issue #1.

borongyuan avatar Dec 08 '21 14:12 borongyuan

Yeah my robot uses this library for physical and simulated differential drive robot, works nicely :)

https://github.com/kallaspriit/rosbot https://www.youtube.com/watch?v=t-1GAfGHRLs

kallaspriit avatar Dec 08 '21 16:12 kallaspriit

@kallaspriit I have checked your library, but I don't understand which part do I need to create a node that creates cmd_vel topic and sends the correct data to odrive. I'm new at this. Can you help me ? I have seen that you use joystick to send a Twist message, but I dont know where is that twist message being read and then converted to values that odrive driver understands.

MoonWalkerAZ avatar Dec 08 '21 16:12 MoonWalkerAZ

For manual testing /cmd_vel is published by teleop_twist_joy package (which uses joy package to get joystick input).

See this for reference https://github.com/kallaspriit/rosbot/blob/main/ros/src/teleop_twist_joy/launch/teleop.launch.py

To run in, you can run . launch_teleop.bash in ros or

. install/local_setup.bash
ros2 launch teleop_twist_joy teleop.launch.py

Which does the same thing.

kallaspriit avatar Dec 09 '21 16:12 kallaspriit

Ok, but who is subscribing to /cmd_vel topic ? And how is the Twist message being converted to input so that odrive can understand it ? Thats the part that I don't understand.

MoonWalkerAZ avatar Dec 10 '21 14:12 MoonWalkerAZ

Before using this package, you need to be familiar with ros2_control framework. http://control.ros.org/ros2_controllers/diff_drive_controller/doc/userdoc.html

borongyuan avatar Dec 11 '21 13:12 borongyuan

Ok. Some example of how to use an implement diff_drive_controller with odrive package would be nice. @kallaspriit could you help me with this ?

MoonWalkerAZ avatar Dec 11 '21 14:12 MoonWalkerAZ

Well the rosbot repo IS an example of how to implement diff drive controller with odrive, not sure what else you need. Familiarize yourself with ROS2, ros2_control, URDF's and read the repo. It's all configuration, no actual code is needed but it takes time to understand what does what, no way around it.

Main configuration is in robot URDF (Universal Robot Descriptor File), take a look at https://github.com/kallaspriit/rosbot/blob/main/ros/src/rosbot_description/urdf/rosbot.urdf.xacro https://github.com/kallaspriit/rosbot/blob/main/ros/src/rosbot_description/ros2_control/rosbot_system.ros2_control.xacro https://github.com/kallaspriit/rosbot/blob/main/ros/src/rosbot_description/urdf/rosbot_links.urdf.xacro https://github.com/kallaspriit/rosbot/blob/main/ros/src/rosbot_description/config/diff_drive_controller.yaml

kallaspriit avatar Dec 13 '21 08:12 kallaspriit

Ok, thank you @kallaspriit and @borongyuan four your help.

MoonWalkerAZ avatar Dec 13 '21 13:12 MoonWalkerAZ