Getting_Started - Factor-Robotics/odrive_ros2_control GitHub Wiki
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 ROS version and ODrive firmware:
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_demo_bringup odrive_multi_interface.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:
The demo configuration also includes various forward command controllers. You can modify the config file, or switch controllers at runtime. When you switch controllers, the drive automatically switches the control mode of the ODrive according to the desired control level.
This package mainly provides hardware components implementation of ODrive. So you can use it with ros2_controllers to build various types of robots. 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. The corresponding hardware configuration needs to be added to URDF.
If you are not familiar with the ros2_control framework or do not know how to write a configuration, you can refer to the examples and templates provided by ros2_control_demos. Among them, DiffBot and RRBot are virtual robots with 2 degrees of freedom, and the ODrive hardware can also provide control of 2 joints. Therefore, we can easily modify these two examples into a hardware-in-the-loop form. Control commands will be executed on real motors, and feedback states will also come from real motors and encoders.Our demos use the original configuration in ros2_control_demos as much as possible. You can compare the configurations in both repositories to see which modifications are required.