-
Notifications
You must be signed in to change notification settings - Fork 83
Documentation
This guide will provide you a minimal set of instructions to operate ODrive using ros2_control.
It is recommended to install odrivetool with root privileges, so the udev rules will be automatically added, and you will not encounter USB permissions issues.
For firmware version 0.5.3:
sudo pip3 install odrive==0.5.3.post0
For firmware version 0.5.1:
sudo pip3 install odrive==0.5.1.post0
Set up your hardware following ODrive Documentation. Please make sure that your motor and encoder are properly configured and calibrated. Set the ODrive startup sequence according to your application requirements. We assume that ODrive has finished the preset startup procedure before you start the ROS driver. We do not recommend enabling the watchdog in advance, as this may hinder the startup procedure. If you want to use watchdog, just set it in URDF. ODrive axis can be set to closed-loop control state in advance or not, anyway the ROS driver can also complete state switching. We also recommend configuring and enabling the anti-cogging function, which will significantly improve the low-speed control performance.
Install dependencies:
sudo apt-get install libusb-1.0-0-dev ros-foxy-ros2-control ros-foxy-ros2-controllers ros-foxy-xacro
Clone and build odrive_ros2_control, choose the branch that matches your firmware version:
git clone -b <branch> https://github.com/Factor-Robotics/odrive_ros2_control.git
cd ..
colcon build
The demo launch file will load and start velocity controller on axis0:
ros2 launch odrive_bringup odrive.launch.py
Send velocity command in another terminal, the motor should start to rotate at a speed of 1 rad/s:
ros2 topic pub -r 100 /joint0_velocity_controller/commands std_msgs/Float64MultiArray "data: [1]"
You can monitor the status of axis0, including position, speed, torque, temperature, error code:
ros2 topic echo /dynamic_joint_states
You can also visualize tf in rviz2:
This package mainly provides hardware components implementation of ODrive. So you can use it with ros2_controllers to build various types of robots. For example, you can use a single ODrive to build a differential wheeled robot, with the help of diff_drive_controller. Or use three ODrives to build a six-axis robot arm, with the help of forward_command_controller. The corresponding hardware setup need to be added to URDF, as shown in examples. If you use multiple ODrives, you must set the serial_number of the hardware to which each joint belongs. If you only use a single ODrive, the serial_number can be set to 0, then the driver will use the only ODrive found.