I am developing a feedback controller for a quadrotor that sends signals (the target angular velocity or voltage) directly to the motors. All the code examples I saw do something like
void Run() override
{
// ...
actuator_controls_s actuators;
actuators.control[0] = ktx * torque_x; // forward-direction torque
actuators.control[1] = kty * torque_y; // right-direction torque
actuators.control[2] = ktz * torque_z; // up-direction torque
actuators.control[3] = kfz * force_z; // up-direction force
actuators.timestamp = hrt_absolute_time();
orb_publish_auto(ORB_ID(actuator_controls_0),
&_actuator0_pub, &actuators, nullptr, ORB_PRIO_DEFAULT);
}
So, all the signals actuators.control
go throw the MultirotorMixer
to pwm
. But I would like to remove all the mixers from the pipeline to be able to control the motors individually.
As far as I understand, this can be made by changing the Multirotor
mixer by the Simple
mixer in quad_x.main.mix
. So, I did
M: 1
S: 1 4 0 20000 -10000 -10000 10000
M: 1
S: 1 5 0 20000 -10000 -10000 10000
M: 1
S: 1 6 0 20000 -10000 -10000 10000
M: 1
S: 1 7 0 20000 -10000 -10000 10000
and also in C++ changed the channels to 4…7 of group actuator_controls_1
.
This trick doesn’t work, because PX4IO::task_main()
subscribes to the group actuator_controls_0, and does not react on messages in actuator_controls_1
.
All of these seem to me like a dirty hack. Is there a good way? I will be surprised if not.