Commit 67aa745d authored by Ibrahim's avatar Ibrahim
Browse files

Added options to visualization

parent 8fedf4ed
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -302,6 +302,10 @@ class DataLog:
        return self.track(vehicle, controller, other_vars)
    

    def __bool__(self):
        return True


    def track(self, vehicle, controller, other_vars=None):
        """
        Register Multirotor and Controller instances to track, along with names
@@ -429,12 +433,12 @@ class DataLog:
        if relative:
            # last_pos = self.position[old_len - 1]
            if not self._arrayed:
                last_time = self._times[old_len - 1]
                last_time = self._times[old_len - 1] if old_len > 0 else 0
                for i in range(old_len, len(self)):
                        # self._states[i][:3] += last_pos
                        self._times[i] += last_time
            elif self._arrayed:
                last_time = self.times[old_len - 1]
                last_time = self.times[old_len - 1] if old_len > 0 else 0
                # self.states[old_len:,:3] += last_pos
                self.times[old_len:] += last_time

+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
# https://github.com/souhaiel1/DJI-Mavic-pro-simplified-modelling-and-simulation
 No newline at end of file
+50 −0
Original line number Diff line number Diff line
from copy import deepcopy

import numpy as  np

from multirotor.vehicle import (
    VehicleParams,
    MotorParams,
    PropellerParams,
    BatteryParams,
    SimulationParams
)



BP = BatteryParams(max_voltage=22.2)
MP = MotorParams(
    moment_of_inertia=5e-5,
    # resistance=0.27,
    resistance=0.081,
    k_emf=0.0265,
    k_motor=0.0932,
    speed_voltage_scaling=0.0347,
    max_current=38.
)
PP = PropellerParams(
    moment_of_inertia=1.86e-6,
    use_thrust_constant=True,
    k_thrust=9.8419e-05, # 18-inch propeller
    # k_thrust=5.28847e-05, # 15 inch propeller
    k_drag=1.8503e-06, # 18-inch propeller
    # k_drag=1.34545e-06, # 15-inch propeller
    # motor=MP
    motor=None
)
VP = VehicleParams(
    propellers=[deepcopy(PP) for _ in range(8)],
    battery=BP,
    # angles in 45 deg increments, rotated to align with
    # model setup in gazebo sim (not part of this repo)
    angles=np.linspace(0, -2*np.pi, num=8, endpoint=False) + 0.375 * np.pi,
    distances=np.ones(8) * 0.635,
    clockwise=[-1,1,-1,1,-1,1,-1,1],
    mass=10.66,
    inertia_matrix=np.asarray([
        [0.2206, 0, 0],
        [0, 0.2206, 0.],
        [0, 0, 0.4238]
    ])
)
SP = SimulationParams(dt=0.01, g=9.81, dtype=np.float32)
+2 −1
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ def plot_datalog(log: DataLog, figsize=(21,10.5),

    if 'traj' in plots:
        plt.subplot(*plot_grid, plot_number)
        if len(log.target.position) > 0:
            plt.plot(log.target.position[:,0], log.target.position[:,1], label='Prescribed traj', ls=':')
        plt.plot(log.x, log.y, label='Actual traj', ls='-')
        plt.gca().set_aspect('equal', 'box')