-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add args for "--stream" for webots simulation streaming (temp workaround in comments) #209
Comments
Unfortunately, It doesn't exist in the
Please go ahead:
I am not sure whether it is a good approach to restart the simulation only (Webots and the controller). Let's say you start the simulation and it reaches a state A_{simulation}, and the other nodes (e.g. navigation and mapping) reach the corresponding state A_{control}. If you restart the simulation your simulation will be in state B_{simulation} even though the other nodes are still in the state A_{control}. Therefore, the nodes will completely confused. Please correct me if I am wrong. I was thinking to emit an event when the simulation is restarted/reset, so a user can decide how to handle it. Something similar to what we are doing right now for exiting the simulation:
|
I will do my best to put in a quality PR for the "--stream" args ASAP, thank you for the tips on where to start. Pretty straightforward, I just need to contribute some effort here.
After becoming more familiar with webots over the past couple of weeks, I think I agree with this. I assume what you're saying is that you wouldn't want ROS2 to get way out of sync with the progression of the webots simulation because of a disjointed "restart" between the webots simulation, ROS2 nodes that make use of the webots interface, and ROS2 nodes that aren't making use of the webots interface? Seems like it would require almost an entire process exit and complete restart of the launch (which is where I was headed in terms of a "workaround" for this) In the lines you mentioned:
I am assuming this is simply saying "when this ros2 launch process exits, gracefully shutdown webots too". Is it possible to call an additional event handler, to handle whatever specific event(s) from webots occur when the "reset" button is activated from the gui, to trigger both gracefully shutting down webots, but also to exit and then "relaunch" the ROS2 launchfile itself (relaunch all associated nodes)? Forgive my ignorance if this the wrong approach, or not a built-in functionality for the launch.event_handler in ROS2 (I am still building familiarity for best practices for general ROS2 usage). I did a quick once-over to review the classes from launch.event_handlers and didn't see anything right away that stuck out as being able to have a launchfile "relaunch" itself upon something like webots gui events (in this specific example). I feel like I'm probably overlooking something simple either with how to handle this, or that a full relaunch may not even be necessary (or desirable). Thanks again for your feedback and for such a detailed/quality response; I am still familiarizing myself with webots and ROS2 simulation best-practices in general, so my questions here are likely part "feature request" and part "I didn't know it could do that". Let me know your thoughts, and I'll proceed with the effort needed to get some of the core "--stream" args functionality established in the meantime. |
No :/ To be honest I have no idea how to implement it. We should explore how to implement a custom event in ROS 2 launch and how to pass the event from Webots. On the Webots side, we probably can implement whatever is needed to pass the events to the ROS 2 launch. You can create a proof of concept before proposing changes to Webots. Like, implement a simple application that replaces Webots and emits necessary events to the ROS 2 launch (to restart nodes). Once you have the example working feel free to propose changes to Webots, open an issue, or PR. |
Will do. Looks like additional parameters for the launch description that may allow for conditional respawning of nodes; might be getting warmer here. Going to try to utilize this to test out a "respawn" of a node upon closing webots. Then I'll look into how webots gets a "closed" state from the restart button, and how that can be distinguished from simply closing the window. Some days ago I am certain I stumbled across the API docs for what the actual gui buttons returned--It's in a sea of bookmarks so bare with me and I'll see if I can't get a proof of concept rolling here in the next few hours. |
a) Maybe we can create an action, similar to b) Even simpler. Consider that the simulation reset kills the controller. Also, consider that the So here:
we should add an event fired on the on_exit callback. On this event, we should restart the ControllerLauncher and all other relevant nodes (if possible).
|
Is your feature request related to a problem? Please describe.
Requesting a feature for handling the "--stream" and other webots args for serving/accessing webots simulations from a browser via websocket and http:// need to be added. I could not find docs on this feature, nor where there is existing configurable functionality to add it to the ros2 launch command. The webots docs for these args are here: https://cyberbotics.com/doc/guide/starting-webots#streaming-server-options
Describe the solution you'd like
I'm open to adding to the existing args parsing/handling for the launcher myself and submitting a pr, if it's not already done or being addressed in another issue.
Describe alternatives you've considered
I've shoehorned-in a "--stream" argument to the string put together by webots_launcher,py for the webots command, and it streaming works fine.
Additional context
For anyone wanting a quick bandaid to get simulation streaming working
Change line 61 in webots_launcher.py (https://github.com/cyberbotics/webots_ros2/blob/master/webots_ros2_core/webots_ros2_core/webots_launcher.py#L61)
from:
to:
Then cd to your colcon workspace (contains your src folder) and run a full build from your workspace home:
Then run your launchfile for the desired ros2 webots package, and follow the normal steps for accessing a webots streaming server per their docs https://cyberbotics.com/doc/guide/web-streaming#how-to-stream-a-webots-simulation
^that is not an ideal fix, just some breadcrumbs for anyone wanting this feature prior to a pr.
Also note: The Reset Simulation button in the GUI from webot's streaming viewer html, reproduces the same problem from #40 with extern controllers not being relaunched when simulation is relaunched
The text was updated successfully, but these errors were encountered: