mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
clang-tidy: fix issues (#26498)
This commit is contained in:
@@ -505,7 +505,7 @@ px4_sitl_default-clang:
|
|||||||
# To add manual exclusions, append to CLANG_TIDY_EXCLUDE_EXTRA below.
|
# To add manual exclusions, append to CLANG_TIDY_EXCLUDE_EXTRA below.
|
||||||
# Submodules are automatically excluded - no action needed when adding new ones.
|
# Submodules are automatically excluded - no action needed when adding new ones.
|
||||||
CLANG_TIDY_SUBMODULES := $(shell git config --file .gitmodules --get-regexp path | awk '{print $$2}' | tr '\n' '|' | sed 's/|$$//')
|
CLANG_TIDY_SUBMODULES := $(shell git config --file .gitmodules --get-regexp path | awk '{print $$2}' | tr '\n' '|' | sed 's/|$$//')
|
||||||
CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5|src/lib/drivers/smbus|src/drivers/gpio|src/modules/commander/failsafe/emscripten|failsafe_test\.dir
|
CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5|src/lib/drivers/smbus|src/drivers/gpio|src/modules/commander/failsafe/emscripten|failsafe_test\.dir|\.pb\.cc
|
||||||
CLANG_TIDY_EXCLUDE := $(CLANG_TIDY_SUBMODULES)|$(CLANG_TIDY_EXCLUDE_EXTRA)
|
CLANG_TIDY_EXCLUDE := $(CLANG_TIDY_SUBMODULES)|$(CLANG_TIDY_EXCLUDE_EXTRA)
|
||||||
|
|
||||||
clang-tidy: px4_sitl_default-clang
|
clang-tidy: px4_sitl_default-clang
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
// Direct Form II implementation
|
// Direct Form II implementation
|
||||||
T delay_element_0{sample - _delay_element_1 *_a1 - _delay_element_2 * _a2};
|
T delay_element_0{sample - _delay_element_1 *_a1 - _delay_element_2 * _a2};
|
||||||
|
|
||||||
const T output{delay_element_0 *_b0 + _delay_element_1 *_b1 + _delay_element_2 * _b2};
|
T output{delay_element_0 *_b0 + _delay_element_1 *_b1 + _delay_element_2 * _b2};
|
||||||
|
|
||||||
_delay_element_2 = _delay_element_1;
|
_delay_element_2 = _delay_element_1;
|
||||||
_delay_element_1 = delay_element_0;
|
_delay_element_1 = delay_element_0;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ Vector3f RateControl::update(const Vector3f &rate, const Vector3f &rate_sp, cons
|
|||||||
Vector3f rate_error = rate_sp - rate;
|
Vector3f rate_error = rate_sp - rate;
|
||||||
|
|
||||||
// PID control with feed forward
|
// PID control with feed forward
|
||||||
const Vector3f torque = _gain_p.emult(rate_error) + _rate_int - _gain_d.emult(angular_accel) + _gain_ff.emult(rate_sp);
|
Vector3f torque = _gain_p.emult(rate_error) + _rate_int - _gain_d.emult(angular_accel) + _gain_ff.emult(rate_sp);
|
||||||
|
|
||||||
// update integral only if we are not landed
|
// update integral only if we are not landed
|
||||||
if (!landed) {
|
if (!landed) {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ Vector4f MecanumActControl::computeInverseKinematics(float throttle_body_x, floa
|
|||||||
const Matrix<float, 3, 1> input(input_data);
|
const Matrix<float, 3, 1> input(input_data);
|
||||||
const float m_data[12] = {1.f, -1.f, -1.f, 1.f, 1.f, 1.f, 1.f, 1.f, -1.f, 1.f, -1.f, 1.f};
|
const float m_data[12] = {1.f, -1.f, -1.f, 1.f, 1.f, 1.f, 1.f, 1.f, -1.f, 1.f, -1.f, 1.f};
|
||||||
const Matrix<float, 4, 3> m(m_data);
|
const Matrix<float, 4, 3> m(m_data);
|
||||||
const Vector4f motor_commands = m * input;
|
Vector4f motor_commands = m * input;
|
||||||
|
|
||||||
return motor_commands;
|
return motor_commands;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ protected:
|
|||||||
// Use trapezoidal integration to calculate the delta integral
|
// Use trapezoidal integration to calculate the delta integral
|
||||||
_integrated_samples++;
|
_integrated_samples++;
|
||||||
_integral_dt += dt;
|
_integral_dt += dt;
|
||||||
const matrix::Vector3f delta_alpha{(val + _last_val) *dt * 0.5f};
|
matrix::Vector3f delta_alpha{(val + _last_val) *dt * 0.5f};
|
||||||
_last_val = val;
|
_last_val = val;
|
||||||
|
|
||||||
return delta_alpha;
|
return delta_alpha;
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ void BuoyancyPrivate::CheckForNewEntities(const EntityComponentManager &_ecm)
|
|||||||
[&](const Entity & _entity,
|
[&](const Entity & _entity,
|
||||||
const components::Link *,
|
const components::Link *,
|
||||||
const components::Inertial *) -> bool {
|
const components::Inertial *) -> bool {
|
||||||
if (this->basicBuoyancy == true) return true;
|
if (this->basicBuoyancy == true) { return true; }
|
||||||
// Skip if the entity already has a volume and center of volume
|
// Skip if the entity already has a volume and center of volume
|
||||||
if (_ecm.EntityHasComponentType(_entity,
|
if (_ecm.EntityHasComponentType(_entity,
|
||||||
components::CenterOfVolume().TypeId()) &&
|
components::CenterOfVolume().TypeId()) &&
|
||||||
|
|||||||
@@ -334,16 +334,18 @@ void SpacecraftThrusterModelPrivate::UpdateForcesAndMoments(
|
|||||||
// d: cycle period
|
// d: cycle period
|
||||||
double targetDutyCycle = normalizedInput * (1.0 / this->dutyCycleFrequency);
|
double targetDutyCycle = normalizedInput * (1.0 / this->dutyCycleFrequency);
|
||||||
|
|
||||||
if (this->actuatorNumber == 0)
|
if (this->actuatorNumber == 0) {
|
||||||
gzdbg << this->actuatorNumber
|
gzdbg << this->actuatorNumber
|
||||||
<< ": target duty cycle: " << targetDutyCycle << std::endl;
|
<< ": target duty cycle: " << targetDutyCycle << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate cycle start time
|
// Calculate cycle start time
|
||||||
if (this->samplingTime >= 1.0 / this->dutyCycleFrequency) {
|
if (this->samplingTime >= 1.0 / this->dutyCycleFrequency) {
|
||||||
if (this->actuatorNumber == 0)
|
if (this->actuatorNumber == 0) {
|
||||||
gzdbg << this->actuatorNumber
|
gzdbg << this->actuatorNumber
|
||||||
<< ": Cycle completed. Resetting cycle start time."
|
<< ": Cycle completed. Resetting cycle start time."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
this->cycleStartTime = this->simTime;
|
this->cycleStartTime = this->simTime;
|
||||||
}
|
}
|
||||||
@@ -351,22 +353,24 @@ void SpacecraftThrusterModelPrivate::UpdateForcesAndMoments(
|
|||||||
// Calculate sampling time instant within the cycle
|
// Calculate sampling time instant within the cycle
|
||||||
this->samplingTime = this->simTime - this->cycleStartTime;
|
this->samplingTime = this->simTime - this->cycleStartTime;
|
||||||
|
|
||||||
if (this->actuatorNumber == 0)
|
if (this->actuatorNumber == 0) {
|
||||||
gzdbg << this->actuatorNumber
|
gzdbg << this->actuatorNumber
|
||||||
<< ": PWM Period: " << 1.0 / this->dutyCycleFrequency
|
<< ": PWM Period: " << 1.0 / this->dutyCycleFrequency
|
||||||
<< " Cycle Start time: " << this->cycleStartTime
|
<< " Cycle Start time: " << this->cycleStartTime
|
||||||
<< " Sampling time: " << this->samplingTime << std::endl;
|
<< " Sampling time: " << this->samplingTime << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply force if the sampling time is less than the target ON duty cycle
|
// Apply force if the sampling time is less than the target ON duty cycle
|
||||||
double force = this->samplingTime <= targetDutyCycle ? this->maxThrust : 0.0;
|
double force = this->samplingTime <= targetDutyCycle ? this->maxThrust : 0.0;
|
||||||
|
|
||||||
if (targetDutyCycle < 1e-9) { force = 0.0; }
|
if (targetDutyCycle < 1e-9) { force = 0.0; }
|
||||||
|
|
||||||
if (this->actuatorNumber == 0)
|
if (this->actuatorNumber == 0) {
|
||||||
gzdbg << this->actuatorNumber
|
gzdbg << this->actuatorNumber
|
||||||
<< ": Force: " << force
|
<< ": Force: " << force
|
||||||
<< " Sampling time: " << this->samplingTime
|
<< " Sampling time: " << this->samplingTime
|
||||||
<< " Tgt duty cycle: " << targetDutyCycle << std::endl;
|
<< " Tgt duty cycle: " << targetDutyCycle << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply force to the link
|
// Apply force to the link
|
||||||
Link link(this->linkEntity);
|
Link link(this->linkEntity);
|
||||||
@@ -374,10 +378,11 @@ void SpacecraftThrusterModelPrivate::UpdateForcesAndMoments(
|
|||||||
link.AddWorldForce(_ecm,
|
link.AddWorldForce(_ecm,
|
||||||
worldPose->Rot().RotateVector(math::Vector3d(0, 0, force)));
|
worldPose->Rot().RotateVector(math::Vector3d(0, 0, force)));
|
||||||
|
|
||||||
if (this->actuatorNumber == 0)
|
if (this->actuatorNumber == 0) {
|
||||||
gzdbg << this->actuatorNumber
|
gzdbg << this->actuatorNumber
|
||||||
<< ": Input Value: " << msg->velocity(this->actuatorNumber)
|
<< ": Input Value: " << msg->velocity(this->actuatorNumber)
|
||||||
<< " Calc. Force: " << force << std::endl;
|
<< " Calc. Force: " << force << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GZ_ADD_PLUGIN(SpacecraftThrusterModel,
|
GZ_ADD_PLUGIN(SpacecraftThrusterModel,
|
||||||
|
|||||||
Reference in New Issue
Block a user