diff --git a/lib/HALSim/Encoders.cpp b/lib/HALSim/Encoders.cpp index b9c0be01..73d5488b 100644 --- a/lib/HALSim/Encoders.cpp +++ b/lib/HALSim/Encoders.cpp @@ -122,8 +122,9 @@ int16_t Encoders::calculateSteps(double lastPos, double pos) const /* Position sensor provides NAN until the first simulation step was perfomed. */ if (false == isnan(pos)) { - double deltaPos = (pos - lastPos) * 1000.0f; /* [mm] */ - double encoderSteps = deltaPos * static_cast(RobotConstants::ENCODER_STEPS_PER_MM); /* [steps] */ + const double CONV_FACTOR_M_TO_MM = 1000.0F; + double deltaPos = (pos - lastPos) * CONV_FACTOR_M_TO_MM; /* [mm] */ + double encoderSteps = deltaPos * static_cast(RobotConstants::ENCODER_STEPS_PER_MM); /* [steps] */ /* Simulate int16_t wrap around. */ if (static_cast(INT16_MAX) < encoderSteps) diff --git a/lib/HALSim/Motors.cpp b/lib/HALSim/Motors.cpp index c08e89f9..05ea1987 100644 --- a/lib/HALSim/Motors.cpp +++ b/lib/HALSim/Motors.cpp @@ -122,7 +122,7 @@ void Motors::initMotor(webots::Motor* motor) motor->setPosition(std::numeric_limits::infinity()); /* Stop motor, note velocity in m/s */ - motor->setVelocity(0.0f); + motor->setVelocity(0.0F); } } diff --git a/lib/Service/Odometry.cpp b/lib/Service/Odometry.cpp index 6760e281..28ad26f6 100644 --- a/lib/Service/Odometry.cpp +++ b/lib/Service/Odometry.cpp @@ -206,26 +206,26 @@ void Odometry::calculateDeltaPos(int16_t stepsCenter, int32_t orientation, int16 { int16_t distCenter = stepsCenter / static_cast(RobotConstants::ENCODER_STEPS_PER_MM); /* [mm] */ float fDistCenter = static_cast(distCenter); /* [mm] */ - float fOrientation = static_cast(orientation) / 1000.0f; /* [rad] */ + float fOrientation = static_cast(orientation) / 1000.0F; /* [rad] */ float fDeltaPosX = fDistCenter * cosf(fOrientation); /* [mm] */ float fDeltaPosY = fDistCenter * sinf(fOrientation); /* [mm] */ - if (0.0f <= fDeltaPosX) + if (0.0F <= fDeltaPosX) { - fDeltaPosX += 0.5f; + fDeltaPosX += 0.5F; } else { - fDeltaPosX -= 0.5f; + fDeltaPosX -= 0.5F; } - if (0.0f <= fDeltaPosY) + if (0.0F <= fDeltaPosY) { - fDeltaPosY += 0.5f; + fDeltaPosY += 0.5F; } else { - fDeltaPosY -= 0.5f; + fDeltaPosY -= 0.5F; } dX = static_cast(fDeltaPosX); /* [mm] */ diff --git a/platformio.ini b/platformio.ini index a713ca3e..45c7e4f7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,6 +27,21 @@ build_flags = -DTEAM_NAME_LINE_1="\"Radon\"" -DTEAM_NAME_LINE_2="\"Alcer\"" +; ***************************************************************************** +; Static check configuration +; ***************************************************************************** +[static_check_configuration] +check_tool = cppcheck, clangtidy +check_severity = medium, high +check_patterns = + include + src + lib +check_flags = + cppcheck: cppcheck: --suppress=*:*/libdeps/* --suppress=*:*lib/Webots/* --suppress=noExplicitConstructor --suppress=unusedFunction --std=c++11 + clangtidy: --header-filter='' --checks=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow --warnings-as-errors=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow +check_skip_packages = yes + ; ***************************************************************************** ; Target environment for Zumo32U4. ; ***************************************************************************** @@ -138,7 +153,7 @@ lib_ignore = ; Line follower application on target ; ***************************************************************************** [env:LineFollowerTarget] -extends = target:Zumo32U4, app:LineFollower +extends = target:Zumo32U4, app:LineFollower, static_check_configuration build_flags = ${target:Zumo32U4.build_flags} ${app:LineFollower.build_flags} @@ -150,18 +165,12 @@ lib_ignore = ${app:LineFollower.lib_ignore} extra_scripts = ${target:Zumo32U4.extra_scripts} -check_tool = cppcheck, clangtidy -check_severity = medium, high -check_flags = - cppcheck: --suppress=noExplicitConstructor --suppress=unusedFunction --suppress=*:*/libdeps/* - clangtidy: --checks=-*,clang-analyzer-*,performance-*,portability-*,bugprone-* --fix --header-filter=.* -check_skip_packages = yes ; ***************************************************************************** ; Line follower application on simulation ; ***************************************************************************** [env:LineFollowerSim] -extends = target:Sim, app:LineFollower +extends = target:Sim, app:LineFollower, static_check_configuration build_flags = ${target:Sim.build_flags} ${app:LineFollower.build_flags} @@ -173,21 +182,15 @@ lib_ignore = ${app:LineFollower.lib_ignore} extra_scripts = ${target:Sim.extra_scripts} -check_tool = cppcheck, clangtidy -check_severity = medium, high -check_flags = - cppcheck: --suppress=noExplicitConstructor --suppress=unusedFunction - clangtidy: --checks=-*,clang-analyzer-*,performance-*,portability-*,bugprone-* --fix --header-filter=.* -check_skip_packages = yes ; ***************************************************************************** ; Remote control application on target ; ***************************************************************************** [env:RemoteControlTarget] -extends = target:Zumo32U4, app:RemoteControl +extends = target:Zumo32U4, app:RemoteControl, static_check_configuration build_flags = ${target:Zumo32U4.build_flags} - ${app:RemoteControl.build_flags} + ${app:RemoteControl.build_flags} lib_deps = ${target:Zumo32U4.lib_deps} ${app:RemoteControl.lib_deps} @@ -196,18 +199,12 @@ lib_ignore = ${app:RemoteControl.lib_ignore} extra_scripts = ${target:Zumo32U4.extra_scripts} -check_tool = cppcheck, clangtidy -check_severity = medium, high -check_flags = - cppcheck: --suppress=noExplicitConstructor --suppress=unusedFunction --suppress=*:*/libdeps/* - clangtidy: --checks=-*,clang-analyzer-*,performance-*,portability-*,bugprone-* --fix --header-filter=.* -check_skip_packages = yes ; ***************************************************************************** ; Remote control application on simulation ; ***************************************************************************** [env:RemoteControlSim] -extends = target:Sim, app:RemoteControl +extends = target:Sim, app:RemoteControl, static_check_configuration build_flags = ${target:Sim.build_flags} ${app:RemoteControl.build_flags} @@ -219,18 +216,12 @@ lib_ignore = ${app:RemoteControl.lib_ignore} extra_scripts = ${target:Sim.extra_scripts} -check_tool = cppcheck, clangtidy -check_severity = medium, high -check_flags = - cppcheck: --suppress=noExplicitConstructor --suppress=unusedFunction - clangtidy: --checks=-*,clang-analyzer-*,performance-*,portability-*,bugprone-* --fix --header-filter=.* -check_skip_packages = yes ; ***************************************************************************** ; PC target environment for tests ; ***************************************************************************** [env:Test] -extends = target:Test +extends = target:Test, static_check_configuration build_flags = ${target:Test.build_flags} ${common.build_flags} @@ -240,9 +231,3 @@ lib_ignore = ${target:Test.lib_ignore} extra_scripts = ${target:Test.extra_scripts} -check_tool = cppcheck, clangtidy -check_severity = medium, high -check_flags = - cppcheck: --suppress=noExplicitConstructor --suppress=unusedFunction - clangtidy: --checks=-*,clang-analyzer-*,performance-*,portability-*,bugprone-* --fix --header-filter=.* -check_skip_packages = yes