Open samdrew opened 3 weeks ago
Comparing the code from ardupilot_gazebo plugin to the code from aeroloop_gazebo (based on an earlier version of ardupilot), it is likely just the multiplier
in ardupilot_gazebo that needs adjusting, although the exact parameters are unclear.
ardupilot_gazebo:src/ArduPilotPlugin:1634
// convert pwm to raw cmd: [servo_min, servo_max] => [0, 1],
// default is: [1000, 2000] => [0, 1]
const double pwm = _pwm[this->dataPtr->controls[i].channel];
const double pwm_min = this->dataPtr->controls[i].servo_min;
const double pwm_max = this->dataPtr->controls[i].servo_max;
const double multiplier = this->dataPtr->controls[i].multiplier;
const double offset = this->dataPtr->controls[i].offset;
// bound incoming cmd between 0 and 1
double raw_cmd = (pwm - pwm_min)/(pwm_max - pwm_min);
raw_cmd = gz::math::clamp(raw_cmd, 0.0, 1.0);
this->dataPtr->controls[i].cmd =
multiplier * (raw_cmd + offset);
aeroloop_plugin:src/BetaflightPlugin:588
if (i < MAX_MOTORS)
{
// std::cout << i << ": " << pkt.motorSpeed[i] << "\n";
this->dataPtr->rotors[i].cmd = this->dataPtr->rotors[i].maxRpm *
pkt.motorSpeed[i];
}
Where maxRpm is double maxRpm = 838.0
Low throttle angular velocity: 197.168 High throttle angular velocity: 620.872
(Selecting rotor_0 and looking at Angular Velocity property of model element)
From aeroloop_gazebo, RADSEC2RPM = 9.549296585513721
Iris Model MaxRPM is 838.
Changing multiplier in control channels doesn't impact rotor velocity.
Given this isn't being impacted by the multiplier, it would be worth looking at the input levels. The template code (from ardupilot) was using an entirely different input scheme, and I'm unsure how much was done to convert. Other possibilities include the aforementioned RADSEC2RPM conversion.
Regardless 838RPM as stated in code seems extremely low for an actual quadcopter, particularly when the real-life iris uses T-Motor 9545 Props with optimum thrust in the range 6000-7000RPM.
Issue isn't (specifically) with the rotation speed, as testing with iris_runway.sdf and Ardupilot SITL, the hover velocity is approximately 450rad/sec. As such takeoff should be successful at 620. Given that the throttle and propeller rotation do impact the flight characteristics (as seen by comparing the flight behaviour of the craft by increasing its Z-position while rotors under thrust), the underlying cause of this is unclear and needs further investigation.
To check:
Issue confirmed, all rotors have positive angular velocity.
The current settings and limits coming from the Betaflight FC are being interpreted such that even with the PWM output at full, the motors are still not spinning enough to enable flight.