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
simulator in hardware, new module #11400
Conversation
…r in the hardware autopilot, for more documentation visit https://github.com/romain-chiap/PX4_SIH_QuadX
Cool! Let me dig into this some more and we can discuss it. A few initial minor things that stand out are including it on more boards (should be almost everywhere except fmu-v2, io-v2, etc), a mechanism to start it (via param) with the right airframe (safe configuration), and metadata for the parameters. Trivial code style issues here - http://ci.px4.io:8080/blue/organizations/jenkins/PX4%2FFirmware/detail/PR-11400/1/pipeline |
It's a really interesting approach. Traditionally, HIL is used because the flight simulator is way too heavy to run on the autopilot itself. I'll try and give you some feedback as soon as possible! |
Super cool! |
I formatted the code with astyle and the metadata for the parameters. Regarding the board configs, mc_att_control appears in 40 different cmake files, so I guess I should include it in the same files except:
I think I should exclude it from SITL (to avoid an Inception like simulator :). Anyway, the sensors data will be conflicting with the data from SITL, so I won't include it. I will check to add another airframe but I'm not very familiar with that. |
Devcall: Cool feature! Can we have a minimal automatic test to run in CI and make sure it doesn't break in the future? Can we add some documentation? @dagar : Suggestion to use jMAVsim or gazebo to display the vehicle state. By using this MAVLink message which get sent here for the ground truth and having a mode for the simulator to just display the state instead of simulating. |
done:
in progress:
|
Where can I add the documentation? This is currently in a pdf file |
@romain-chiap Probably docs should go to the development guide's simulation part: |
@bkueng
|
src/modules/sih/sih_params.c
Outdated
* @min 0.0 | ||
* @decimal 2 | ||
* @increment 0.1 | ||
* @group SIH |
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.
Perhaps the group name should be Simulation In Hardware. At this point the acronym isn't as well known as SITL or HITL so while eventually SIH might be obvious, right now it is not.
You can see how all these will render here: https://hamishwillee.gitbooks.io/havdevguide/content/v/test_sih/en/advanced/parameter_reference.html#sih
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 put two underscores to:
- SIH__LAT0
- SIH__LON0
- SIH__H0
- SIH__MU_X
- SIH__MU_Y
- SIH__MU_Z
I would like them to be grouped in the documentation. Is there a better way to do 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.
I'm thinking of removing those six parameters as they are very specific and don't bring much if changed by the user.
@romain-chiap Very very cool. A few comments inline. With respect to documentation, as @MaEtUgR says above, it should appear in the table here: http://dev.px4.io/en/simulation/#supported-simulators and it should have its own sub page linking to it. The sub page should provide overview information in the same way as the other pages:
Mostly this is what you have in https://github.com/romain-chiap/PX4_SIH_QuadX/wiki/Setting-up-the-Coriolis-SIH and on your readme. You would also link to the generated parameters: https://hamishwillee.gitbooks.io/havdevguide/content/v/test_sih/en/advanced/parameter_reference.html#sih The PDF you link above is pretty cool (though we generate the params, so that section not so useful). It is up to you if you include that content in our docs. IMO that is quite a lot of work so ideally you would copy the file into https://github.com/PX4/Devguide/tree/master/assets/simulation and link to it from there. I don't know how well you know gitbook, but that is what we use for our infrastructure. Essentially you create files in markdown and submit a PR to https://github.com/PX4/Devguide. Info on the toolchain is here: http://dev.px4.io/en/contribute/docs.html#adding-new-content---big-changes Is that enough to get started? |
@hamishwillee |
Great. Minimally you could draft a link to your docs and then update when you have a little more time. |
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.
What category and subcategory should this be in for the module documentation? Currently this fails because a custom category was used:
We can add 'simulation' to https://github.com/PX4/Firmware/blob/master/Tools/px4moduledoc/srcparser.py#L13.
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.
@hamishwillee |
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 have a couple more remarks, this is IMO good to merge afterwards.
Can you also look into CI and run the style fix script?
@MaEtUgR |
Note there are also file conflicts above to be fixed. |
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.
@romain-chiap can you rebase?
I rebased from PX4/Firmware master.
|
Something did not work as expected (you can see it from the many commits that now appear in the PR). Can you try to rebase again? |
@bkueng What I did:
It looks good on my repository branch, but for some reason, it did not followed to the PR. Is there a good way to fix that? (or shall I make a new "clean" PR?) |
It looks good now, but unfortunately, there are conflicts again.
|
Done in #11835 |
new module added that allows to run a simulator for quadrotor directly on the hardware autopilot.
For more documentation visit
https://github.com/romain-chiap/PX4_SIH_QuadX
Please use PX4 Discuss or Slack to align on pull requests if necessary.
Test data / coverage
https://review.px4.io/plot_app?log=4a5b5b89-7231-4e7e-a989-f16e71aa9966
Describe problem solved by the proposed pull request
Timing delays due to the bidirectional connection from the hardware to the desktop computer are an issue in the HITL and affect the flight performance. Furthermore, a user willing to modify the quadrotor parameters (mass, inertia, maximum thrust, ...) needs to dig into JMAVSim or Gazebo to do the modification.
Describe your preferred solution
The proposed solution is to add a new module, fully compatible with PX4, called Simulator In Hardware (SIH). It implements the equations of motion of a quadrotor along with thruster force and torque, a simple drag model is also implemented. The sih module subscribes to actuator_outputs to get directly the outputs of the mixer. It also reconstructs noisy sensor data and publish them. The idea is to include the state estimator in the loop, and the controller of course.
The user can modify the drag coefficient, inertia matrix and mass of the vehicle directly from QGC parameters.
This module is fully compatible with the current PX4 Firmware. The following flight modes have been tested:
Describe possible alternatives
The other alternatives are to use the SITL or current HITL
Additional context
This module was developed to display the quadrotor trajectory in FlightGear, to have a real time visual.
This module outputs the quad position and orientation on a serial port. The idea is to transform those serial data into UDP to communicate the position/attitude to FlightGear for the display. A Java application SerialToUDP.jar is also provided at the following link along with a simple quadrotor model for FlightGear
https://github.com/romain-chiap/PX4_SIH_QuadX