Factor-Robotics / odrive_ros2_control

ODrive driver for ros2_control
Apache License 2.0
250 stars 82 forks source link

Improve documentation #1

Closed kallaspriit closed 2 years ago

kallaspriit commented 2 years ago

Hey, seems to be a nice library, trying to use it to control a differential drive robot but not entirely sure how to use it.

Managed to compile it and launch it with

os2 launch odrive_bringup odrive.launch.py enable_joint1:=true

Also managed to subscribe to the joint states topic.

ros2 topic echo /dynamic_joint_states

How would I go about controlling the motor velocities etc? Some documentation about using the library and some examples would help the package :)

borongyuan commented 2 years ago

Hi,

sorry for the missing document. We will add more examples and instructions after various tests.

The current launch file use velocity controllers by default. Of course you need enable_joint1 if you want to use both joints. The three basic controllers (position, velocity, effort) are inherited from forward_command_controller. They accept std_msgs/Float64MultiArray as input. You can try following command to set velocity of joint0.

ros2 topic pub -r 100 /joint0_velocity_controller/commands std_msgs/Float64MultiArray "layout:
  dim:
  - label: ''
    size: 1
    stride: 1
  data_offset: 0
data: [1]"

For differential drive robot, a better solution is to use diff_drive_controller. This controller handles two joints using velocity interface. It subscribes cmd_vel and publishes odometry. Please refer to DiffBot in ros2_control_demos for configurations.

kallaspriit commented 2 years ago

Hey, thanks for the info.

I can enable both joints by launching with ros2 launch odrive_bringup odrive.launch.py enable_joint1:=true.

I can also now control the individual wheel speeds with

Etc. I have not used ros2_control before and I haven't quite figured out how to use the diff_drive_controller to drive the odrive through this library. Any example would be much appreciated as this is probably a pretty common use-case for the odrive board.

kallaspriit commented 2 years ago

Managed to implement a joystick-controlled differential drive robot using diff drive controller and this package.

Not a tutorial as such but maybe the codebase helps someone (work in progress). https://github.com/kallaspriit/rosbot/tree/main/ros

Documentation for future users would still be welcome, not trivial to figure it all out by oneself :)

borongyuan commented 2 years ago

documentation added