clang-tidy: enable performance-unnecessary-value-param and fix

This commit is contained in:
Daniel Agar
2019-10-27 17:06:14 -04:00
parent 4a7a9a1ba9
commit d545825bf0
5 changed files with 15 additions and 15 deletions

View File

@@ -85,7 +85,6 @@ Checks: '*,
-modernize-use-override, -modernize-use-override,
-modernize-use-using, -modernize-use-using,
-performance-inefficient-string-concatenation, -performance-inefficient-string-concatenation,
-performance-unnecessary-value-param,
-readability-avoid-const-params-in-decls, -readability-avoid-const-params-in-decls,
-readability-braces-around-statements, -readability-braces-around-statements,
-readability-container-size-empty, -readability-container-size-empty,

View File

@@ -38,7 +38,7 @@
using namespace matrix; using namespace matrix;
void ManualVelocitySmoothingXY::reset(Vector2f accel, Vector2f vel, Vector2f pos) void ManualVelocitySmoothingXY::reset(const Vector2f &accel, const Vector2f &vel, const Vector2f &pos)
{ {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
_trajectory[i].reset(accel(i), vel(i), pos(i)); _trajectory[i].reset(accel(i), vel(i), pos(i));
@@ -54,7 +54,7 @@ void ManualVelocitySmoothingXY::resetPositionLock()
_position_setpoint_locked(1) = NAN; _position_setpoint_locked(1) = NAN;
} }
void ManualVelocitySmoothingXY::update(float dt, Vector2f velocity_target) void ManualVelocitySmoothingXY::update(float dt, const Vector2f &velocity_target)
{ {
// Update state // Update state
updateTrajectories(dt); updateTrajectories(dt);
@@ -79,7 +79,7 @@ void ManualVelocitySmoothingXY::updateTrajectories(float dt)
} }
} }
void ManualVelocitySmoothingXY::updateTrajDurations(Vector2f velocity_target) void ManualVelocitySmoothingXY::updateTrajDurations(const Vector2f &velocity_target)
{ {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
_trajectory[i].updateDurations(velocity_target(i)); _trajectory[i].updateDurations(velocity_target(i));
@@ -88,7 +88,7 @@ void ManualVelocitySmoothingXY::updateTrajDurations(Vector2f velocity_target)
VelocitySmoothing::timeSynchronization(_trajectory, 2); VelocitySmoothing::timeSynchronization(_trajectory, 2);
} }
void ManualVelocitySmoothingXY::checkPositionLock(Vector2f velocity_target) void ManualVelocitySmoothingXY::checkPositionLock(const Vector2f &velocity_target)
{ {
/** /**
* During a position lock -> position unlock transition, we have to make sure that the velocity setpoint * During a position lock -> position unlock transition, we have to make sure that the velocity setpoint

View File

@@ -50,10 +50,10 @@ public:
ManualVelocitySmoothingXY() = default; ManualVelocitySmoothingXY() = default;
~ManualVelocitySmoothingXY() = default; ~ManualVelocitySmoothingXY() = default;
void reset(Vector2f accel, Vector2f vel, Vector2f pos); void reset(const Vector2f &accel, const Vector2f &vel, const Vector2f &pos);
void update(float dt, Vector2f velocity_target); void update(float dt, const Vector2f &velocity_target);
void setVelSpFeedback(const Vector2f fb) { _velocity_setpoint_feedback = fb; } void setVelSpFeedback(const Vector2f &fb) { _velocity_setpoint_feedback = fb; }
void setMaxJerk(const float max_jerk) void setMaxJerk(const float max_jerk)
{ {
@@ -79,7 +79,7 @@ public:
Vector2f getCurrentJerk() const { return _state.j; } Vector2f getCurrentJerk() const { return _state.j; }
Vector2f getCurrentAcceleration() const { return _state.a; } Vector2f getCurrentAcceleration() const { return _state.a; }
void setCurrentVelocity(const Vector2f vel) void setCurrentVelocity(const Vector2f &vel)
{ {
_state.v = vel; _state.v = vel;
_trajectory[0].setCurrentVelocity(vel(0)); _trajectory[0].setCurrentVelocity(vel(0));
@@ -87,7 +87,7 @@ public:
} }
Vector2f getCurrentVelocity() const { return _state.v; } Vector2f getCurrentVelocity() const { return _state.v; }
void setCurrentPosition(const Vector2f pos) void setCurrentPosition(const Vector2f &pos)
{ {
_state.x = pos; _state.x = pos;
_trajectory[0].setCurrentPosition(pos(0)); _trajectory[0].setCurrentPosition(pos(0));
@@ -96,13 +96,13 @@ public:
} }
Vector2f getCurrentPosition() const { return _position_setpoint_locked; } Vector2f getCurrentPosition() const { return _position_setpoint_locked; }
void setCurrentPositionEstimate(Vector2f pos) { _position_estimate = pos; } void setCurrentPositionEstimate(const Vector2f &pos) { _position_estimate = pos; }
private: private:
void resetPositionLock(); void resetPositionLock();
void updateTrajectories(float dt); void updateTrajectories(float dt);
void checkPositionLock(Vector2f velocity_target); void checkPositionLock(const Vector2f &velocity_target);
void updateTrajDurations(Vector2f velocity_target); void updateTrajDurations(const Vector2f &velocity_target);
VelocitySmoothing _trajectory[2]; ///< Trajectory in x and y directions VelocitySmoothing _trajectory[2]; ///< Trajectory in x and y directions

View File

@@ -66,7 +66,7 @@ void RateControl::setSaturationStatus(const MultirotorMixer::saturation_status &
_mixer_saturation_negative[2] = status.flags.yaw_neg; _mixer_saturation_negative[2] = status.flags.yaw_neg;
} }
Vector3f RateControl::update(const Vector3f rate, const Vector3f rate_sp, const float dt, const bool landed) Vector3f RateControl::update(const Vector3f &rate, const Vector3f &rate_sp, const float dt, const bool landed)
{ {
// angular rates error // angular rates error
Vector3f rate_error = rate_sp - rate; Vector3f rate_error = rate_sp - rate;

View File

@@ -93,7 +93,8 @@ public:
* @param dt desired vehicle angular rate setpoint * @param dt desired vehicle angular rate setpoint
* @return [-1,1] normalized torque vector to apply to the vehicle * @return [-1,1] normalized torque vector to apply to the vehicle
*/ */
matrix::Vector3f update(const matrix::Vector3f rate, const matrix::Vector3f rate_sp, const float dt, const bool landed); matrix::Vector3f update(const matrix::Vector3f &rate, const matrix::Vector3f &rate_sp, const float dt,
const bool landed);
/** /**
* Set the integral term to 0 to prevent windup * Set the integral term to 0 to prevent windup