0
$\begingroup$

Rosanswers logo

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


Originally posted by nickd on ROS Answers with karma: 92 on 2022-05-09

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by gvdhoorn with karma: 86574 on 2022-05-10

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Joe28965 on 2022-05-10:
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.

Comment by dcconner on 2023-06-15:
FlexBE now has ROS 2 versions for source build on github.com/FlexBE.
Anticipate official Humble binary release in July 23

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.