Hello, I am currently using the Navigator board to design a new controller for the BlueROV2 (LQR) for educational and research purposes. I am planning to create firmware using MATLAB, similar to Pixhawk, and I really need help with documentation and suggestions from you. What should I do first? Thank you.
Hi @HoaiThanh -
Can you expand on what you mean by “controller LQR?” What are your goals for the vehicle and your custom software?
The ArduPilot firmware that typically runs on BlueOS uses the Navigator as a source of input/output/motion sensors. This firmware has nothing to do with Matlab…
I’d recommend researching ArduSub, and seeing what functionality you’d like to modify to accomplish your goals. Depending on the application, a Lua script, which is executed by the autopilot, may also be a good solution!
I am very happy to receive your response.
I use the LQR controller to control the depth and heading of the BlueROV2 (Normal), but currently, I don’t know how to integrate this controller into the Navigator. The documents you provided are very valuable to me. Thank you!
Hi @HoaiThanh -
Happy to help. When in depth-hold mode, the ArduSub autopilot firmware will automatically control both heading and depth, allowing you to higher level commands to change these set-points. I’m not sure what advantage your “LQR” controller would have, or if it is even necessary vs. what the system already provides!
To not conflict with the autopilot, you would need to either disable it and use Navigator web assistant for direct controls of outputs, or set the vehicle to manual mode and manually send simulated joystick input, or individually control motor throttle levels via ArduSub (for exmple, via pymavlink.)
I believe ArduPilot uses a simple PID controller so LRQ might give you some performance benefits in some cases. I think your best bet is to use ROS node in matlab: https://www.mathworks.com/help/ros/ug/generate-a-standalone-ros-node-for-a-uav-waypoint-follower.html
Hi @HoaiThanh, welcome to the forum
If I remember correctly MATLAB allows generating and exporting C++ code, which is how some of the original ArduPilot source code was created. If you’re mostly interested in writing a control algorithm then it might be worth focusing on integrating that with the existing ArduPilot codebase rather than creating an entire vehicle firmware from scratch (including sensor and peripheral libraries, communication protocols, etc).
I expect ArduPilot’s more general development communication channels are likely to yield more directed advice, if that’s relevant to you
This is unlikely to be suitable for high fidelity control, because of the latency of the communications link between the autopilot and the computer running MATLAB. It could technically function, but code running on the autopilot has access to much lower latency (and higher frequency) sensor and state updates than code running on an onboard or topside computer, which is generally important for control algorithms to be effective.