ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How does FlexBe conccurrent container work (in terms of state lifecycle)?

asked 2021-11-30 18:29:43 -0500

Jibran gravatar image

updated 2021-12-03 14:33:16 -0500

I haven't been able to find the answer to what I am facing in the tutorials. Let me explain briefly what I am trying to do. I have 2 states : StartSewing and ExecTraj in a concurrent container

image description

In StartSewing, I have the following piece of 'blocking code' in the execute() function :

def execute(self, userdata):
    self.success = sewing_machine_control_client(userdata.low_speed, userdata.high_speed, userdata.presser_foot, userdata.trim_thread)
    return 'continue'

This (sewing_machine_control_client) is a wrapper function around a call to a rosservice.

In ExecTraj, I have the following piece of code :

def execute(self, userdata):
    self.robot.load_cartesian_trajectory(os.environ['HOME'] + "/training_ws/src/robot_arm_control-master/config/saved_trajectories/" + userdata.traj_filename, wait_for_exec=True)
    return 'continue'

And again, this is a wrapper function and is also a blocking code, it eventually leads to this recognizable piece of code to Moveit users :

self.move_group.execute(loaded_plan, wait=wait_for_exec)

My colleague who has worked with SMACH tells me that concurrent containers are supposed to run all states inside them simultaneously. But that doesn't seem to happen here. From my observation so far, one of the states' execute() is called first and then the other state's execute() is called.

Anyone else facing the same issue? Instead of multithreading, is it more of context-switching that is taking place here?

edit retag flag offensive close merge delete

Comments

Thank you for the question. Added more points so you can share pictures.

osilva gravatar image osilva  ( 2021-12-01 17:13:43 -0500 )edit

Please don’t consider this an answer just a comment. Flexbe offers concurrency http://wiki.ros.org/flexbe/Tutorials/...

You may also look into SMACC written in C++

osilva gravatar image osilva  ( 2021-12-01 17:25:59 -0500 )edit

I have gone over that tutorial. It doesnt seem to have the answer.

Jibran gravatar image Jibran  ( 2021-12-03 14:32:28 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2023-06-15 21:15:09 -0500

dcconner gravatar image

Concurrent means both states are active at the same time, but they do not execute in parallel.

For each "tic" of the state machine, all active states in concurrent will be tic'd and execute.

For FlexBE, the state implementation methods should be "fast" and not blocking. The best model is to use action interfaces to complex/long running calculations and then let FlexBE states interact via those.

If the execute method blocks, then it prevents FlexBE's preemption checks from running.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-11-30 17:52:40 -0500

Seen: 50 times

Last updated: Jun 15 '23