Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add few compiler warning flags to error #219

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(control_toolbox LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format)
endif()

if(WIN32)
Expand Down
18 changes: 9 additions & 9 deletions src/limited_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ double LimitedProxy::update(
{
// Get the parameters. This ensures that they can not change during
// the calculations and are non-negative!
double mass = abs(mass_); // Estimate of the joint mass
double Kd = abs(Kd_); // Damping gain
double Kp = abs(Kp_); // Position gain
double Ki = abs(Ki_); // Integral gain
double Ficl = abs(Ficl_); // Integral force clamp
double Flim = abs(effort_limit_); // Limit on output force
double vlim = abs(vel_limit_); // Limit on velocity
double lam = abs(lambda_proxy_); // Bandwidth of proxy reconvergence
double acon = abs(acc_converge_); // Acceleration of proxy reconvergence
double mass = std::abs(mass_); // Estimate of the joint mass
double Kd = std::abs(Kd_); // Damping gain
double Kp = std::abs(Kp_); // Position gain
double Ki = std::abs(Ki_); // Integral gain
double Ficl = std::abs(Ficl_); // Integral force clamp
double Flim = std::abs(effort_limit_); // Limit on output force
double vlim = std::abs(vel_limit_); // Limit on velocity
double lam = std::abs(lambda_proxy_); // Bandwidth of proxy reconvergence
double acon = std::abs(acc_converge_); // Acceleration of proxy reconvergence

// For numerical stability, upper bound the bandwidth by 2/dt.
// Note this is safe for dt==0.
Expand Down
4 changes: 2 additions & 2 deletions src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ double Pid::computeCommand(double error, uint64_t dt)
error_dot_ = d_error_;

// Calculate the derivative error
error_dot_ = (error - p_error_last_) / (dt / 1e9);
error_dot_ = (error - p_error_last_) / (static_cast<double>(dt) / 1e9);
p_error_last_ = error;

return computeCommand(error, error_dot_, dt);
Expand All @@ -155,7 +155,7 @@ double Pid::computeCommand(double error, double error_dot, uint64_t dt)
p_term = gains.p_gain_ * p_error_;

// Calculate the integral of the position error
i_error_ += (dt / 1e9) * p_error_;
i_error_ += (static_cast<double>(dt) / 1e9) * p_error_;
saikishor marked this conversation as resolved.
Show resolved Hide resolved

if (gains.antiwindup_ && gains.i_gain_ != 0) {
// Prevent i_error_ from climbing higher than permitted by i_max_/i_min_
Expand Down
Loading