executive_smach icon indicating copy to clipboard operation
executive_smach copied to clipboard

Porting SMACH to ROS2

Open lesire opened this issue 4 years ago • 8 comments

Hi guys, I am porting all my ROS applications to ROS2, and therefore, as I use SMACH to control some part of my autonomous robot mission, I need to port SMACH to ROS2. I looked at all the GitHub forks of SMACH but found no ROS2 version.

I will start a ROS2 branch on a fork, and try to port everything to ROS2 during the coming days.

First, have I missed something? Is there a ROS2 version under development? If not, if anybody wants to contribute in the porting, and/or testing of the ROS2 version, let me know!

Best,

lesire avatar Mar 24 '20 18:03 lesire

it's there, if someone wants to have a look

https://github.com/lesire/executive_smach/tree/ros2-eloquent

The most difficult part was to manage threads (i.e. ROS2 Executors), and the fact that all subscribers/publishers/clients must be declared within ROS2 Nodes. ROS2 States now need a pointer to the ROS2 Node executing the SM in their constructors.

Except the Action Wrapper (somebody uses it??), all the other features have been ported to ROS2. Nevertheless, I only made the tests work, and therefore I am not sure yet that the threading management is functional in a standard 'main' script (without the unittesting framework). And also, it may need some helper functions to initialize correctly ROS2 and the Node.

Other important point: smach_viewer is on an independent repo, and if I have barely tested the IntrospectionClient, all the porting of smach_viewer has to be done (to ROS2 and Python3).

lesire avatar Mar 27 '20 15:03 lesire

I would have needed to use the action wrapper quite excessive, as I was going to implement a behavior tree with it that mostly included larger sub-trees. As it was a hierarchical BT like concept, long open service-calls were prone to fail. I would have needed to alter my concept to actions. At least in ROS1 you get some strange behaviors when you have a service call too long open on the network.

But awesome to see someone has ported SMACH to ROS2! I wanted to tackle it during summer when I would have been up to speed with my other ROS2 related projects. Be sure to mention it here: https://discourse.ros.org/t/smach-for-ros-2/3175

gramss avatar May 24 '20 05:05 gramss

Thanks for the interest. Yeah, I did not mention it yet because I was hoping to have some more time for testing or starting to port also the viewer... maybe a bit too optimistic

lesire avatar May 27 '20 08:05 lesire

That's great you've been porting SMACH! What is the status? Can I use it on Foxy?

dmorris0 avatar Sep 15 '20 17:09 dmorris0

This issue has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/smach-for-ros-2/3175/4

ros-discourse avatar Oct 08 '20 16:10 ros-discourse

I saw this codebase that has reportedly made the switch to foxy - https://github.com/jeffrey870517/executive_smach

Hermanoid avatar Jul 12 '21 13:07 Hermanoid

It has been a year, I think it is time to bump this topic. This last post by @Hermanoid is the most bleeding edge of this topic I can find.

I am tempted to try out the referenced code, but SMACH without smach_viewer is a proposition that is hard to stomach. An introspection tool is vital.

albuckley avatar Sep 09 '21 15:09 albuckley

It looks like DeepX, inc. has a foxy version of executive_smach and executive_smach_visualization, but I haven't had eyes on them:

  • https://github.com/DeepX-inc/executive_smach
  • https://github.com/DeepX-inc/executive_smach_visualization

jbohren avatar Nov 29 '21 05:11 jbohren

It has been more than 3 years and this issue is still open. I recommend checking YASMIN: Yet Another State MachINe library for ROS 2 :wink:

jkaniuka avatar Jun 08 '23 15:06 jkaniuka

I'm listed as a maintainer, so I'm sorry for not taking any action til now. I just pushed ros2 branch based off of noetic-devel branch. If anyone could open a pull request against that branch, that'll be great.

A few of you have posted links to ros2-ified forked repos? Note you can even open a PR using that (even if that is not the repo you have a control over, I think).

130s avatar Jun 08 '23 15:06 130s

Yes indeed @130s ,

I've created the pull request #100 from the Deep-X-inc fork. Thanks a lot for looking into it !

bsteenput avatar Jun 12 '23 14:06 bsteenput

Status:

  1. [x] ROS2-ified --> https://github.com/ros/executive_smach/pull/100, https://github.com/ros/executive_smach/pull/101 (thanks @bsteenput!)
  2. [x] Made release (3.0.1)
  3. Requested adding to index (so that the pkg info will be on index.ros.org, also deb installer will be generated), following https://docs.ros.org/en/humble/How-To-Guides/Releasing/Release-Team-Repository.html
    1. [ ] Requested to add source entry -> https://github.com/ros/rosdistro/pull/37620
    2. [ ] Requested to add a GBP repo -> https://github.com/ros2-gbp/ros2-gbp-github-org/issues/275
    3. [ ] Requested to add a release entry

130s avatar Jun 12 '23 20:06 130s

This issue has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/smach-for-ros-2/3175/7

ros-discourse avatar Jun 12 '23 20:06 ros-discourse

Glad to see that porting SMACH to ROS 2 is moving so fast :+1: Taking advantage of the fact that this thread is active again, it is worth mentioning the issue of visualization. Being able to view the state machine in real time is a crucial part of using SMACH. So I suggest that we simultaneously port the executive_smach_visualization package to ROS 2 :wink:

jkaniuka avatar Jun 12 '23 21:06 jkaniuka

@jkaniuka Understood, but let's open a ticket separately on executive_smach_visualization/issues. Would you mind doing that? I don't seem to have maintainer access in that repo, and I doubt I can extend my bandwidth to do another release work real soon.

130s avatar Jun 13 '23 01:06 130s

First released version for ros2, 3.0.2 is out.

Requested making an installer:

  • rolling https://github.com/ros/rosdistro/pull/37814
  • iron https://github.com/ros/rosdistro/pull/37815
  • humble https://github.com/ros/rosdistro/pull/37813

130s avatar Jun 29 '23 10:06 130s