Skip to content

Commit

Permalink
Parameterize maximum relative air velocity for generating thrust on t…
Browse files Browse the repository at this point in the history
…he motors (#1045)

* Parameterize maximum relative airspeed

* Add maximum relative airspeed to sdf
  • Loading branch information
Jaeyoung-Lim authored Jun 17, 2024
1 parent 93b45ad commit 7dc8042
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/gazebo_motor_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static constexpr double kDefaulMaxRotVelocity = 838.0;
static constexpr double kDefaultRotorDragCoefficient = 1.0e-4;
static constexpr double kDefaultRollingMomentCoefficient = 1.0e-6;
static constexpr double kDefaultRotorVelocitySlowdownSim = 10.0;
static constexpr double kDefaultMaxRelativeAirspeed = 25.0;

class GazeboMotorModel : public MotorModel, public ModelPlugin {
public:
Expand Down Expand Up @@ -118,6 +119,7 @@ class GazeboMotorModel : public MotorModel, public ModelPlugin {
double rotor_velocity_slowdown_sim_{kDefaultRotorVelocitySlowdownSim};
double time_constant_down_{kDefaultTimeConstantDown};
double time_constant_up_{kDefaultTimeConstantUp};
double max_relative_airspeed_{kDefaultMaxRelativeAirspeed};

bool reversible_{false};

Expand Down
4 changes: 2 additions & 2 deletions src/gazebo_motor_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void GazeboMotorModel::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) {
getSdfParam<double>(_sdf, "rollingMomentCoefficient", rolling_moment_coefficient_,
rolling_moment_coefficient_);
getSdfParam<double>(_sdf, "maxRotVelocity", max_rot_velocity_, max_rot_velocity_);
getSdfParam<double>(_sdf, "maxRelativeAirspeed", max_relative_airspeed_, max_relative_airspeed_);
getSdfParam<double>(_sdf, "motorConstant", motor_constant_, motor_constant_);
getSdfParam<double>(_sdf, "momentConstant", moment_constant_, moment_constant_);

Expand Down Expand Up @@ -217,8 +218,7 @@ void GazeboMotorModel::UpdateForcesAndMoments() {

ignition::math::Vector3d relative_wind_velocity = body_velocity - wind_vel_;
ignition::math::Vector3d velocity_parallel_to_rotor_axis = (relative_wind_velocity.Dot(joint_axis)) * joint_axis;
double vel = velocity_parallel_to_rotor_axis.Length();
double scalar = 1 - vel / 25.0; // at 25 m/s the rotor will not produce any force anymore
double scalar = 1 - velocity_parallel_to_rotor_axis.Length() / max_relative_airspeed_; // at 25 m/s the rotor will not produce any force anymore
scalar = ignition::math::clamp(scalar, 0.0, 1.0);
// Apply a force to the link.
link_->AddRelativeForce(ignition::math::Vector3d(0, 0, force * scalar));
Expand Down

0 comments on commit 7dc8042

Please sign in to comment.