-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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 support for simulators running on a different host than the PX4 instance #15965
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I was curious if the testing done also with the UDP connection? and a few minor comments in line
Also the SITL tests are failing. Do you mind rebasing the PR?
ROMFS/px4fmu_common/init.d-posix/rcS
Outdated
simulator start -c $simulator_tcp_port | ||
else | ||
echo "PX4 SIM HOST: $PX4_SIM_HOST" | ||
simulator start -c $simulator_tcp_port $PX4_SIM_HOST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense if the host is passed through a flag as it is done with the ports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use a flag since currently the flag is only used to specify the protocol. I decided to use the length of the arguments as it was already being used to verify that the port was passed through.
src/modules/simulator/simulator.cpp
Outdated
@@ -95,6 +107,8 @@ static void usage() | |||
PX4_INFO("Start simulator: simulator start"); | |||
PX4_INFO("Connect using UDP: simulator start -u udp_port"); | |||
PX4_INFO("Connect using TCP: simulator start -c tcp_port"); | |||
PX4_INFO("Connect using UDP: simulator start -u udp_port hostname"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this use case valid / tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UDP version hasn't been tested, I don't have a simulator at this time that uses a UDP connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not tested, would it be possible to disable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can remove it for now or comment it out. Which is preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also make it so that you support passing an explicit ip address instead of hostname ? In some cases (like windows subsystem for linux WSL2) the host name is the same for the linux and windows machines, but the ip addresses are different. Explicit ip address can also be handy to select a specific ethernet interface which can be handy when there's multiple ways to reach the host (e.g. wifi versus hard wired).
What commit should I rebase the PR against? I was working off the latest commit in master. The two test that were failing were complaining about not being able to connect to a display. |
I don't think this is accurate since it is reliably passing on other PRs - can you hvae a look? |
I added the couple of commits that occurred since I made this PR. I'm waiting to see if all the tests pass now. |
Two tests are still failing but it is not caused by the changes I made.
|
@FernandezR I am pretty sure that the following error is not causing the SITL test to fail, if you look at other PRs the tests pass even though it displays the same message
|
@Jaeyoung-Lim The specific tests that are not passing are these:
I'm not sure how I'm supposed to fix these tests failing as nothing I changed is impacting them. Looking in the logs the simulator connection is established on localhost as expected. And I can't do anything to solve the MacOS test that is failing as it has something to do with the CI environment as far as I can tell. |
This seems to be the cause of the failure: [mavsdk_tests] ../../../test/mavsdk_tests/autopilot_tester.cpp:106: FAILED: |
The latest commit on master seems to be failing the same SITL test |
@Jaeyoung-Lim Do you have any suggestions of how to debug the failing test? I'm not sure why this assertion, |
@Jaeyoung-Lim It looks like all the checks finally passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into the failures, and sorry for the late response.
Looks good to me on my side! Thanks!
@FernandezR can you align this PR with the changes made in #15443? I like your addition of an environment variable to change the IP. |
Yes, I will work on aligning with change to support both ip address and hostname for remote simulator. |
… address or hostname.
I updated the request to align to PR #15443 |
Failed tests are failing due to this error.
I'm not sure why some tests were cancelled. |
@Jaeyoung-Lim this PR looks like it would be super useful, and I think we should take over from @FernandezR, could you please branch out, fix the conflicts, and make a new PR? It would be the best way to go since the author already went out of his way to accommodate all of our requests. |
@mrpollo I have fixed the conflicts and updated to the latest commit in master. Do you still want another pr? This one was updated with the changes I just made automatically. Some test keep failing due to a missing ulg file that can't be found by the test. I'm not sure how that file is supposed to be created or why it is missing. Also, someone updated the number of arguments being passed to the simulator script but it was incorrect during my testing. So the values are back to there original values. |
@FernandezR we don't like merge commits from the main branch, we usually rebase, and to avoid further conflicts with the file you are modifying I have asked @Jaeyoung-Lim to help, he's probably creating a new PR to address the issue. Don't worry you will remain the author of the commits, he's just adding some on top. |
I have merged the work Fernandez did with the other change that already added "-t" support for remote ip addresses. See #17275 |
@lovettchris Thanks for merging in my changes. Should we close this pull request now? |
Yes I think I got all your changes in so if you are happy with what is in the master branch, go ahead and close this one. |
Changes merged into master through pull request #17275. |
Please use PX4 Discuss or Slack to align on pull requests if necessary. You can then open draft pull requests to get early feedback.
Describe problem solved by this pull request
Allows for the use of simulators running on a different host than the PX4 instance.
Describe your solution
Added use of
PX4_SIM_HOSTNAME
andPX4_SIM_HOST_ADDR
environment variables to pass simulator hostname or ip address through the posix rcs script to the simulator module.Describe possible alternatives
Didn't consider any other alternatives as this was the simplest implementation.
Test data / coverage
Tested using a docker compose implementation using a a private Unity Simulation, where simulator and PX4 instances exist in different containers. Also, tested on local machine to ensure continued support of
localhost
simulator.Additional context
None