Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Low-Level Controllers Topic #810

Merged
merged 28 commits into from
Mar 11, 2024
Merged

Improve Low-Level Controllers Topic #810

merged 28 commits into from
Mar 11, 2024

Conversation

01binary
Copy link
Contributor

@01binary 01binary commented Feb 12, 2024

Description

There is a lot of confusion around different controller managers supported by MoveIt and their configuration settings, integrating controllers with MoveIt by linking them with existing controller handle allocator plugins, and writing controller handles and allocators. Issues reported on GitHub, posts on Robotics Stack Exchange, ROS Answers, Google Groups attest that this part of documentation is both critical to integrating new robots with MoveIt and lacks sufficient depth and clarity.

This pull request addresses issues created in MoveIt 1 repository:

Questions for reviewers:

  • Should we try to setup Panda with ROS Controllers? I've been having to use basic_velocity_moveit_config for all of the YAML configuration examples because Panda's ros_controllers.yaml is blank for unknown reason, and there is no gazebo_demo.launch file in its moveit config package. Both features are needed for examples in this article.
  • Where should links to ROS docs go?
    • Currently going to:
      https://docs.ros.org/en/noetic/*
    • This is already used in planning_with_approximated_constraint_manifolds_tutorial.rst so I assume it's fine.
  • Where should links to ROS Controls GitHub go?
  • MoveIt source links currently going to:
    https://github.com/ros-planning/moveit/blob/master/*
    • This seems fine because it's both the master branch and the default.

Checklist

Copy link

welcome bot commented Feb 12, 2024

Thanks for helping in improving MoveIt and open source robotics!

@01binary 01binary force-pushed the master branch 2 times, most recently from dc1f2f5 to 4f9fbe9 Compare February 13, 2024 03:31
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this thorough rework of the controller tutorial. There are many nice contributions. However, for some parts I liked the previous text more. Thus in my additional commit, I tried to merge the old and new stuff getting the best from both worlds.
I didn't yet worked through the new code sections. (Sorry, time is limited).

@01binary
Copy link
Contributor Author

01binary commented Feb 19, 2024

I don't know whether the ros_control tutorials explain that idea. Probably they do.

I checked ROS Control 1 documentation - it's just one page and links to presentation & paper. The presentation mentions "resources" but does not say that resources are joints. No specific mention of controllers claiming joints. Also checked ROS Control 2 documentation - it's smoother but still has large gaps.

I recommend leaving this in, otherwise I will have to copy-and-paste it into 100 different answers on Robotics Stack Exchange - it's a lot easier to link to relevant documentation.

Other than that, things looking good. Last remaining issue is we need to use an example project that has ROS Control configuration, and Panda does not. I see you replaced all the examples with Panda config.

The MSA-generated project must have the following to be a valid example here:

  • Have ROS Controllers configuration
  • Have Gazebo launch configuration
  • Have RViz & Gazebo launch configuration

Panda only has RViz configuration to launch with fake controllers.

Would you like me to setup panda_moveit_config with ROS controls in a separate PR, get that merged, and then come back here?

@rhaschke
Copy link
Contributor

Would you like me to setup panda_moveit_config with ROS controls in a separate PR, get that merged, and then come back here?

No, please don't do that. If you want to augment a robot config with such a config, consider using the Panda robot or Fanuc robot in moveit_resources.

Before merging this, I need to work through the code example sections. I didn't find time for this yet.

@01binary
Copy link
Contributor Author

Sorry, I didn't realize I was not being clear. By "setup panda with moveit config" I meant augmenting panda_moveit_config by re-running the wizard to make sure all the files normally generated by MSA exist, are filled out, and work.

@rhaschke
Copy link
Contributor

I think I understood you correctly. And I suggest not to update the standard panda_moveit_config which is very special and deviates in many regards from the MSA-generated files. However, the panda_moveit_config in moveit_resources is much closer to the MSA defaults. Hence, you should use that version.

@01binary
Copy link
Contributor Author

01binary commented Feb 21, 2024

My first few attempts to re-gen panda_moveit_config in moveit_resources (using panda_description) failed.

EDIT 1

