utiasDSL / gym-pybullet-drones

PyBullet Gymnasium environments for single and multi-agent reinforcement learning of quadcopter control
https://utiasDSL.github.io/gym-pybullet-drones/
MIT License
1.27k stars 372 forks source link

Controlling Crazyflie through RPMs (PWM) #244

Open piratax007 opened 2 weeks ago

piratax007 commented 2 weeks ago

Hello, I have successfully trained a policy for setpoint tracking using RPM as action space. Now I'm trying to deploy it to a real Crazyflie using a ROS2 package (Crazywarm and Vicon system). As you refer to in #118, exists an empirical study of the relation between PWM and RPMs for Crazyflie (https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/functional-areas/pwm-to-thrust/). My question, is that using the data from that study and comparing with the transformation used by GymPybullet I found high discrepancies as is shown in the plot. The black line corresponds with the linear transformation used by GymPybyllet. Crazyflie_RPM_vs_PWM Could you help me to understand this and how can affect the transferability of the trained policy to a real drone?

Thank you so much

JacopoPan commented 9 hours ago

The relation between RPMs and thrust in gym-pybullet-drones is modeled as quadratic: https://github.com/utiasDSL/gym-pybullet-drones/blob/3d7b12edd4915a27e6cec9f2c0eb4b5479f7735e/gym_pybullet_drones/envs/BaseAviary.py#L693-L694

There assumption of linearly between RPMs and PWM (that don't fully hold away from a hover range) in DSLPIDControl.py and CFAviary.py but those shouldn't come into play if you purely trained RL for RPMs in a class derived from BaseRLAviary.py