Skip to content

Commit 995cc5c

Browse files
authored
Merge pull request #445 from rosflight/update-mixer-error-message
added error message if canned mixer is used but USE_MOTOR_PARAM is se…
2 parents cacbf2c + de1a212 commit 995cc5c

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/mixer.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,42 @@ void Mixer::init_mixing()
241241

242242
// Update the motor parameters that will be used
243243
update_parameters();
244-
} else if (mixer_choice != FIXEDWING ||
244+
} else if (mixer_choice != FIXEDWING &&
245245
mixer_choice != INVERTED_VTAIL) {
246246
// Invert the selected "canned" matrix
247247
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_INFO,
248248
"Inverting selected mixing matrix...");
249249
primary_mixer_ = invert_mixer(array_of_mixers_[mixer_choice]);
250+
251+
// If using a canned mixer but the USE_MOTOR_PARAM is set to 1 (true), raise a warning.
252+
// Motor parameters (thus motor speed/voltage calculations) should not be used with the canned
253+
// mixers, since the output will be vanishingly small. Check online documentation for more
254+
// information.
255+
if (!(RF_.params_.get_param_int(PARAM_USE_MOTOR_PARAMETERS) == 0)) {
256+
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING,
257+
("USE_MOTOR_PARAM=1, but PRIMARY_MIXER=" + std::to_string(static_cast<unsigned int>(mixer_choice)) + ", which").c_str());
258+
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING,
259+
"may cause issues (check docs). Is this correct?");
260+
}
261+
250262
} else {
251263
// Don't invert the fixedwing mixers
252264
primary_mixer_ = *array_of_mixers_[mixer_choice];
265+
266+
// For the fixedwing canned mixers, the RC_F_AXIS parameter should be set to 0 (X-AXIS).
267+
// Otherwise, the aircraft will arm and appear to be ok, but will zero out any RC throttle
268+
// commands. Raise a warning if this condition is detected
269+
int rc_f_axis = RF_.params_.get_param_int(PARAM_RC_F_AXIS);
270+
if (!(rc_f_axis == 0)) {
271+
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING,
272+
("PRIMARY_MIXER=" + std::to_string(static_cast<unsigned int>(mixer_choice))
273+
+ " but RC_F_AXIS="
274+
+ std::to_string(static_cast<unsigned int>(rc_f_axis))
275+
+ ", which"
276+
).c_str());
277+
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING,
278+
"will cause issues (check docs). Is this correct?");
279+
}
253280
}
254281

255282
// Load the primary mixer header to the mixer_to_use_ header. Note that both the primary and

0 commit comments

Comments
 (0)