Hi, dear colleges.
Now I am trying to control the motor speed by sending messages to the actuator_control topic with PX4 1.7.3.
I found the control flow in PX4 is like this:
actuator_control------------>mixer------------>normalised PWM------------>PWM----------->ESC(motor)
-
I identify the relation between the PWM sent to ESC and the motor speed: omega = g(PWM)
-
the relation PWM = f(normalised PWM) can be found
effective_pwm[i] = control_value * (max_pwm[i] - min_pwm[i]) / 2 + (max_pwm[i] + min_pwm[i]) / 2;
from PX4-Autopilot/src/modules/systemlib/pwm_limit/pwm_limit.c at v1.7.3 · PX4/PX4-Autopilot · GitHub.
- An identity mixer is defined such that normalised PWM = actuator_control. The mixer is defined as
I followed the steps Modifying mixer file without reflashing
M: 1
O: 10000 10000 0 -10000 10000
S: 0 0 10000 10000 0 -10000 10000
M: 1
O: 10000 10000 0 -10000 10000
S: 0 1 10000 10000 0 -10000 10000
M: 1
O: 10000 10000 0 -10000 10000
S: 0 2 10000 10000 0 -10000 10000
M: 1
O: 10000 10000 0 -10000 10000
S: 0 3 10000 10000 0 -10000 10000
Finally, the control messages publish to actuator_control can be computed from motor speed as
actuator_control = f^-1(g^-1(omega)).
However, I have meet some problems:
-
with the mixer in (auto.land mode), the /rc/out shozs that PWM sent to the motors are the same. However, the motor speeds are quite different. In fact, when PWM = 1500, the motor 4 are around 9000 rpm while motor 1,2,3 are like 14000. So, is there some other setting that I need to change, or my mixer is not defined correctly?
-
when switch to the OFFBOARD mode, /target_actuator_control is defined to copy the messages from /actuator_control and sent to PX4 in mavros. Howevcer, /target_actuator_control change to [0,0,0,0,0,0,0,-1] periodically. As a consequence, when I publish [-0.7,-0.7,-0.7,-0.7,0,0,0,0] to /actuator_control, /rc/out vibrates between [1512, 1512, 1512, 1512] and [1590,1590,1590,1590]. Is this a bug or I misunderstood something?