Apparently MSA does not add filename attribute to <plugin name="gazebo_ros_control> element in URDF generated for simulation. I haven't seen this error before because my robot URDF already had the <gazebo><plugin> section in it, so MSA didn't have to add one. After I added the attribute Gazebo finally spawned the model, but then crashed after unpausing physics.

Continuing to troubleshoot. If this takes too long I'm fine with giving up on this aspect, and getting it patched up later in another PR. No reason to over-extend and keep PRs open for a long time when there's always another PR.

EDIT 2

If you are looking to test the code, see third_draft branch in trajectory_controller_example repo. If you clone that into a ROS1 workspace and install packages with rosdep I feel like it should build on the first attempt with no issues.

@rhaschke
Copy link
Contributor

Regarding the issues you observed with Gazebo:

  1. I added the missing filename attribute in MSA via MSA: Add missing filename attribute to gazebo plugin tag moveit#3572
  2. The crash of Gazebo when unpausing physics is caused by a bug in joint_state_controller, fixed via Fix uncaught exception in joint_state_controller ros-controls/ros_controllers#630

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see so much value in the two code sections. The mainly explain pluginlib usage, which is documented elsewhere.

@01binary
Copy link
Contributor Author

I think we found a happy middle here: the topic starts with a survey of controller managers and their settings (split by type), then goes into integrating controllers (again split by type)

Comment on lines -98 to -107
Remapping /joint_states topic
-----------------------------
<param name="moveit_controller_manager" value="moveit_ros_control_interface::MoveItMultiControllerManager" />

When you run a `move group node <../move_group_interface/move_group_interface_tutorial.html>`_, you may need to remap the topic /joint_states to /robot/joint_states, otherwise MoveIt won't have feedback from the joints. To do this remapping you could make a simple launch file for your node as follows: ::
.. note::
The `Simple Controller Manager` is generic as it can interface controllers from multiple ROS controller managers by specifying different prefix names in the bridging configuration file.

<node pkg="moveit_ros_move_group" type="move_group" name="any_name" output="screen">
<remap from="joint_states" to="robot/joint_states"/>
</node>
Controller Switching and Namespaces
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Or you can make a subscriber with the correct topic name and then ensure that the starting robot state for your move group corresponds to a correct joints angle by using the call back of this subscriber.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explicitly moved that section to the end as it is not strongly related to the current sections.

@rhaschke rhaschke merged commit 3bf8de6 into moveit:master Mar 11, 2024
5 checks passed
Copy link

welcome bot commented Mar 11, 2024

Congrats on getting your first MoveIt pull request merged and improving open source robotics!

@01binary
Copy link
Contributor Author

Thanks for the merge! Sorry the PR had to bounce as both of us were busy at different times.

Copy link
Contributor

@simonschmeisser simonschmeisser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being late to the party but I still find this very confusing and would love to see more clarity

<!-- load controller_list -->
<rosparam file="$(find robot_moveit_config)/config/controllers.yaml"/>
</launch>
Alternatively to the simple controller manager described above, MoveIt also provides a controller manager that directly interfaces the `ROS Controller Manager <http://wiki.ros.org/controller_manager>`_. Instead of using a bridging configuration file like ``simple_moveit_controllers.yaml``, this controller manager directly queries the ROS Controller Manager for available controllers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently trying to use ros_control for the first time and it is not clear to me when I would use which controller manager. It says "Alternatively" here but not why I would choose this alternative.

Also the actual name of the plugin is not spelled out.

Debugging Information
---------------------
The ``FollowJointTrajectory`` or ``GripperCommand`` interfaces on your robot must be communicating in the namespace: ``/name/action_ns``. In the above example, you should be able to see the following topics (using *rostopic list*) on your robot:
The *MoveIt ROS Control Controller Manager* can only interface controllers from the single ROS controller manager found in the ROS namespace defined by the ROS parameter ``~ros_control_namespace`` (defaults to ``/``).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not clear to me where to put this parameter and it belongs to the previous section?

Copy link
Contributor Author

@01binary 01binary Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this part assumes you are very comfortable with ROS configuration.

The "~" means root or top level (you could say "global") ROS configuration namespace. There is a number of ways to set global parameters, such as specifying them as command line arguments, putting them in launch files, loading them from YAML, or setting them via command line CLI commands.

This parameter is being read by controller_manager_plugin.cpp:

/**
 * \brief The default constructor. Reads the namespace from ~ros_control_namespace param and defaults to /
 */
MoveItControllerManager()
  : ns_(ros::NodeHandle("~").param("ros_control_namespace", std::string("/")))
  , loader_("moveit_ros_control_interface", "moveit_ros_control_interface::ControllerHandleAllocator")
{
  ROS_INFO_STREAM("Started moveit_ros_control_interface::MoveItControllerManager for namespace " << ns_);
}

The easiest way to set it would probably be in ros_controllers.launch launch file by using param tag, but you could also pick any other launch file where you think it makes the most sense.

<param name="ros_control_namespace" value="/myrobotcontrol" />

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* ``name``: The name of the controller. (See debugging information below for important notes).
* ``action_ns``: The action namespace for the controller. (See debugging information below for important notes).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the "debugging info" is now above?

Also it would be super helpful to add more debugging tips. Currently my robot is not moving and I have no idea why. Is there a way to make ros_control acknowledge that it received a trajectory? Print the content? This kind of thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was moved too many times. We can get this fixed.

@01binary
Copy link
Contributor Author

01binary commented Mar 19, 2024

@simonschmeisser we can setup Zoom if you like, to make it a bit more interactive.

First question I have, is the current documentation after this pull request better than the previous version?

it is not clear to me when I would use which controller manager

The "Low-Level Controllers" topic follows the following macro-structure:

  1. Enumerate controller manager types
  2. Explain the use case for each controller manager and its configuration
  3. Explain how controllers interact with controller managers

Here's a high-level summary, let me know if this makes sense.

  • There are several controller manager types: Fake, Simple, ROS Control, Multi, Custom (roll your own)
  • Some controllers are used only in special scenarios:
    • Fake controller manager is used for basic visualization of inverse kinematics, so that you can test basic configuration without loading all of the complex machinery needed to actually move the robot arm. You might want this for testing inverse kinematics and basic robot description for correctness.
    • Multi controller manager is used if you have multiple ROS Controller Manager nodes. This can happen in advanced scenarios if you have a robot with many controllers, or mixing and matching controllers that were designed to work on another robot.
  • Remaining controllers are arranged from simple to complex by usage scenario:
    • Simple: minimum configuration needed to load and move a robot. Supports two most common controller types people might want. You might do this if you are starting out and want to test basic functionality with less moving parts in play. When you have a stack with lots of moving parts so to speak, it's harder to troubleshoot.
    • ROS Control: the most common configuration for robots using controllers from ROS Controller package. Intermediate level of complexity for someone very familiar with ROS Control and ROS Controllers. This also lets you load your own custom controller, or use custom controllers written by someone else (Intermediate to Advanced level of difficulty).
    • Custom: you can write your own controller manager to have complete control over what's happening. This degree of control may be useful for someone who has an old robot with a custom stack that they decide to integrate with MoveIt, or an enterprise/large company scenario where you have many specific requirements for your business, and you need something that checks all the boxes, and have the time to do all the customization.

Currently my robot is not moving and I have no idea why. Is there a way to make ros_control acknowledge that it received a trajectory? Print the content? This kind of thing

  • You can echo the topic on which the ROS controller would receive its trajectory command to verify MoveIt is telling the controller to move joints
    • If you list topics with rostopic list you should get a topic called /your_controller_name/follow_joint_trajectory/goal, this receives goals from MoveIt
    • You can then use rostopic echo <topicname> to watch it
  • Console errors
    • You could look for Completed trajectory execution with status (followed by status) or Controller 'name' successfully finished
  • Debug messages
    • Console messages logged with "debug" severity are not normally displayed, you could enable those. See any logging statements that start with ROS_ in joint_trajectory_controller_impl.h (ROS Controllers GitHub repo) to get an idea of what messages to look for
  • Debug the ROS controller
    • You can attach to Gazebo Server using ROS Attach command in Visual Studio Code. It's the executable called "gzserver". Set a breakpoint in joint_trajectory_controller_impl.h, the goalCB method. This is the method that gets called when the /follow_joint_trajectory/goal topic I mentioned earlier gets a goal from MoveIt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants