APMotors_6DOF: Implement motor_is_enabled(), get_motor_angular_factors() and set_reversed();

This commit is contained in:
Willian Galvani 2019-09-23 13:40:41 -03:00 committed by Jacob Walser
parent 4c62fe6c72
commit dd97eedde3
2 changed files with 34 additions and 0 deletions

View File

@ -551,3 +551,29 @@ void AP_Motors6DOF::output_armed_stabilizing_vectored_6dof()
}
}
}
Vector3f AP_Motors6DOF::get_motor_angular_factors(int motor_number) {
if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) {
return Vector3f(0,0,0);
}
return Vector3f(_roll_factor[motor_number], _pitch_factor[motor_number], _yaw_factor[motor_number]);
}
bool AP_Motors6DOF::motor_is_enabled(int motor_number) {
if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) {
return false;
}
return motor_enabled[motor_number];
}
bool AP_Motors6DOF::set_reversed(int motor_number, bool reversed) {
if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) {
return false;
}
if (reversed) {
_motor_reverse[motor_number].set_and_save(-1);
} else {
_motor_reverse[motor_number].set_and_save(1);
}
return true;
}

View File

@ -41,6 +41,14 @@ public:
// output_to_motors - sends minimum values out to the motors
void output_to_motors() override;
// returns a vector with roll, pitch, and yaw contributions
Vector3f get_motor_angular_factors(int motor_number);
// returns true if motor is enabled
bool motor_is_enabled(int motor_number);
bool set_reversed(int motor_number, bool reversed);
// var_info for holding Parameter information
static const struct AP_Param::GroupInfo var_info[];