Skip to content

Commit

Permalink
Static checks separated as configuration. Number of checks increased.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Mar 26, 2023
1 parent 5e0149a commit 49e82dc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 46 deletions.
5 changes: 3 additions & 2 deletions lib/HALSim/Encoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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<double>(RobotConstants::ENCODER_STEPS_PER_MM); /* [steps] */

/* Simulate int16_t wrap around. */
if (static_cast<double>(INT16_MAX) < encoderSteps)
Expand Down
2 changes: 1 addition & 1 deletion lib/HALSim/Motors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void Motors::initMotor(webots::Motor* motor)
motor->setPosition(std::numeric_limits<double>::infinity());

/* Stop motor, note velocity in m/s */
motor->setVelocity(0.0f);
motor->setVelocity(0.0F);
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/Service/Odometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,26 @@ void Odometry::calculateDeltaPos(int16_t stepsCenter, int32_t orientation, int16
{
int16_t distCenter = stepsCenter / static_cast<int16_t>(RobotConstants::ENCODER_STEPS_PER_MM); /* [mm] */
float fDistCenter = static_cast<float>(distCenter); /* [mm] */
float fOrientation = static_cast<float>(orientation) / 1000.0f; /* [rad] */
float fOrientation = static_cast<float>(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<int16_t>(fDeltaPosX); /* [mm] */
Expand Down
57 changes: 21 additions & 36 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.
; *****************************************************************************
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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

0 comments on commit 49e82dc

Please sign in to comment.