Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The math behind the motor model plugin #995

Open
AllenHuangDongyue opened this issue Jul 18, 2023 · 2 comments
Open

The math behind the motor model plugin #995

AllenHuangDongyue opened this issue Jul 18, 2023 · 2 comments

Comments

@AllenHuangDongyue
Copy link

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!

@JohnTGZ
Copy link

JohnTGZ commented Sep 7, 2023

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_;

@DronecodeBot
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants