mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
dummy mixer: add offset param
This commit is contained in:
@@ -115,7 +115,10 @@ MultirotorMixer::MultirotorMixer():
|
|||||||
_sub = _n.subscribe("actuator_controls_0", 1, &MultirotorMixer::actuatorControlsCallback,this);
|
_sub = _n.subscribe("actuator_controls_0", 1, &MultirotorMixer::actuatorControlsCallback,this);
|
||||||
_pub = _n.advertise<mav_msgs::MotorSpeed>("/mixed_motor_commands",10);
|
_pub = _n.advertise<mav_msgs::MotorSpeed>("/mixed_motor_commands",10);
|
||||||
if (!_n.hasParam("motor_scaling_radps")) {
|
if (!_n.hasParam("motor_scaling_radps")) {
|
||||||
_n.setParam("motor_scaling_radps", 1500.0);
|
_n.setParam("motor_scaling_radps", 150.0);
|
||||||
|
}
|
||||||
|
if (!_n.hasParam("motor_offset_radps")) {
|
||||||
|
_n.setParam("motor_offset_radps", 600.0);
|
||||||
}
|
}
|
||||||
_sub_actuator_armed = _n.subscribe("actuator_armed", 1, &MultirotorMixer::actuatorArmedCallback,this);
|
_sub_actuator_armed = _n.subscribe("actuator_armed", 1, &MultirotorMixer::actuatorArmedCallback,this);
|
||||||
}
|
}
|
||||||
@@ -189,20 +192,22 @@ void MultirotorMixer::mix() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mix
|
// mix
|
||||||
if (_armed) {
|
mix();
|
||||||
mix();
|
|
||||||
} else {
|
|
||||||
for (unsigned i = 0; i < _rotor_count; i++) {
|
|
||||||
outputs.control[i] = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// publish message
|
// publish message
|
||||||
mav_msgs::MotorSpeed rotor_vel_msg;
|
mav_msgs::MotorSpeed rotor_vel_msg;
|
||||||
double scaling;
|
double scaling;
|
||||||
|
double offset;
|
||||||
_n.getParamCached("motor_scaling_radps", scaling);
|
_n.getParamCached("motor_scaling_radps", scaling);
|
||||||
for (int i = 0; i < _rotor_count; i++) {
|
_n.getParamCached("motor_offset_radps", offset);
|
||||||
rotor_vel_msg.motor_speed.push_back(outputs.control[i] * scaling);
|
if (_armed) {
|
||||||
|
for (int i = 0; i < _rotor_count; i++) {
|
||||||
|
rotor_vel_msg.motor_speed.push_back(outputs.control[i] * scaling + offset);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < _rotor_count; i++) {
|
||||||
|
rotor_vel_msg.motor_speed.push_back(0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_pub.publish(rotor_vel_msg);
|
_pub.publish(rotor_vel_msg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user