Question on Custom Controller Implementation
-
I'm working with the Sentinel platform and I'm planning on testing a custom controller that runs in tandem with a deep learning model and I have some general questions about implementation. I've modified the existing voxl-vision-hub to contain an additional offboard mode with a custom trajectory. I want to also implement a custom controller that basically replaces the Position/Attitude controllers on PX4 and just feeds rate/thrust commands to PX4's rate controller.
-
Is implementing a controller as a separate thread within a new offboard mode in voxl-vision-hub a viable option or would I have to modify PX4 source code to edit the existing position/attitude controllers? I saw there is a message struct in the mavlink API for sending rate/thrust commands directly to PX4 so I was planning on having the controller pull down the current state from the autopilot monitor in voxl-vision-hub for input the same way existing offboard modes do and output the rate thrust commands via mavlink the same way trajectory setpoints are sent.
-
If I do have to modify PX4 source code, how would I go about doing that? Can I just uninstall the px4 service from the sentinel, pull down the repo here https://gitlab.com/voxl-public/voxl-sdk/services/voxl-px4, swap the px4 submodule with an edited one, rebuild locally and push it back to sentinel?
-
Any general advice/warnings for custom controller implementation?
Any feedback is appreciated. Thanks!
-
-
@josephmlullo Here is how to build PX4 for VOXL 2 https://docs.modalai.com/voxl-px4-dev-build-guide/
-
On this branch you can see how to control the attitude for PX4 in offboard_mode just from the CPU https://gitlab.com/voxl-public/voxl-sdk/services/voxl-vision-hub/-/blob/dev_attitude_target/src/offboard_manual.c?ref_type=heads
Please note, this is development code and we do not support it in any way. you are on your own when implementing your own controller
-
@josephmlullo The build environment for px4 is within a Docker container. You can find the instructions on how to create this Docker image here: https://gitlab.com/voxl-public/rb5-flight/rb5-flight-px4-build-docker