Skip to content
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

Running Multiple Containers #39

Open
OliverHeilmann opened this issue Aug 11, 2023 · 4 comments
Open

Running Multiple Containers #39

OliverHeilmann opened this issue Aug 11, 2023 · 4 comments

Comments

@OliverHeilmann
Copy link

Hello! I am currently exploring running multiple simulators in parallel for some CICD pipeline testing. I have used the Multi-Vehicle-Simulation-With-Gazebo which has been useful in checking that my agents can connect to multiple assets/ vehicles. Note: this helped me find the correct shell script.

My issue with this is that I cannot run the simulation in a headless environment i.e. on a pipeline test. I was thinking about containerising the multi-vehicle simulation. Gut feel is that three individual docker images may actually be the simplest option but I don't know how to map the UDP:14540 port to other ports as you aren't using the traditional docker -p command for it (noting that this approach would have three instances of Gazebo running which isn't great either).

So my question is two fold:

  1. Do you know how to run a mutli-vehicle headless simulation in a docker container? I can handle the mapping of ports 14540, 14541... 1454n using normal docker practices.
  2. If this is not possible, how can I modify this docker image to allow for remapping port 14540 to another one as done with the normal docker approach?
@JonasVautherin
Copy link
Owner

For the first question, I don't think anything prevents you from running a multi-vehicle headless simulation with some changes to this image. I haven't looked into it though, it would require a couple changes.

For the second question, the ports are defined here: https://github.com/JonasVautherin/px4-gazebo-headless/blob/master/edit_rcS.bash#L59C35-L59C58. So you could probably change \$udp_offboard_port_local for the port you want.

@OliverHeilmann
Copy link
Author

Thanks for the prompt response! I will look into modifying this image/ dockerfile to support multi-vehicle simulation. I think this is a more elegant solution over running multiple containers, with each running a simulator. Perhaps I will open up a pull request if I arrive to an elegant solution...

Regarding the \$udp_offboard_port_local, I'll give this a try but I am happy to close this issue now. Thanks!

@OliverHeilmann
Copy link
Author

Hello again!

Thought I'd reopen this issue instead of making a new one so the discussion stays on one thread... Below are the changes I have made in my attempt to get the multi-vehicle simulation working in a docker container. I used this repo as a baseline and made changes to a couple of the scripts.

entrypoint.sh

Changing the HEADLESS=1 make ... line to the sitl_multiple_run.sh made sense, the issue here is that the shell script uses the pre-built binaries instead of a make command directly.

+ ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -s "${vehicle}:3" -w "${world}"
-  HEADLESS=1 make px4_sitl gazebo_${vehicle}__${world}

sitl_multiple_run.sh

Add headless option to the px4 referenced binaries to ensure it uses the headless mode instead.

+ HEADLESS=1 $build_path/bin/px4 -i $n -d "$build_path/etc" >out.log 2>err.log &
- $build_path/bin/px4 -i $n -d "$build_path/etc" >out.log 2>err.log &

Issue with REST Request

When I run the below console command, being sure to map the other UDP ports which will be used for other vehicles (following the documentation), I get part of the way there.

oliver@ubuntu:~/<DIR>$ docker run --name sitl -p 14541:14541 -p 14542:14542 --rm -it px4-sitl-headless:latest

From the screenshot below, you can see that all three vehicles are created in the docker container and the headless mode is in fact working. The two errors are relating to an Audio device (which perhaps is not an issue since audio is then disabled) and then the REST request. The programme then hangs on the libcurl print and doesn't do anything else.

I have however tested the connections to the vehicles in the docker containers and it seems to be working which is great however. Any idea on these issues? I suspect if you follow those two changes, you should be able to replicate my issue.

Screenshot 2023-08-14 at 12 57 15

Thanks again for your help!

@JonasVautherin
Copy link
Owner

I think I wouldn't care about the "Audio will be disabled" part. IMO that could be a warning.

I don't know about the REST error, but the line just above says "Starting gazebo client". I believe it suggests that it is trying to run the frontend, which you don't want. So somehow something is not running headless with your setup.

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

No branches or pull requests

2 participants