ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
1

Is there a recommended way to control sequential logic and tasks (ROS2)

asked 2022-05-09 23:14:29 -0500

nickd gravatar image

Hello,

Is there a recommended way to control logic in ROS when I want to do something in sequential order? I am using ROS2 on Ubuntu 20.04. Previously (without using ROS), I have written discrete controllers where I keep track of the state of my program and execute the appropriate commands in loops.

As an example, let's say I have a robot arm with a gripper and a camera. I want to do the following tasks in this order and only move on to the next task when the previous has finished 1) Close the gripper 2) Move the robot arm to a position (IK) 3) Run object detection routine with the camera.

I am pretty sure I can "hack" together a way to perform this routine with topics that act as flags that tell me when a task has finished but is there a better (more scalable) way that you recommend?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2022-05-10 02:23:08 -0500

gvdhoorn gravatar image

updated 2022-05-10 02:31:49 -0500

This isn't really ROS 2 (or ROS 1) specific I believe.

In general any behaviour modelling formalism could be used for what you describe.

Two popular choices in the ROS community have been (and still are) state machines and behaviour trees.

I don't have links available to ROS 2 specific versions, but BehaviorTree.CPP has a ROS 2 integration and SMACC2 also has one (here).

More formal planning approaches can be used as well: IntelligentRoboticsLabs/ros2_planning_system supports PDDL-based planning.

In ROS 1, you could've used SMACH or a more recent iteration like flexbe.

Note that none of these are really ROS-specific, in the sense that they typically all use a generic implementation of some behaviour modelling approach and then add conveniences for using it "with ROS" (such as the "flags" you mention in your OP).

edit flag offensive delete link more

Comments

For ROS2, Nav2 uses behavior trees. However, it might not be the best example if you'd like to implement behavior trees yourself, due to the complexity of Nav2.

Joe28965 gravatar image Joe28965  ( 2022-05-10 02:42:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-05-09 23:14:29 -0500

Seen: 33 times

Last updated: May 10