Multirotor

File: multirotor.py
Author: Marcelo Jacinto (marcelo.jacinto@tecnico.ulisboa.pt)
License: BSD-3-Clause. Copyright (c) 2024, Marcelo Jacinto. All rights reserved.
Description: Definition of the Multirotor class which is used as the base for all the multirotor vehicles.

Classes:

Multirotor

Multirotor class - It defines a base interface for creating a multirotor

MultirotorConfig

A data class that is used for configuring a Multirotor

class pegasus.simulator.logic.vehicles.multirotor.Multirotor

Bases: Vehicle

Multirotor class - It defines a base interface for creating a multirotor

Methods:

__init__([stage_prefix, usd_file, ...])

Initializes the multirotor object

force_and_torques_to_velocities(force, torque)

Auxiliar method used to get the target angular velocities for each rotor, given the total desired thrust [N] and torque [Nm] to be applied in the multirotor's body frame.

handle_propeller_visual(rotor_number, force, ...)

Auxiliar method used to set the joint velocity of each rotor (for animation purposes) based on the amount of force being applied on each joint

start()

In this case we do not need to do anything extra when the simulation starts

stop()

In this case we do not need to do anything extra when the simulation stops

update(dt)

Method that computes and applies the forces to the vehicle in simulation based on the motor speed.

__init__(stage_prefix='quadrotor', usd_file='', vehicle_id=0, init_pos=[0.0, 0.0, 0.07], init_orientation=[0.0, 0.0, 0.0, 1.0], config=<pegasus.simulator.logic.vehicles.multirotor.MultirotorConfig object>)

Initializes the multirotor object

Parameters:
  • stage_prefix (str) – The name the vehicle will present in the simulator when spawned. Defaults to “quadrotor”.

  • usd_file (str) – The USD file that describes the looks and shape of the vehicle. Defaults to “”.

  • vehicle_id (int) – The id to be used for the vehicle. Defaults to 0.

  • init_pos (list) – The initial position of the vehicle in the inertial frame (in ENU convention). Defaults to [0.0, 0.0, 0.07].

  • init_orientation (list) – The initial orientation of the vehicle in quaternion [qx, qy, qz, qw]. Defaults to [0.0, 0.0, 0.0, 1.0].

  • config (MultirotorConfig, optional) – Defaults to MultirotorConfig().

force_and_torques_to_velocities(force, torque)

Auxiliar method used to get the target angular velocities for each rotor, given the total desired thrust [N] and torque [Nm] to be applied in the multirotor’s body frame.

Note: This method assumes a quadratic thrust curve. This method will be improved in a future update, and a general thrust allocation scheme will be adopted. For now, it is made to work with multirotors directly.

Parameters:
  • force (np.ndarray) – A vector of the force to be applied in the body frame of the vehicle [N]

  • torque (np.ndarray) – A vector of the torque to be applied in the body frame of the vehicle [Nm]

Returns:

A list of angular velocities [rad/s] to apply in reach rotor to accomplish suchs forces and torques

Return type:

list

handle_propeller_visual(rotor_number, force, articulation)

Auxiliar method used to set the joint velocity of each rotor (for animation purposes) based on the amount of force being applied on each joint

Parameters:
  • rotor_number (int) – The number of the rotor to generate the rotation animation

  • force (float) – The force that is being applied on that rotor

  • articulation (_type_) – The articulation group the joints of the rotors belong to

start()

In this case we do not need to do anything extra when the simulation starts

stop()

In this case we do not need to do anything extra when the simulation stops

update(dt)

Method that computes and applies the forces to the vehicle in simulation based on the motor speed. This method must be implemented by a class that inherits this type. This callback is called on every physics step.

Parameters:

dt (float) – The time elapsed between the previous and current function calls (s).

class pegasus.simulator.logic.vehicles.multirotor.MultirotorConfig

Bases: object

A data class that is used for configuring a Multirotor

Methods:

__init__()

Initialization of the MultirotorConfig class

__init__()

Initialization of the MultirotorConfig class