AP_Motors: add method for scripting to set external limit flags
This commit is contained in:
parent
23fb73085a
commit
bbb9e66196
@ -258,8 +258,23 @@ void AP_MotorsMulticopter::output()
|
|||||||
|
|
||||||
// output raw roll/pitch/yaw/thrust
|
// output raw roll/pitch/yaw/thrust
|
||||||
output_rpyt();
|
output_rpyt();
|
||||||
|
|
||||||
|
// check for any external limit flags
|
||||||
|
update_external_limits();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void AP_MotorsMulticopter::update_external_limits()
|
||||||
|
{
|
||||||
|
#if AP_SCRIPTING_ENABLED
|
||||||
|
limit.roll |= external_limits.roll;
|
||||||
|
limit.pitch |= external_limits.pitch;
|
||||||
|
limit.yaw |= external_limits.yaw;
|
||||||
|
limit.throttle_lower |= external_limits.throttle_lower;
|
||||||
|
limit.throttle_upper |= external_limits.throttle_upper;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// output booster throttle, if any
|
// output booster throttle, if any
|
||||||
void AP_MotorsMulticopter::output_boost_throttle(void)
|
void AP_MotorsMulticopter::output_boost_throttle(void)
|
||||||
{
|
{
|
||||||
|
@ -154,6 +154,9 @@ protected:
|
|||||||
// save parameters as part of disarming
|
// save parameters as part of disarming
|
||||||
void save_params_on_disarm() override;
|
void save_params_on_disarm() override;
|
||||||
|
|
||||||
|
// update external limits from scripting
|
||||||
|
void update_external_limits();
|
||||||
|
|
||||||
// enum values for HOVER_LEARN parameter
|
// enum values for HOVER_LEARN parameter
|
||||||
enum HoverLearn {
|
enum HoverLearn {
|
||||||
HOVER_LEARN_DISABLED = 0,
|
HOVER_LEARN_DISABLED = 0,
|
||||||
|
@ -219,6 +219,17 @@ void AP_Motors::set_limit_flag_pitch_roll_yaw(bool flag)
|
|||||||
limit.yaw = flag;
|
limit.yaw = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if AP_SCRIPTING_ENABLED
|
||||||
|
void AP_Motors::set_external_limits(bool roll, bool pitch, bool yaw, bool throttle_lower, bool throttle_upper)
|
||||||
|
{
|
||||||
|
external_limits.roll = roll;
|
||||||
|
external_limits.pitch = pitch;
|
||||||
|
external_limits.yaw = yaw;
|
||||||
|
external_limits.throttle_lower = throttle_lower;
|
||||||
|
external_limits.throttle_upper = throttle_upper;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// returns true if the configured PWM type is digital and should have fixed endpoints
|
// returns true if the configured PWM type is digital and should have fixed endpoints
|
||||||
bool AP_Motors::is_digital_pwm_type() const
|
bool AP_Motors::is_digital_pwm_type() const
|
||||||
{
|
{
|
||||||
|
@ -199,16 +199,21 @@ public:
|
|||||||
|
|
||||||
// structure for holding motor limit flags
|
// structure for holding motor limit flags
|
||||||
struct AP_Motors_limit {
|
struct AP_Motors_limit {
|
||||||
uint8_t roll : 1; // we have reached roll or pitch limit
|
bool roll; // we have reached roll or pitch limit
|
||||||
uint8_t pitch : 1; // we have reached roll or pitch limit
|
bool pitch; // we have reached roll or pitch limit
|
||||||
uint8_t yaw : 1; // we have reached yaw limit
|
bool yaw; // we have reached yaw limit
|
||||||
uint8_t throttle_lower : 1; // we have reached throttle's lower limit
|
bool throttle_lower; // we have reached throttle's lower limit
|
||||||
uint8_t throttle_upper : 1; // we have reached throttle's upper limit
|
bool throttle_upper; // we have reached throttle's upper limit
|
||||||
} limit;
|
} limit;
|
||||||
|
|
||||||
// set limit flag for pitch, roll and yaw
|
// set limit flag for pitch, roll and yaw
|
||||||
void set_limit_flag_pitch_roll_yaw(bool flag);
|
void set_limit_flag_pitch_roll_yaw(bool flag);
|
||||||
|
|
||||||
|
#if AP_SCRIPTING_ENABLED
|
||||||
|
// set limit flag for pitch, roll and yaw
|
||||||
|
void set_external_limits(bool roll, bool pitch, bool yaw, bool throttle_lower, bool throttle_upper);
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// virtual functions that should be implemented by child classes
|
// virtual functions that should be implemented by child classes
|
||||||
//
|
//
|
||||||
@ -367,6 +372,9 @@ protected:
|
|||||||
#if AP_SCRIPTING_ENABLED
|
#if AP_SCRIPTING_ENABLED
|
||||||
// Custom frame string set from scripting
|
// Custom frame string set from scripting
|
||||||
char* custom_frame_string;
|
char* custom_frame_string;
|
||||||
|
|
||||||
|
// external limits from scripting
|
||||||
|
AP_Motors_limit external_limits;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user