Skip to content

Commit

Permalink
control: reduce default control update frequency (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeLaine authored May 16, 2024
1 parent 5ec96ae commit b11608e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DirectActuatorsSetpointType : public SetpointBase
~DirectActuatorsSetpointType() override = default;

Configuration getConfiguration() override;
float desiredUpdateRateHz() override {return 500.f;}
float desiredUpdateRateHz() override {return 200.f;}

/**
* Send servos setpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AttitudeSetpointType : public SetpointBase
~AttitudeSetpointType() override = default;

Configuration getConfiguration() override;
float desiredUpdateRateHz() override {return 200.f;}
float desiredUpdateRateHz() override {return 100.f;}

void update(
const Eigen::Quaternionf & attitude_setpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RatesSetpointType : public SetpointBase
~RatesSetpointType() override = default;

Configuration getConfiguration() override;
float desiredUpdateRateHz() override {return 500.f;}
float desiredUpdateRateHz() override {return 200.f;}

void update(
const Eigen::Vector3f & rate_setpoints_ned_rad,
Expand Down
5 changes: 4 additions & 1 deletion px4_ros2_cpp/src/components/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ bool ModeBase::onRegistered()
// TODO: check setpoint types compatibility with current vehicle type

activateSetpointType(*_setpoint_types[0]);
setSetpointUpdateRateFromSetpointTypes();
if (_setpoint_update_rate_hz < FLT_EPSILON) {
// Do not use default setpoint rate if rate was already set by user
setSetpointUpdateRateFromSetpointTypes();
}

return true;
}
Expand Down

0 comments on commit b11608e

Please sign in to comment.