def __init__(self, config): Ti = config.Ti # Quad Params # --------------------------- self.params = sys_params(config) # Command for initial stable hover # --------------------------- ini_hover = init_cmd(self.params) self.params["FF"] = ini_hover[0] # Feed-Forward Command for Hover self.params["w_hover"] = ini_hover[1] # Motor Speed for Hover self.params["thr_hover"] = ini_hover[2] # Motor Thrust for Hover self.thr = np.ones(4) * ini_hover[2] self.tor = np.ones(4) * ini_hover[3] # Initial State # --------------------------- self.state = init_state(self.params, config) self.pos = self.state[0:3] self.quat = self.state[3:7] self.vel = self.state[7:10] self.omega = self.state[10:13] self.wMotor = np.array( [self.state[13], self.state[15], self.state[17], self.state[19]]) self.vel_dot = np.zeros(3) self.omega_dot = np.zeros(3) self.acc = np.zeros(3) self.extended_state() self.forces() # Set Integrator # --------------------------- self.integrator = ode(self.state_dot).set_integrator( 'dopri5', first_step='0.00005', atol='10e-6', rtol='10e-6') self.integrator.set_initial_value(self.state, Ti)
def __init__(self, states0, Ti=0): # Quad Params # --------------------------- self.params = sys_params() # Initial State # --------------------------- self.state = init_state(states0) self.pos = self.state[0:3] self.angle = self.state[3:6] self.vel = self.state[6:9] self.angular = self.state[9:12] self.backstepping = Control(quad, traj.yawType) self.wind_direct = 0. # Set Integrator # --------------------------- self.integrator = ode(self.state_dot).set_integrator( 'dopri5', first_step='0.00005', atol='10e-6', rtol='10e-6') self.integrator.set_initial_value(self.state, Ti)
def __init__(self, Ti, Tf, ctrlType, trajSelect, numTimeStep, Ts, quad_id=None, mode='ennemy', id_targ=-1, color='blue', pos_ini=[0, 0, 0], pos_goal=[1, 1, -1], pos_obs=None): ''' It is used to store in the basic attributes the inputs already mentioned in the previous sections. In the case of the one employed by Python simulation environment, the command for an initial stable hover and the initial state of the drone are initialized. For that, the dynamics, kinetics, kinematics and control are also loaded. Finally, the storage of drone data is pre-allocated. ''' # Quad Params # --------------------------- self.quad_id = quad_id self.pos_ini = pos_ini self.pos_goal = pos_goal self.pos_goal_ini = pos_goal self.pos_obs = pos_obs self.id_targ = id_targ self.pos_quads = None self.mode = mode self.mode_ini = mode self.neutralize = False self.ctrlType = ctrlType self.trajSelect = trajSelect self.params = sys_params() self.t_update = Ti self.t_track = 0 self.Ti = Ti self.Ts = Ts self.Tf = Tf # Command for initial stable hover # --------------------------- ini_hover = init_cmd(self.params) self.params["FF"] = ini_hover[0] # Feed-Forward Command for Hover self.params["w_hover"] = ini_hover[1] # Motor Speed for Hover self.params["thr_hover"] = ini_hover[2] # Motor Thrust for Hover self.thr = np.ones(4) * ini_hover[2] self.tor = np.ones(4) * ini_hover[3] # Initial State # --------------------------- self.state = init_state(self.params, pos_ini) self.pos = self.state[0:3] self.quat = self.state[3:7] self.vel = self.state[7:10] self.omega = self.state[10:13] self.wMotor = np.array( [self.state[13], self.state[15], self.state[17], self.state[19]]) self.vel_dot = np.zeros(3) self.omega_dot = np.zeros(3) self.acc = np.zeros(3) self.previous_pos_targ = self.pos self.previous_pos_us = self.pos self.extended_state() self.forces() # Set Integrator # --------------------------- self.integrator = ode(self.state_dot).set_integrator( 'dopri5', first_step='0.00005', atol='10e-6', rtol='10e-6') self.integrator.set_initial_value(self.state, Ti) self.traj = Trajectory(self.psi, ctrlType, trajSelect, pos_ini=self.pos, pos_goal=pos_goal, pos_obs=pos_obs, Tf=self.Tf, t_ini=0) self.ctrl = Control(self.params["w_hover"], self.traj.yawType) self.t_all = np.zeros(numTimeStep) self.s_all = np.zeros([numTimeStep, len(self.state)]) self.pos_all = np.zeros([numTimeStep, len(self.pos)]) self.vel_all = np.zeros([numTimeStep, len(self.vel)]) self.quat_all = np.zeros([numTimeStep, len(self.quat)]) self.omega_all = np.zeros([numTimeStep, len(self.omega)]) self.euler_all = np.zeros([numTimeStep, len(self.euler)]) self.sDes_traj_all = np.zeros([numTimeStep, len(self.traj.sDes)]) self.sDes_calc_all = np.zeros([numTimeStep, len(self.ctrl.sDesCalc)]) self.w_cmd_all = np.zeros([numTimeStep, len(self.ctrl.w_cmd)]) self.wMotor_all = np.zeros([numTimeStep, len(self.wMotor)]) self.thr_all = np.zeros([numTimeStep, len(self.thr)]) self.tor_all = np.zeros([numTimeStep, len(self.tor)]) self.color = color self.pf_map_all = np.empty(numTimeStep, dtype=list)