odriverobotics / ros_odrive

MIT License
58 stars 34 forks source link

Basic usage #5

Closed anthonywebb closed 5 days ago

anthonywebb commented 10 months ago

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?

00Doc-T commented 10 months ago

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?

anthonywebb commented 10 months ago

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

samuelsadok commented 10 months ago

@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.

anthonywebb commented 10 months ago

@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.

00Doc-T commented 10 months ago

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.

JesseDarr commented 10 months ago

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.

00Doc-T commented 8 months ago

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

anthonywebb commented 8 months ago

@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

00Doc-T commented 8 months ago

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.

JesseDarr commented 8 months ago

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

samuelsadok commented 5 days ago

Closing this given that we have a ros2_control interface in the main branch now: (https://github.com/odriverobotics/ros_odrive/tree/main/odrive_ros2_control) and documentation has improved since the original issue.