From 883d57b286e2405a1923d49c342d217d46ae136b Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 18 Feb 2024 10:33:45 +0000 Subject: [PATCH] Rover : class Mode : Add const attribute to some 'getter' member function signatures. --- Rover/mode.cpp | 14 +++++++------- Rover/mode.h | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Rover/mode.cpp b/Rover/mode.cpp index 6173ac337d..e54cc84f8a 100644 --- a/Rover/mode.cpp +++ b/Rover/mode.cpp @@ -56,7 +56,7 @@ bool Mode::enter() // decode pilot steering and throttle inputs and return in steer_out and throttle_out arguments // steering_out is in the range -4500 ~ +4500 with positive numbers meaning rotate clockwise // throttle_out is in the range -100 ~ +100 -void Mode::get_pilot_input(float &steering_out, float &throttle_out) +void Mode::get_pilot_input(float &steering_out, float &throttle_out) const { // no RC input means no throttle and centered steering if (rover.failsafe.bits & FAILSAFE_EVENT_THROTTLE) { @@ -102,7 +102,7 @@ void Mode::get_pilot_input(float &steering_out, float &throttle_out) // decode pilot steering and throttle inputs and return in steer_out and throttle_out arguments // steering_out is in the range -4500 ~ +4500 with positive numbers meaning rotate clockwise // throttle_out is in the range -100 ~ +100 -void Mode::get_pilot_desired_steering_and_throttle(float &steering_out, float &throttle_out) +void Mode::get_pilot_desired_steering_and_throttle(float &steering_out, float &throttle_out) const { // do basic conversion get_pilot_input(steering_out, throttle_out); @@ -130,7 +130,7 @@ void Mode::get_pilot_desired_steering_and_throttle(float &steering_out, float &t } // decode pilot steering and return steering_out and speed_out (in m/s) -void Mode::get_pilot_desired_steering_and_speed(float &steering_out, float &speed_out) +void Mode::get_pilot_desired_steering_and_speed(float &steering_out, float &speed_out) const { float desired_throttle; get_pilot_input(steering_out, desired_throttle); @@ -146,7 +146,7 @@ void Mode::get_pilot_desired_steering_and_speed(float &steering_out, float &spee } // decode pilot lateral movement input and return in lateral_out argument -void Mode::get_pilot_desired_lateral(float &lateral_out) +void Mode::get_pilot_desired_lateral(float &lateral_out) const { // no RC input means no lateral input if ((rover.failsafe.bits & FAILSAFE_EVENT_THROTTLE) || (rover.channel_lateral == nullptr)) { @@ -159,7 +159,7 @@ void Mode::get_pilot_desired_lateral(float &lateral_out) } // decode pilot's input and return heading_out (in cd) and speed_out (in m/s) -void Mode::get_pilot_desired_heading_and_speed(float &heading_out, float &speed_out) +void Mode::get_pilot_desired_heading_and_speed(float &heading_out, float &speed_out) const { // get steering and throttle in the -1 to +1 range float desired_steering = constrain_float(rover.channel_steer->norm_input_dz(), -1.0f, 1.0f); @@ -183,7 +183,7 @@ void Mode::get_pilot_desired_heading_and_speed(float &heading_out, float &speed_ // decode pilot roll and pitch inputs and return in roll_out and pitch_out arguments // outputs are in the range -1 to +1 -void Mode::get_pilot_desired_roll_and_pitch(float &roll_out, float &pitch_out) +void Mode::get_pilot_desired_roll_and_pitch(float &roll_out, float &pitch_out) const { if (channel_roll != nullptr) { roll_out = channel_roll->norm_input(); @@ -199,7 +199,7 @@ void Mode::get_pilot_desired_roll_and_pitch(float &roll_out, float &pitch_out) // decode pilot walking_height inputs and return in walking_height_out arguments // outputs are in the range -1 to +1 -void Mode::get_pilot_desired_walking_height(float &walking_height_out) +void Mode::get_pilot_desired_walking_height(float &walking_height_out) const { if (channel_walking_height != nullptr) { walking_height_out = channel_walking_height->norm_input(); diff --git a/Rover/mode.h b/Rover/mode.h index 0d7833de99..f166843ed0 100644 --- a/Rover/mode.h +++ b/Rover/mode.h @@ -138,24 +138,24 @@ protected: // decode pilot steering and throttle inputs and return in steer_out and throttle_out arguments // steering_out is in the range -4500 ~ +4500 with positive numbers meaning rotate clockwise // throttle_out is in the range -100 ~ +100 - void get_pilot_desired_steering_and_throttle(float &steering_out, float &throttle_out); + void get_pilot_desired_steering_and_throttle(float &steering_out, float &throttle_out) const; // decode pilot input steering and return steering_out and speed_out (in m/s) - void get_pilot_desired_steering_and_speed(float &steering_out, float &speed_out); + void get_pilot_desired_steering_and_speed(float &steering_out, float &speed_out) const; // decode pilot lateral movement input and return in lateral_out argument - void get_pilot_desired_lateral(float &lateral_out); + void get_pilot_desired_lateral(float &lateral_out) const; // decode pilot's input and return heading_out (in cd) and speed_out (in m/s) - void get_pilot_desired_heading_and_speed(float &heading_out, float &speed_out); + void get_pilot_desired_heading_and_speed(float &heading_out, float &speed_out) const; // decode pilot roll and pitch inputs and return in roll_out and pitch_out arguments // outputs are in the range -1 to +1 - void get_pilot_desired_roll_and_pitch(float &roll_out, float &pitch_out); + void get_pilot_desired_roll_and_pitch(float &roll_out, float &pitch_out) const; // decode pilot height inputs and return in height_out arguments // outputs are in the range -1 to +1 - void get_pilot_desired_walking_height(float &walking_height_out); + void get_pilot_desired_walking_height(float &walking_height_out) const; // high level call to navigate to waypoint void navigate_to_waypoint(); @@ -192,7 +192,7 @@ protected: // decode pilot steering and throttle inputs and return in steer_out and throttle_out arguments // steering_out is in the range -4500 ~ +4500 with positive numbers meaning rotate clockwise // throttle_out is in the range -100 ~ +100 - void get_pilot_input(float &steering_out, float &throttle_out); + void get_pilot_input(float &steering_out, float &throttle_out) const; void set_steering(float steering_value); // references to avoid code churn: @@ -745,7 +745,7 @@ protected: bool _loitering; // true if loitering at end of SRTL }; - + class ModeSteering : public Mode {