ros_odrive icon indicating copy to clipboard operation
ros_odrive copied to clipboard

Basic usage

Open anthonywebb opened this issue 1 year ago • 10 comments

I am hunting for a barebones example of using this package to actually control the motor. I am not finding anything here in the README or either on the odrive page here https://odrive-cdn.nyc3.digitaloceanspaces.com/releases/docs/tuz5Eoq9jgCRICZVXLGZca10l1WFnisS_t3Vbhu9smQ/guides/ros-package.html

The package built, and I can see some packages. Just need to close the loop on how to actually use it. Can someone point me in the right direction?

anthonywebb avatar Dec 31 '23 05:12 anthonywebb

I am having the same issue. It seems like there needs to be a hardware interface plugin in order for ROS2 control to be able to use the ODrive. Can you keep me posted if you make any progress?

00Doc-T avatar Jan 02 '24 05:01 00Doc-T

@00Doc-T will do, and if you bump into anything let’s post it here so everyone can benefit.

anthonywebb avatar Jan 02 '24 05:01 anthonywebb

@anthonywebb The link you posted is a special, strongly versioned link (and outdated), I'm actually interested where you found that? The up-to-date link is here: https://docs.odriverobotics.com/v/latest/guides/ros-package.html

To get started, I recommend to try and interact with the ODrive ROS2 node via the terminal. Some example commands can be found in the docs linked above but I see it has some gaps.

After running the launch command, here's how you would switch a (preconfigured and just booted) ODrive to closed loop control state and send a velocity setpoint:

source ./install/setup.bash
ros2 service call /odrive_axis0/request_axis_state /odrive_can/srv/AxisState "{axis_requested_state: 8}"`
ros2 topic pub /odrive_axis0/control_message odrive_can/msg/ControlMessage "{control_mode: 2, input_mode: 1, input_pos: 0.0, input_vel: 1.0, input_torque: 0.0}"

The enum values can be found here: axis_requested_state, control_mode, input_mode.

Note that the ODrive must previously be configured such that it's ready for control (make sure you can control it from the GUI first).

Once these commands work, they should give you an idea how to do the same from Python or C++.

@00Doc-T It sounds like you're referring to ros2_control - unfortunately the current version of the ODrive ROS2 package is not out-of-the-box compatible with ros2_control. You would have to make a glue layer (a separate node) or change the interface exposed by this node. If someone wants to make the necessary changes we're happy to take contributions.

samuelsadok avatar Jan 05 '24 16:01 samuelsadok

@samuelsadok I’m trying to get the bot explorer rolling so I assume that link is in the notion docs for the bot explorer build somewhere? Hopefully someone with enough ROS experience can help get ros_control wired up so we have an end to end of ROS driving these odrives. I’ll keep hacking.

anthonywebb avatar Jan 05 '24 16:01 anthonywebb

Factor Robotics has a package that works with V3. Though it seems the package is incompatible with S1 firmware. Could use that, if we could figure out how to make the file changes.

00Doc-T avatar Jan 08 '24 04:01 00Doc-T

image

Here are some notes I've taken recently. It covers some ROS2 concepts and some notes on how to use the this ODrive package. Hopefully that will help some.

JesseDarr avatar Jan 17 '24 01:01 JesseDarr

Thought I'd follow up this discussion, to see if any of you made any advances?

00Doc-T avatar Feb 23 '24 18:02 00Doc-T

@00Doc-T there is a branch for ros_control that we have been testing. Still early but it does appear to be working with ROS2 https://github.com/odriverobotics/odrive_can/tree/ros-control

anthonywebb avatar Feb 23 '24 18:02 anthonywebb

I got it working today. Fantastic. I've been trying to write my own hardware package for 2 months. Learned a little coding, which never hurts. This will work much better.

00Doc-T avatar Feb 24 '24 05:02 00Doc-T

Thank you Anthony! I've also got this running successfully 😊

JesseDarr avatar Feb 25 '24 14:02 JesseDarr