Git Product home page Git Product logo

moteus_ros2's Introduction

ROS2 Package for moteus

This contains a ROS2 node for communication with mjbots moteus controllers.

License: Apache 2.0

Getting started

Installation

  1. Clone this repository into the src folder of your ROS2 workspace.
cd src
git clone https://github.com/mjbots/moteus_ros2
  1. Navigate to the top level of the ROS2 workspace folder and run:
colcon build
  1. Source the workspace:
source ./install/setup.bash
  1. Run the example launch file:
ros2 launch moteus_control example_launch.yaml

Monitoring and control.

The following commands assume you are using the parameters from the default launch file. You can change the namespace or the IDs configured according to your application. The following are examples of commands that can be sent.

  1. Show the current status of servo ID 1.
ros2 topic echo /moteus/id_1/state
  1. Request the motor stop, in order to clear any faults.
ros2 topic pub /moteus/id_1/cmd_stop std_msgs/msg/Empty "{}"
  1. Send a position mode command.

The following requests a move to position 0.5, repeating the command at 50Hz. Each field which should be sent, should be a single element list with the desired value present.

ros2 topic pub -r 50 /moteus/id_1/cmd_position moteus_msgs/msg/PositionCommand "{position: [0.5], accel_limit: [5]}"

Note that the ROS2 node only sends commands to moteus when it receives them from ROS. Thus you need to either:

a. Send ROS commands faster than the configured watchdog timeout period (0.1s by default)

b. Change servo.default_timeout_s to nan if you want it disabled

c. Temporarily override the watchdog timeout on a per-command basis like the following:

ros2 topic pub /moteus/id_1/cmd_position moteus_msgs/msg/PositionCommand "{position: [0.5], accel_limit: [5], watchog_timeout:[.NAN]}"
  1. Send a command that requires no arguments. The possible options are:
/moteus/id_1/cmd_stop
/moteus/id_1/cmd_brake
/moteus/id_1/cmd_recapture_position_velocity

These can all be sent with the following:

ros2 topic pub -1 /moteus/id_1/cmd_brake std_msgs/msg/Empty "{}"
  1. Send a command that requires a single floating point argument. The possible options are:
/moteus/id_1/cmd_set_output_exact
/moteus/id_1/cmd_set_output_nearest

These can be sent with something of the form:

ros2 topic pub -1 /moteus/id_1/cmd_set_output_exact std_msgs/msg/Float32 "{data: 0.5}"

Operation with the pi3hat

For usage with the pi3hat, the easiest method is to run the entirety of the ROS2 session as root. That can be accomplished by running sudo bash before sourcing the ROS2 setup profiles. An example is below:

sudo bash
source /opt/ros/iron/setup.sh
source ./install/local.bash

Caveats

Currently the resolution of the command and query results cannot be changed.

The maximum achievable performance of a system in terms of update rate using this node will be much lower than a dedicated process. The dedicated process is able to combine commands and queries for all servos into a single cycle, and control the resolution of all commands and responses. If you need a fast update rate (>100Hz), consider not using ROS2 and instead directly using either the moteus python or C++ library.

Reference

The semantics of all commands are identical to that found in the primary moteus reference documentation: https://github.com/mjbots/moteus/blob/main/docs/reference.md

moteus_ros2's People

Contributors

jpieper avatar

Stargazers

Stéphane Caron avatar

Watchers

 avatar Stéphane Caron avatar  avatar

Forkers

zhangzq71

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.