I’d like to implement my own rate control loop, and set direct command to the motors for hovering and basic movements.
My testing is currently on SITL only, ArduCopter mode.
I calculate altitude and attitude rate errors, and then build it into motor command, and finally i set the value to the motor.
I tried to work in GUIDED and in ACRO, but it looks like the copter is ignoring my PWM commands.
In what mode should i work in order to not interfere with RC or other commands ?
Your approach is likely flawed, and I don’t think you’ll be able to directly influence motor output the way you are attempting.
If you really want a custom rate controller, you need to look at modifying the C++ source with a custom flight mode (or possibly even deeper customization).
But what is it that you’re trying to do that guided mode will not accomplish?
Hi Yuri,
This is a kind of educational project of autonomous racing drone, which implements rate control algorithm.
We would like to base it on standard ArduPilot and do not change its code because of the regulations.
The alternative approach may be to override RC commands in Acro, like with Mavlink, but i think it less effective, that’s why i thought about direct motor control.
The best option could be direct access to the AP’s rate controller, but as far as i know it is not possible from LUA.
Can you recommend another way to do this?
I agree, it is not the optimal solution, but like i said, this is educational school project.
Can i achieve 150-200Hz update rate on LUA with H7 (480 MHz) cpu?
Can i pass commands for roll and pitch rates in Guided mode from LUA ?
I need fact response like in Acro mode.
I tried the function **set_target_throttle_rate_rpy ** from your list,
in SITL in Guided mode, with only pitch rate of 0.5 rad/s, the other arguments were zero, but nothing happened.
The copter keeps hovering on the same place at 20 m.
Did i forget something?
You need to continually send guided mode target commands at a rate of at least several Hz. If guided mode does not see this, it will assume a broken control scheme and simply loiter.
I tested other function from the list set_target_rate_and_throttle and it is working.
The copter got pitch rate and moved forward as expected, but i need custom control over the throttle.
Can it be some bug in the implementation of set_target_throttle_rate_rpy ?
I didn’t found its source code in the AP.