PX4 / PX4-SITL_gazebo-classic

Set of plugins, models and worlds to use with OSRF Gazebo Simulator in SITL and HITL.

Home Page:http://dev.px4.io/simulation-gazebo.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The math behind the motor model plugin

AllenHuangDongyue opened this issue · comments

As mentioned by issue110 this issue, I got some questions about this model,

  1. What are the units of rotational speed we used in the model, rad/s?
  2. Why do we need the parameter (rotorVelocitySlowdownSim)?

I am going to contructure my own model based on this one, any suggestion will be welcomed!!

Many thanks!

The best place to start looking is the source code.

It seems that this line tells me that double force = real_motor_velocity * std::abs(real_motor_velocity) * motor_constant_; Since units of Force = [Mass] [ Length] [Time^-2], and motor_constant_ is [mass][Length] (This is derived in these notes), we can conclude that real_motor_velocity is [s-1], which would be in units of (rad/s).

As for the rotorVelocitySlowdownSim, I believe that when motor speed is higher than what the simulation can step through, it is used as part of anti-aliasing during simulation at (line 197)[https://github.com/PX4/PX4-SITL_gazebo-classic/blob/20ded0757b4f2cb362833538716caf1e938b162a/src/gazebo_motor_model.cpp#L197]:

  motor_rot_vel_ = joint_->GetVelocity(0);
  if (motor_rot_vel_ / (2 * M_PI) > 1 / (2 * sampling_time_)) {
    gzerr << "Aliasing on motor [" << motor_number_ << "] might occur. Consider making smaller simulation time steps or raising the rotor_velocity_slowdown_sim_ param.\n";
  }
  double real_motor_velocity = motor_rot_vel_ * rotor_velocity_slowdown_sim_;

This issue has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/gazebo-sdf-file-motor-parameters-definitions/34747/1