Simulating individual components of the multirotor. These make up the final `Multirotor` object.
%% Cell type:markdown id:0505e4f6 tags:
#### Motor
%% Cell type:code id:b3128c10 tags:
``` python
%matplotlibinline
# Plot motor speeds as a function of time and input voltage signal
plt.figure(figsize=(8,8))
motor=Motor(mp,sp)
forvsignalin[2,4,6,8,10,12,14,16,18,20]:
speeds=[]
motor.reset()
speed=vsignal/mp.speed_voltage_scaling
foriinrange(200):
speeds.append(motor.step(speed))
plt.plot(speeds,label='%d rad/s'%speed)
plt.legend(ncol=2)
plt.ylabel('Speed rad/s')
plt.xlabel('Time /ms')
```
%% Cell type:markdown id:f3ddb119 tags:
Learning a linear relationship for the equation $V = k_{scaling} * speed$ for motors. This is useful for `SpeedsMultirotorEnv` which takes speed signals as the input. This constant converts speeds to applied voltages. The default value in`MotorParams` is 1, meaning the actions are voltage signals.
The propeller can use a numerically solved thrust relationship, where thrust depends on airspeed. Or the easier option of using thrust coefficient is available.
%% Cell type:code id:1669687b tags:
``` python
%matplotlibinline
# Plot propeller speed by numerically solving the thrust equation,
# *if* accurate propeller measurements are given in params
pp_=deepcopy(pp)
pp_.use_thrust_constant=False# Set to true to just use k_thrust
Then, defining a disturbance (for example, wind). The disturabance function takes time, `Multirotor`, and returns the forces in the *body frame* of the vehicle.