Commit d58939a7 authored by Ibrahim's avatar Ibrahim
Browse files

bugfix: immutable default dataclass value;

Made inertia_matrix attribute of multirotor.vehicle.VehicleParams a required parameter,
instead of assigning a np.ndarray default value if it were an optional parameter. Np arrays
are mutable. See: https://stackoverflow.com/q/53632152/4591810
parent 6d6a21d9
Loading
Loading
Loading
Loading
+15 −2
Changes for README.md: 15 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@

Simulation of multi-rotor unmanned aerial vehicles in python.

This package provides an object-oriented interface for modeling and simulating motors, propellers, and airframe of a UAV. Additionally, an OpenAI gym-compatible environment is provided for Reinforcement Learning experiments.

See the [Detailed Demo](./Detailed%20Demo.ipynb) jupyter notebbok for a walkthrough.

Please cite this as:

```
@@ -18,14 +22,23 @@ Please cite this as:

Install from the Python Package Index (PyPI):

```
```bash
pip install multirotor
```

Or, clone repository and install for development. This will allow you to change the code of the package so the changes show up when you `import multirotor` in other projects.

```
```bash
git clone https://github.com/hazrmard/multirotor.git
cd multirotor
pip install -e .

# to also install dependencies for building package/documentation
pip install -e .[DEV]
```

## Usage

```python

```
 No newline at end of file
+6 −6
Changes for multirotor/vehicle.py: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ class BatteryParams:
@dataclass
class VehicleParams:

    mass: float
    "The total mass of the vehicle"
    # TODO: Should moments of inertia of propeller motors be added to this matrix
    # manually? Currently we assume this represents the whole vehicle.
    inertia_matrix: np.ndarray
    "3x3 intertia matrix describing the rotational properties of the body."
    propellers: List[PropellerParams]
    angles: np.ndarray
    "Angle (radians) of propeller arm from the positive x-axis (forward) of the body frame."
@@ -107,14 +113,8 @@ class VehicleParams:
    clockwise: np.ndarray = None
    """1 if motor spins clockwise, -1 if anti-clockwise, looking from the top.
    Defaults to alternating clockwise/anti-clockwise."""

    battery: BatteryParams = None
    "The battery parameters"
    mass: float = 1.
    # TODO: Should moments of inertia of propeller motors be added to this matrix
    # manually? Currently we assume this represents the whole vehicle.
    inertia_matrix: np.matrix = np.eye(3)
    "3x3 intertia matrix describing the rotational properties of the body."


    def __post_init__(self):