semvec/pypi-packages huggingface dataset:
quadx88 0.3.1
Configurable dynamical model of quadcopter
License: MIT License
Keywords: quadcopter


## QUADx88

Configurable dynamical model of quadcopter

## API documentation

### The `Quadcopter` Class


To construct a quadcopter object we can call the constructor


```python
import quadx88 as qx

copter = qx.Quadcopter(mass=1.15, 
                       ts=0.0083,
                       prop_mass=0.01)
```

The following parameters can be provided to the above constructor

| Parameter    | Description                     | Default   |
| ------------ | ------------------------------- | --------- |
| `ts`         | Sampling time (s)               | 1/125     |
| `mass`       | Total mass of the copter (kg)   | 1         |
| `arm_length` | Arm length (m)                  | 0.225     |
| `moi_xx`     | x-x moment of inertia           | 0.01788   |
| `moi_yy`     | x-x moment of inertia           | 0.03014   |
| `moi_zz`     | z-z moment of inertia           | 0.04614   |
| `gravity_acc`| gravitational acceleration (m/s2)| 9.81     |
| `air_density`| air density (kg/m3) | 1.225 |
| `K_v` | Kv constant of motors (rpm/V) | 1000 | 
| `motor_time_constant` | motor time constant (s) | 0.05 | 
| `rotor_mass` | rotor mass (kg) | 0.04 |
| `rotor_radius` | rotor radius (m) | 0.019 | 
| `motor_mass` | motor mass (kg) | 0.112 | 
| `voltage_max` | maximum voltage (V) | 16.8 |
| `voltage_min` | minimum voltage (V) | 15.0 |
| `thrust_coeff` | thrust coefficient of propellers  | 0.112 |
| `power_coeff` | power coefficient of propellers | 0.044 | 
| `prop_mass` | propeller mass (kg) | 0.009 | 
| `prop_diameter_in` | propeller diameter (inches) | 10 |

### Getters


| Method/Property | Description |
| ------------ | ------------- |
| `state`    | Nine dimensional state of the system, $x=(q, \omega, n)$ |
| `quaternion` | Current quaternion |
| `hover_rpm` | Hovering spin in RPM |
| `euler_angles()` | Current Euler angles in degrees |

### Setters 

To initialise the state of the system the following methods are available

1. `set_initial_quaternion(q)`, where `q` is the quaternion
2. `set_initial_angular_velocity(w)`
3. `set_initial_motor_spin(spin)`
4. `set_initial_euler_angles(yaw, pitch, roll, angle_unit=ANGLE_UNITS.RADIANS)`, where `yaw`, `pitch` and `roll` and the three Euler angles (in this order) and `angle_unit` is the units of measurement. For example to construct a quadcopter object with an initial attitude of $\phi=0^\circ$, $\theta=1^\circ$ and $\psi=-5^\circ$ we can do 

```python
copter = qx.Quadcopter()
copter.set_initial_euler_angles(-5, 0, 1, ANGLE_UNITS.DEGREES)
```

### System matrices 

The methods `continuous_linearised_matrices` and `discrete_linearised_matrices` return a dictionary with the continuous-time and discrete-time matrices of the linearised system respectively. The discrete-time linearised system has the form 
$$\begin{aligned}
x_{t+1} =& Ax_t + Bu_t,
\\
y_t =& Cx_t.
\end{aligned}$$


### Nonlinear dynamical system 

To simulate the nonlinear model you can use `move(u)` which updates the system state following the application of a given control action for the duration of the sampling time.