Close
0%
0%

C++ Odrive ROS driver

Create a flexible C++ Odrive node for Robotic Operating System (ROS)

Similar projects worth following
Create a flexible C++ Odrive node for Robotic Operating System (ROS).

The aim of the project is to provide a flexible and portable interface for odrive brushless motor control hardware. Driver is written in C++ for performance and portability reason and communication with the hardware is performed using a USB port and odrive native format. The software is ported to ROS Operating System and the node is publishing status information about the motor controller and also listening for control command. For our test we are using the nvidia Xavier arm64 host.

Example Json configuration file:

[
    {
        "name":"config.brake_resistance",
        "type":"float",
        "value":0.0
    },
    {
        "name":"axis0.motor.config.pole_pairs",
        "type":"int32",
        "value":5
    },
    {
        "name":"axis0.motor.config.resistance_calib_max_voltage",
        "type":"float",
        "value":4.0
    }
] 

The driver based on for setting-up an axis channels for a specific application or BLDC motor. Then values can be read or set using a similar to odrivetool notation.

Driver implements a publisher providing status information for both odrive channels at fixed intervals. The information which is published includes the following fields:

float32 vbus      # Bus voltage

int32 error0      # Axis 0 error
uint8 state0      # Axis 0 state
float32 vel0      # Axis 0 velocity 
float32 pos0      # Axis 0 encoder position
float32 curr0B    # Axis 0 motor channel B current
float32 curr0C    # Axis 0 motor channel C current
float32 temp0     # Axis 0 invertr temperature

int32 error1      # Axis 1 error
uint8 state1      # Axis 1 state
float32 vel1      # Axis 1 velocity 
float32 pos1      # Axis 1 encoder position
float32 curr1B    # Axis 1 motor channel B current
float32 curr1C    # Axis 1 motor channel C current
float32 temp1     # Axis 1 inverter temperature

A listener supports basic commands, such as enabling or disabling the closed loop, setting the velocity set-point etc. Following the list of basic command set that can be easily extended according to application needs:   

// Listener commands
enum commands {
    CMD_AXIS_RESET,
    CMD_AXIS_IDLE,
    CMD_AXIS_CLOSED_LOOP,
    CMD_AXIS_SET_VELOCITY,
    CMD_REBOOT
};

  • 1 × odrive brushless motor controller
  • 1 × nvidia Xavier embedded host
  • 1 × 750W/48V BLDC Motor

  • 1
    Running ROS node

    Following instructions for building the motor driver on ROS melodic:

    cd ~/catkin_ws/src/
    git clone https://github.com/johnkok/ros_odrive
    cd ~/catkin_ws
    catkin_make

     After compiling the driver we are ready to start the new node:

    cd ~/catkin_ws
    source ./devel/setup.bash
    roscore & # Start ROS core if it is not running
    rosrun ros_odrive ros_odrive _od_sn:="0x2054306D594D"

    Optionally we can also pass the configuration Json file if it is required:

    rosrun ros_odrive ros_odrive _od_sn:="0x2054306D594D" _od_cfg:="~/catkin_ws/src/ros_odrive/cfg/odrive_5pole.json"

View all instructions

Enjoy this project?

Share

Discussions

robotos2023 wrote 03/08/2023 at 03:59 point

I am having the same error with bears0. Meanwhile I am using 0.5.5. firmware

  Are you sure? yes | no

bears0 wrote 01/26/2022 at 21:13 point

I'm trying to use this driver with the newer 0.5.4 firmware. It's telling me that it's having trouble reading from the USB. I know it's at least connected as it gives a different error if the USB is unplugged or I change the USB protocol on the odrive. What steps would I take to add/ remove commands? Are they in a particular order or does it not matter? Also, where did you find the commands? I was unable to locate them on the ODrive website or github.

Thanks

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates