In the example here(First Application Tutorial (Hello Sky) | PX4 Guide (main)), they’ve written a code in C that reads data from a topic and prints it. I want to write a similar C program that will instruct the drone in JMAVSim to fly a certain way(give pitch, yaw, roll, throttle commands).
I’ve disabled lockstep in sitl.cmake in boards/px4/sit
I’ve commented the line mc_rate_control start in PX4-Autopilot/ROMFS/px4fmu_common/init.d to disable the default application that controls the quad.
Moreover, this is the code that I’m running in px4_simple_app to control the quad:
I am not sure what the expectation of sending arming commands as you are doing in your application.
There are a lot of things missing from your implementation that ensures safely operating the vehicle. If you want to have a reference, you can look at what the mc_rate_control, which you have commented out to check what your application is missing.
Yes I did. In a modified application, I armed my vehicle by publishing to vehicle_control_mode and then publishing to vehicle_attitude_setpoint. However, I still did not get any results.I did commander stop and ran my code. The Attitude_setpoints revert back to some default value after every second iteration. I wasn’t really concerned with the safe operating of the vehicle as I just wanted to get some actuator output and see it move around.
Moreover, here’s a link to my modified code- px4_simple_app/px4_simple_app.c at fbfbe794c865811cdd8571702d2cffe15cbf2490 · wickedticket/px4_simple_app · GitHub
I’ll check out mc_rate_control.
@A7sus4 Why would you stop commander to run your code? Then this means that you need to handle what commander was doing in your code, which I believe the code is not doing and therefore not working
@A7sus4 I was not implying that you should run your code together with commander.
What I meant is that there are a lot of states that are being set for safety in commander, and that you need to handle these if you want to replace commander.
If you are just interested in implementing a controller, you can look at what information the mc_rate_controller is using, and just replace the mc_rate_controller with your implementation
hey @Jaeyoung-Lim . I followed your advice and went through MulticopterRateControl.cpp in src/modules/mc_rate_control thoroughly . I also decided to make some changes in it. Changes in yaw, pitch or roll are getting reflected in jmavsim only when I do commander takeoff.
For example, when I run make px4_sitl_default jmavsim, nothing happens. When i do commander takeoff, the quad takes off, but doesn’t really fly away as I’d expect it to. Commands that come under commander takeoff are probably interfering with my commands.
How do I make sure that the quad runs MulticopterRateControl.cpp with only the upthrust and yaw pitch roll values set by me?