@@ -97,6 +97,11 @@ void ModeGuided::run()
97
97
}
98
98
}
99
99
100
+ bool ModeGuided::option_is_enabled (Option option) const
101
+ {
102
+ return copter.g2 .guided_options .get () & (uint32_t )option) != 0 ;
103
+ }
104
+
100
105
bool ModeGuided::allows_arming (AP_Arming::Method method) const
101
106
{
102
107
// always allow arming from the ground station or scripting
@@ -105,13 +110,13 @@ bool ModeGuided::allows_arming(AP_Arming::Method method) const
105
110
}
106
111
107
112
// optionally allow arming from the transmitter
108
- return (copter. g2 . guided_options & ( uint32_t )Options ::AllowArmingFromTX) != 0 ;
113
+ return option_is_enabled (Option ::AllowArmingFromTX);
109
114
};
110
115
111
116
#if WEATHERVANE_ENABLED == ENABLED
112
117
bool ModeGuided::allows_weathervaning () const
113
118
{
114
- return (copter. g2 . guided_options . get () & ( uint32_t )Options ::AllowWeatherVaning) != 0 ;
119
+ return option_is_enabled (Option ::AllowWeatherVaning);
115
120
}
116
121
#endif
117
122
@@ -607,25 +612,25 @@ bool ModeGuided::set_destination_posvelaccel(const Vector3f& destination, const
607
612
// returns true if GUIDED_OPTIONS param suggests SET_ATTITUDE_TARGET's "thrust" field should be interpreted as thrust instead of climb rate
608
613
bool ModeGuided::set_attitude_target_provides_thrust () const
609
614
{
610
- return ((copter. g2 . guided_options . get () & uint32_t (Options ::SetAttitudeTarget_ThrustAsThrust)) != 0 );
615
+ return option_is_enabled (Option ::SetAttitudeTarget_ThrustAsThrust);
611
616
}
612
617
613
618
// returns true if GUIDED_OPTIONS param specifies position should be controlled (when velocity and/or acceleration control is active)
614
619
bool ModeGuided::stabilizing_pos_xy () const
615
620
{
616
- return !((copter. g2 . guided_options . get () & uint32_t (Options ::DoNotStabilizePositionXY)) != 0 );
621
+ return !option_is_enabled (Option ::DoNotStabilizePositionXY);
617
622
}
618
623
619
624
// returns true if GUIDED_OPTIONS param specifies velocity should be controlled (when acceleration control is active)
620
625
bool ModeGuided::stabilizing_vel_xy () const
621
626
{
622
- return !((copter. g2 . guided_options . get () & uint32_t (Options ::DoNotStabilizeVelocityXY)) != 0 );
627
+ return !option_is_enabled (Option ::DoNotStabilizeVelocityXY);
623
628
}
624
629
625
630
// returns true if GUIDED_OPTIONS param specifies waypoint navigation should be used for position control (allow path planning to be used but updates must be slower)
626
631
bool ModeGuided::use_wpnav_for_position_control () const
627
632
{
628
- return ((copter. g2 . guided_options . get () & uint32_t (Options ::WPNavUsedForPosControl)) != 0 );
633
+ return option_is_enabled (Option ::WPNavUsedForPosControl);
629
634
}
630
635
631
636
// Sets guided's angular target submode: Using a rotation quaternion, angular velocity, and climbrate or thrust (depends on user option)
0 commit comments