I am trying to implement obstacle avoidance using Pixhawk. I wanted to override RC in my onboard app when the drone faces obstacles. I was wondering if position_set or velocity_set means overriding RC. Or how can I use rc_override from mavros for this sort of implementation?
Sorry for the delayed response.
If you have Position estimation of the drone, then it is better to use position_set or velocity_set API.
If you are worried, whether RC stick commands would override your position_set API, then answer is ‘NO’. For position_set or velocity_set API to work, FlytOS changes the Pixhawk’s vehicle mode to ‘OFFBOARD’ or ‘GUIDED’, and RC sticks have no effect in this mode.
Does this sort your problem?
Hi! Thanks for your response!
I have two questions,
Will use of any navigation APIs result in the pixhawk’s mode switching to ‘offboard’ or ‘guided’?
Is there any way I can code my script to change the mode of the vehicle?
If you are testing this on FlytSim, FlytOS will automatically do the switching for you.
But in case of real drone, you have to configure a mode switch in RC. When you want FlytOS to take control of your drone, flip the mode switch to ‘Offboard’/‘Guided’ mode. If you do not want to configure switch in RC, take a look at ‘access_request’ API.
Hi, access_request will allow me to control the drone using API and disable RC control, right?
Is there a way to switch back to RC control?
The only way to correctly switch back to RC control is via changing ‘mode’ switch from RC to MANUAL/STABILIZE/ALTHOLD/POSHOLD modes. OR any mode other that GUIDED/ OFFBOARD.
Hi, is there anyway i can switch back to RC mode without manually switching from RC controller?
For example, after some command is completed in offboard mode, it will automatically switch back to RC mode.
If it is impossible, could you make an API to perform this function?
Yes. It is possible but not recommended. If you are sending it to RC mode, without having an RC pilot, it may cause issues.
Can you instead just send a position_hold command? Can you please explain your situation where you would want to send the drone to RC mode?
You can use Mavros set_mode API -> http://wiki.ros.org/mavros