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

High Thrust Calculation in Motor Model Plugin #2637

Open
Kametor opened this issue Oct 1, 2024 · 2 comments
Open

High Thrust Calculation in Motor Model Plugin #2637

Kametor opened this issue Oct 1, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Kametor
Copy link

Kametor commented Oct 1, 2024

Environment

  • OS Version: Ubuntu 22.04
  • Gazebo Harmonic

Description

  • There may be a misunderstanding or misuse of the Gazebo motor model plugin parameters. Specifically, the “maxRotVelocity” parameter, which is described as the “Maximum rotational velocity command in units of rad/s”, seems to be leading to unintended results in the thrust calculation.
    The thrust force is computed using the following equation:

thrust = realMotorVelocity * realMotorVelocity * this->motorConstant;
Here, the variable realMotorVelocity is defined as:

double realMotorVelocity = motorRotVel * this->rotorVelocitySlowdownSim;
Consequently, at full throttle, the resulting force calculation is:

(maxRotVelocity * 10)^2 * motorConstant.
Based on my calculations, the resulting force in Gazebo appears significantly higher than expected. I am uncertain if I am misinterpreting a specific aspect of the model or if there is an issue with the parameter setup. In my calculation the thrust force is very high. Also drone climbs very fast. I think there is a problem. Any guidance or insight into this discrepancy would be greatly appreciated.

@Kametor Kametor added the bug Something isn't working label Oct 1, 2024
@Kametor
Copy link
Author

Kametor commented Oct 1, 2024

As observed, the ESC PWM values are approximately 250, while the joystick input remains below the halfway mark. Despite this moderate input, the drone exhibits rapid ascent behavior. The custom parameters currently in use are as follows:

<plugin filename="gz-sim-multicopter-motor-model-system" name="gz::sim::systems::MulticopterMotorModel">
  <jointName>rotor_0_joint</jointName>
  <linkName>rotor_0</linkName>
  <turningDirection>ccw</turningDirection>
  <timeConstantUp>0.0125</timeConstantUp>
  <timeConstantDown>0.025</timeConstantDown>
  <maxRotVelocity>313.0</maxRotVelocity>
  <motorConstant>830.0e-06</motorConstant>
  <momentConstant>0.03</momentConstant>
  <commandSubTopic>command/motor_speed</commandSubTopic>
  <motorNumber>0</motorNumber>
  <rotorDragCoefficient>0.001</rotorDragCoefficient>
  <rollingMomentCoefficient>0.001</rollingMomentCoefficient>
  <rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
  <motorType>velocity</motorType>
</plugin>

Additionally, the drone has a total weight of 45 kg.
high_thrust

@azeey
Copy link
Contributor

azeey commented Dec 16, 2024

This is my understanding:

Joint velocity assignment

  1. Commanded rotor velocity is assigned to refMotorInput
    this->refMotorInput = std::min(
    static_cast<double>(msg->velocity(this->actuatorNumber)),
    static_cast<double>(this->maxRotVelocity));
  2. This velocity is filtered (refMotorRotVel) to fullfil the time constant parameters specified
    double refMotorRotVel;
    refMotorRotVel = this->rotorVelocityFilter->UpdateFilter(
    this->refMotorInput, this->samplingTime);
  3. refMotorRotVel/rotorVelocitySlowDownSim is assigned as the actual commanded velocity on the joint
    _ecm.SetComponentData<components::JointVelocityCmd>(
    this->jointEntity,
    {this->turningDirection * refMotorRotVel
    / this->rotorVelocitySlowdownSim});

Thrust Calculation

  1. The current joint velocity is obtained from the ECM and multiplied by rotorVelocitySlowDownSim to get the reference motor velocity (realMotorVelocity). In steady state, this should be the same as refMotorInput. In full throttle, this would be motorRotVel.
    const auto jointVelocity = _ecm.Component<components::JointVelocity>(
    this->jointEntity);
    double motorRotVel = jointVelocity->Data()[0];
    if (motorRotVel / (2 * GZ_PI) > 1 / (2 * this->samplingTime))
    {
    gzerr << "Aliasing on motor [" << this->actuatorNumber
    << "] might occur. Consider making smaller simulation time "
    "steps or raising the rotorVelocitySlowdownSim param.\n";
    }
    double realMotorVelocity =
    motorRotVel * this->rotorVelocitySlowdownSim;
  2. Thrust is calculated as a constant times a signed realMotorVelocity^2.
    double thrust = this->turningDirection * realMotorVelocitySign *
    realMotorVelocity * realMotorVelocity *
    this->motorConstant;

One difference in your analysis is

Consequently, at full throttle, the resulting force calculation is:

(maxRotVelocity * 10)^2 * motorConstant.

I think it should be (maxRotVelocity)^2 * motorConstant since the velocity used in the thrust calculation is in the same order of magnitude as the input rotor velocity refMotorInput, i.e, rotorVelocitySlowdownSim cancels out when calculating realMotorVelocity.

@azeey azeey self-assigned this Dec 16, 2024
@azeey azeey moved this from Inbox to In progress in Core development Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In progress
Development

No branches or pull requests

2 participants