Skip to content

Add spawner and unspawner scripts#310

Merged
bmagyar merged 17 commits intoros-controls:masterfrom
pal-robotics-forks:add-spawn-unspawn
Mar 28, 2021
Merged

Add spawner and unspawner scripts#310
bmagyar merged 17 commits intoros-controls:masterfrom
pal-robotics-forks:add-spawn-unspawn

Conversation

@v-lopez
Copy link
Copy Markdown
Contributor

@v-lopez v-lopez commented Jan 26, 2021

Fixes #294

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Jan 26, 2021

This works better if you have #309 to detect when a command failed.

And also ros2/ros2cli#590 for the param load functionality.

Copy link
Copy Markdown
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Request for 2 small changes.

Were spawner and unspawner nodes in ros1. Does it make sense to have them as nodes or just as scripts as you implemented?

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Jan 26, 2021

Request for 2 small changes.

Were spawner and unspawner nodes in ros1. Does it make sense to have them as nodes or just as scripts as you implemented?

That's up for debate. I started as a node, but I would need to duplicate much code from ros2controlcli and from the ros2param load. I opened ros2/rclpy#671 and went to work as a script to above duplication.

If we want to add more features like listening to a topic as in ROS1, it makes more sense as a node, hopefully there's a way of avoiding duplicating everything.

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Jan 27, 2021

I'd say go with the current version so we have something, and later when we can avoid code duplication, we rewrite it to use services directly.

One thing we could do now as a middleground solution, is implement it as a Node that calls the subprocess.
The reasoning being that if we want to write launch files using it, right now they would be written with ExecuteProcess Action and if it was a Node with the Node Action..

If we want launch files to remain unchanged, we should use a Node right now, even if it's implemented as a script.

@destogl
Copy link
Copy Markdown
Member

destogl commented Jan 27, 2021

I'd say go with the current version so we have something, and later when we can avoid code duplication, we rewrite it to use services directly.

OK, if you correct flake8 I agree :)

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Jan 27, 2021

Damn it, yeah I will.

Let me change it to node first (albeit using subprocess), I'll do it Friday morning.

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Jan 29, 2021

I will, sorry about that.

Do you know why my colcon test and ament_flake8 won't detect that stuff?

$ dpkg -l | grep flake8
ii  ros-foxy-ament-flake8                           0.9.6-1focal.20201210.043943         amd64        The ability to check code for style and syntax conventions with flake8.

$ ament_flake8  
2 files checked
No problems found

Checked files:

* ./spawner.py
* ./unspawner.py

@v-lopez v-lopez force-pushed the add-spawn-unspawn branch 2 times, most recently from b45c374 to ddb3809 Compare January 29, 2021 11:34
@bmagyar
Copy link
Copy Markdown
Member

bmagyar commented Feb 3, 2021

I'm happy to merge this if you pinky promise a follow-up PR with some tests?

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Feb 3, 2021

I will add the tests, but we may want to hold the merge until ros2/ros2cli#590 is passed. Otherwise the part about loading parameters is going to fail because ros2 param load will not exist.

@bmagyar
Copy link
Copy Markdown
Member

bmagyar commented Feb 3, 2021

Is that going into Foxy or only Galactic?

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Feb 3, 2021

I'm gonna request for a cherry-pick to foxy since it's 100% backwards compatible and useful.

@v-lopez v-lopez force-pushed the add-spawn-unspawn branch 2 times, most recently from 0f35b92 to fdbc23e Compare February 5, 2021 13:30
@v-lopez v-lopez changed the title Add spawner and unspawner scripts WIP: Add spawner and unspawner scripts Feb 5, 2021
@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Feb 5, 2021

I added the tests but they seem to fail on the buildfarm, I'll check them next week.

@destogl
Copy link
Copy Markdown
Member

destogl commented Feb 15, 2021

Could you add an example of using spawners in launch files? Maybe on ros2_control_demos repo?

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Feb 16, 2021

I'll add the examples.

Do you have any idea why is it failing?
I see some "No executable found" messages as if the spawner.py was not in the ros2 run path, but if I run the tests with colcon test it works for me.

Also I expect that they will fail until ros2/ros2cli#596 is accepted, but they should fail differently complaining with:

usage: ros2 param [-h] Call ros2 param <command> -h for more detailed usage. ...
ros2 param: error: argument Call ros2 param <command> -h for more detailed usage.: invalid choice: 'load' (choose from 'delete', 'describe', 'dump', 'get', 'list', 'set')

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Feb 16, 2021

@destogl @bmagyar to add the ros2_control_demo example I need to solve #320 first. To put the reusable code there. It's 70 lines of python launch nonsense that I don't want to replicate.

@destogl
Copy link
Copy Markdown
Member

destogl commented Feb 16, 2021

@destogl @bmagyar to add the ros2_control_demo example I need to solve #320 first. To put the reusable code there. It's 70 lines of python launch nonsense that I don't want to replicate.

fully agree with you!

@v-lopez
Copy link
Copy Markdown
Contributor Author

v-lopez commented Mar 10, 2021

@Karsten1987 This is the PR we were talking about. Waiting on ros2cli to be released.

Copy link
Copy Markdown
Contributor

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

I have two requests for changes here:

  • Replace the python subprocess calls with actual ROS2 python API. Most of the calls can easily be replaced by a service call. That saves error prone command line output parsing.
  • I'd love to see this functionality refactored into some sort of spawner API. The reason for this is that I believe we should leverage this quite a bit within the ros2 control CLI, i.e. loading a controller or unloading it.

Victor Lopez and others added 16 commits March 23, 2021 08:07
Signed-off-by: Victor Lopez <victor.lopez@pal-robotics.com>
Signed-off-by: Victor Lopez <victor.lopez@pal-robotics.com>
Signed-off-by: Victor Lopez <victor.lopez@pal-robotics.com>
fixes ros-controls#320

Signed-off-by: Victor Lopez <victor.lopez@pal-robotics.com>
Co-authored-by: Denis Štogl <destogl@users.noreply.github.com>
Co-authored-by: Karsten Knese <Karsten1987@users.noreply.github.com>
@bmagyar bmagyar force-pushed the add-spawn-unspawn branch from e0d00a9 to 32d8933 Compare March 23, 2021 08:24
@bmagyar
Copy link
Copy Markdown
Member

bmagyar commented Mar 23, 2021

I have rebased the branch to resolve the conflict. We are still blocked waiting for a release of ros2/ros2cli#596 , ros2cli to Foxy.

Asked for a release here: ros2/ros2cli#612

@bmagyar bmagyar changed the title WIP: Add spawner and unspawner scripts Add spawner and unspawner scripts Mar 28, 2021
@bmagyar bmagyar merged commit f31c7eb into ros-controls:master Mar 28, 2021
destogl pushed a commit to b-robotized-forks/ros2_control that referenced this pull request Aug 11, 2022
@saikishor saikishor deleted the add-spawn-unspawn branch July 9, 2025 20:27
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.

Spawner and unspawner

4 participants