Skip to content

Latest commit

 

History

History
140 lines (73 loc) · 3.73 KB

mpc-setup-with-mavros.md

File metadata and controls

140 lines (73 loc) · 3.73 KB

MPC setup with mavros

{% hint style="warning" %} Work in Progress. {% endhint %}

Basic Installation

MPC Package

Clone and install required dependencies : ethz-asl/mav_control_rw

Mavros

Clone ethz-asl/mavros

Firmware

Clone ethz-asl/ethzasl_mav_px4

RotorS

Clone ethz-asl/rotors_simulator

System Identification

Clone ethz-asl/mav_system_identification and install matlab_rosbag

Write a Launch file

Create a launch file for launching the model predictive controller along with mavros. Say example.launch


Where px4_config.yaml is the file with modified URL as below


System Identification with RotorS Simulator

  • Connect a joystick and use Joy package.

  • Run the following command in terminal for launching joy node and remapping it to the iris/rc topic

    
    
  • Start the gazebo simulator with iris

    
    
  • Start the MPC Controller

    
    
  • Control iris with the help of joystick.

    Note: If idoesn't work check the following parameter is set to true in mav_linear_mpc_sim.launch file

    
    
  • Record the /iris/command/roll_pitch_yawrate_thrust & /iris/imu topics using rosbag.

  • Refer ethz-asl/mav_system_identification & mav_dji_ros_interface wiki for using the recorded data in matlab and running the matlab plots for system model parameters.

Update the new parameters

  • MPC yaml file for iris (example `mav_linear_mpc/resources/linear_mpc_iris.yaml)

    ```yaml

    ==================================================================================================================

    Project: MPC for multirotor systems.

    function: MPC Position controller parameters

    Author: Mina Kamel [email protected]

    Ge:nerated: 03-Apr-2015 13:11:59

    ==================================================================================================================

Controller Parameters:

mass: 1.52 roll_time_constant: 0.1847 pitch_time_constant: 0.175 roll_gain: 1.017 pitch_gain: 0.789 drag_coefficients: [ 0.010000 , 0.010000, 0.0000]

q_x: 40 q_y: 40 q_z: 60

q_vx: 20 q_vy: 20 q_vz: 25

q_roll: 20 q_pitch: 20

r_roll: 35 r_pitch: 35 r_thrust: 2

r_droll: 0.3 r_dpitch: 0.3 r_dthrust: 0.0025

roll_max: deg(25.0) pitch_max: deg(25.0) yaw_rate_max: deg(90) thrust_min: 5 thrust_max: 20

K_yaw: 1.8

Ki_xy: 0.2 Ki_z: 0.3 position_error_integration_limit: 2 antiwindup_ball: 0.4

enable_offset_free : true enable_integrator : true

sampling_time: 0.01 #IMPORTANT: set this equal to the rate of odometry msg prediction_sampling_time: 0.1


Show Time!!

  • Run the following commands on terminal

    
    
  • Launch the new launch file

    
    
  • Start Q ground control and put the quad in offboard mode

  • Increase the odometry topic rates in mavlink_main.cpp if data lags.