├── .gitignore
├── 10_Docker.md
├── 10_MAVLink.md
├── 1_2_Install_Ardupilot.md
├── 1_Assembly
├── ArduPilot_Kakute
│ ├── Auto_Tunner.png
│ ├── Auto_Tunner2.png
│ ├── BLHeliSuite32_Motor_Change_Direction.png
│ ├── BLHeliSuite32_Motor_Check.png
│ ├── BLHeliSuite32_Motor_Direction.png
│ ├── BLHeliSuite32_Motor_Update.png
│ ├── BLHeliSuite32_Motor_Update2.png
│ ├── BLHeliSuite32_Motor_Update3.png
│ ├── Copter_AttitudeControlPID.png
│ ├── DFU_check.png
│ ├── FrameType_BetaFlight.png
│ ├── Gyroscope_calibration.jpg
│ ├── KakuteH7_Tekko32.png
│ ├── KakuteH7_Tekko32_2.jpg
│ ├── Kakute_HAKRC.png
│ ├── Kakute_Tekko.png
│ ├── Kakute_components.png
│ ├── Kakute_prebuilt_board.png
│ ├── Kakute_prebuilt_firmware.png
│ ├── MPU6000.png
│ ├── MissionPlanner_MotorTest.png
│ ├── Mission_Planner_setup1.png
│ ├── Mot_Type.png
│ ├── Motor_BetaFlightX.jpg
│ ├── Motor_ESC_Connection_step1.jpg
│ ├── Motor_ESC_Connection_step2.jpg
│ ├── Motor_ESC_Connection_step3.jpg
│ ├── Motor_ESC_Connection_step4.jpg
│ ├── Motor_direction_wires_step1.png
│ ├── Motor_direction_wires_step2.png
│ ├── PID_Parameters.png
│ ├── QGroundControl.png
│ ├── Sensor-Calibration.png
│ ├── Step1_STM32CubeProgrammer.png
│ ├── Step2_STM32CubeProgrammer.png
│ ├── Tekko32_Pins.png
│ ├── Transmitter_Connect.jpg
│ ├── Tune_Initial_Table.png
│ ├── UAV_log_viewer_attitude.png
│ ├── UAV_log_viewer_tuning_result.png
│ ├── pid_tuning_interface.jpg
│ └── transmitter.png
├── BetaFlight_Aocoda
│ ├── Acoda_ESC.png
│ ├── Acoda_quadrotor.jpg
│ ├── Aocoda_RCH743_pins.png
│ ├── Autopilot_ESC.jpg
│ ├── BetaFlight_Import_Config.png
│ ├── BetaFlight_flash_finished.png
│ ├── BetaFlight_interface.png
│ ├── Betaflight_Config_flash.png
│ ├── Betaflight_Config_save.png
│ ├── Configurator_MotorDirection.png
│ ├── Configurator_MotorSetting.png
│ ├── Flash_Custm_firmware.png
│ ├── Flash_online_firmware.png
│ ├── Modes_Angle.png
│ ├── Modes_Arm.png
│ ├── Motor_ESC_Connection_step1.jpg
│ ├── Motor_ESC_Connection_step2.jpg
│ ├── Receiver_ports.png
│ ├── battery_measure.png
│ ├── calibrate_acc.png
│ ├── current_scale.png
│ ├── drone_battery_metter.jpg
│ ├── install_betaflight.png
│ ├── logo.png
│ ├── power_voltage_calibration.png
│ └── transmitter.png
├── Chassis
│ ├── Lightning_X_Lite.jpg
│ ├── Lightning_X_Lite_step1.jpg
│ └── Lightning_X_Lite_step2.jpg
├── PX4_X500
│ ├── autoploit.png
│ ├── chassis.png
│ ├── drone.png
│ └── power.png
└── Transmitter
│ └── protocols.png
├── 2_0_Simulation_ROS.md
├── 2_1_Simulation_ROS_PX4.md
├── 2_1_X500_Pixhawk5.md
├── 2_2_LightningXLite_Kakute.md
├── 2_2_Simulation_ROS_Ardupilot.md
├── 2_3_LightningXLite_Aocoda.md
├── 2_3_Simulation_PX4_Gazebo.md
├── 2_4_Config_Ardupilot.md
├── 2_5_Config_BetaFlight.md
├── 2_6_Transmitter.md
├── 2_Simulation_ROS_Ardupilot
├── Ardupilot_Gazebo_Garden_Mavros.png
└── gz_installed_test.png
├── 2_Simulation_Setup_ROS_PX4
├── Installed_mavros.png
├── gazebo_errors.png
├── px4_gazebo.png
├── px4_ros.png
└── px4_version.png
├── 3_Simulation_Gazebo_Control
├── COM_RCL_EXCEPT.png
├── Setting_4_Vicon.png
├── Setting_4_Vicon_height.png
└── Setting_4_Vicon_position.png
├── 4_Experiment_Communication_Pi_Pixhawk.md
├── 4_Experiment_OnboardComputer_Pi.md
├── 4_Experiment_OnboardComputer_Setup
├── Drone_components.png
├── GPIO_Raspberry.png
├── Mate_rapspberry.jpg
├── Pi_power_supply.png
├── Pixhawk_raspberry.png
├── RaspberPi_4B.jpg
├── Raspberry_OS.png
├── Raspberry_OS_option1.png
├── Raspberry_OS_option2.png
├── check_ssh_installation.png
├── ntp_on.png
├── ntp_status.png
├── px4_port_raspberry.png
├── px4_telem2_ports.png
├── px4_telen2_ports_drone.jpeg
├── raspberry_pi_imager.png
├── ssh_host_connect.png
├── ssh_host_name.png
├── ssh_pwd_user.png
├── ssh_request.png
├── static_IP.png
└── write_mate_2004.png
├── 4_Experiment_ROS_Communication_Pi_BaseStation.md
├── 5_Experiment_Hardware_Setup.md
├── 5_Experiment_Hardware_Setup
├── raspberry_bard.png
├── raspberry_usb.png
└── schematic_pixhawks_rasperry.png
├── 6_Vicon
├── ECL_overview.png
├── Vicon_cage.jpg
├── Vicon_calibrate.PNG
├── Vicon_live.png
├── Vicon_object.PNG
├── Vicon_origin.png
├── Vicon_system.png
├── object_name.png
├── static_ip_base_station.png
├── vicon_bridege_setting.png
├── vicon_frame.PNG
├── vicon_in_ros
├── vicon_in_ros.png
├── vicon_rename_in_ros.png
├── vicon_ros_msg.png
├── wand.png
└── yaw_oritation.png
├── 6_Vicon_Setup_Use.md
├── 7_Mavros_Controller.md
├── 7_Mavros_Controller
├── bench_test.png
└── v1_0.png
├── 8_0_ROS2.md
├── 8_1_Intro_ROS2.md
├── 8_2_Install_ROS2.md
├── 8_3_Config_Workspace.md
├── 8_3_Examples_Pub_Subs.md
├── 8_4_ROS2_Ardupilot_PX4.md
├── 8_Arduploit
├── Ardu_sim_Q.png
├── Arduploit_PX4.png
├── Custmer_build_Arduploit.png
├── ardupilot_interface.png
├── arduploit_simu_test.png
├── arm_throttle.png
├── available_boards.png
├── build_bin.png
├── build_config.png
├── build_result.png
├── choose_download_ardupilot_version.png
├── drone_gazebo_takeoff.png
├── guided.png
├── mavors_state_local_pose.png
├── mavros_topics.png
└── takeoff.png
├── 8_ROS2
├── API_structure.png
├── DDS_ROS2.png
├── Maruyama.ExploringROS2.2016.pdf
├── Nodes-TopicandService.gif
├── ROS2_Index.png
├── ROS2_overlays.png
├── Screenshot from 2023-06-02 17-19-02.png
├── check_local_support.png
├── colcon_build_pkg.png
├── colcon_create_pkg.png
├── colcon_pkg_run.png
├── colcon_source.png
├── grapsh_talker_listener.png
├── structures_ROS_ROS2.png
├── talker_listener.png
└── universal.png
├── 9_2_ROS_Ardupilot.md
├── 9_Arduploit.md
├── Readme.md
└── digraph prof {.rs
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/*
2 | !.vscode/settings.json
3 | !.vscode/tasks.json
4 | !.vscode/launch.json
5 | !.vscode/extensions.json
6 | !.vscode/*.code-snippets
7 |
8 | # Local History for Visual Studio Code
9 | .history/
10 |
11 | # Built Visual Studio Code Extensions
12 | *.vsix
13 |
14 | .vscode/
15 |
16 | *.svg
17 | */*.svg
18 |
--------------------------------------------------------------------------------
/10_Docker.md:
--------------------------------------------------------------------------------
1 | Docker is extremely recommended here.
2 |
3 | Tutorials
4 | - basics of docker [Docker 101](https://youtu.be/SAMPOK_lazw?si=h3iRsYHCWNUMp_Cg)
5 | - [Crafting your Dockerfile (Docker and Robotics Pt 3)](https://youtu.be/RbP5cARP-SM?si=9cON1vphcz4puayk)
6 | - [Devices in Docker - Not so simple! (Docker for Robotics #4)](https://youtu.be/uf4zOigzTFo?si=kWSsGsG1fZFuZSPV)
7 |
8 | -[ROS2 Docker GUI for Windows and Linux](https://youtu.be/qWuudNxFGOQ?si=INaxeDXXT0q3TFmI)
9 |
10 | - [Commands ref](https://github.com/noshluk2/ros1_wiki/blob/main/docker/commands.md)
11 |
12 | - [Docker compose](Docker Compose)
--------------------------------------------------------------------------------
/10_MAVLink.md:
--------------------------------------------------------------------------------
1 | # Mavlink interface between autopilot and onboard computer
2 |
3 | ## Mavpoxy
4 | ```shell
5 | sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
6 | pip3 install PyYAML mavproxy --user
7 | echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc
8 |
9 | ```
10 |
11 | 1. Connect to autopilot
12 | ```shell
13 | mavproxy.py --master=/dev/ttyUSB0
14 | ```
15 |
16 |
--------------------------------------------------------------------------------
/1_2_Install_Ardupilot.md:
--------------------------------------------------------------------------------
1 | # Install Ardupilot firmware on drone
2 | ## 1 Obtain Ardupilot firmware
3 | ### 1.1 build Ardupilot firmware from source code
4 | 1. use Waf to build an ardupliot firmware for the chosen board. Tutorials to use Waf https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md.
5 | - clean previous built firmware
6 | ```shell
7 | cd ardupliot
8 | ./waf distclean
9 | ```
10 | - The available list can be found by
11 | ```shell
12 | cd ardupliot
13 | ./waf list_boards
14 | ```
15 |
16 |
17 |
18 |
19 | - video tutorial for next two steps https://youtu.be/lNSvAPZOM_o.
20 | - choose firmware - it is Pixhawk5X for us
21 | ```shell
22 | cd ardupliot
23 | ./waf configure --board Pixhawk5X
24 | ```
25 |
26 |
27 |
28 |
29 | - build it
30 | ```shell
31 | cd ardupliot
32 | ./waf copter
33 | ```
34 |
35 |
36 |
37 |
38 | - find the built ardupliot file at /ardupliot/build/board_name/bin, like
39 |
40 |
41 |
42 |
43 | ### 1.2 Download Arduploit firemware directly from online sources
44 | 1. we can download an Arduploit firmware at https://firmware.ardupilot.org/ choosing
45 | + drone type
46 | + board of autoploit
47 | + **features that are needed**
48 |
49 |
51 |
52 |
53 | 2. we can find version 4.3. and its corresponding files for Pixhwask5
54 |
55 |
57 |
58 |
59 | ## 2 burn Ardupilot to drone
60 |
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Auto_Tunner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Auto_Tunner.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Auto_Tunner2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Auto_Tunner2.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Change_Direction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Change_Direction.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Check.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Direction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Direction.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update2.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/BLHeliSuite32_Motor_Update3.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Copter_AttitudeControlPID.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Copter_AttitudeControlPID.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/DFU_check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/DFU_check.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/FrameType_BetaFlight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/FrameType_BetaFlight.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Gyroscope_calibration.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Gyroscope_calibration.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/KakuteH7_Tekko32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/KakuteH7_Tekko32.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/KakuteH7_Tekko32_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/KakuteH7_Tekko32_2.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Kakute_HAKRC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Kakute_HAKRC.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Kakute_Tekko.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Kakute_Tekko.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Kakute_components.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Kakute_components.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Kakute_prebuilt_board.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Kakute_prebuilt_board.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Kakute_prebuilt_firmware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Kakute_prebuilt_firmware.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/MPU6000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/MPU6000.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/MissionPlanner_MotorTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/MissionPlanner_MotorTest.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Mission_Planner_setup1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Mission_Planner_setup1.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Mot_Type.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Mot_Type.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_BetaFlightX.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_BetaFlightX.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step1.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step2.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step3.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_ESC_Connection_step4.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_direction_wires_step1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_direction_wires_step1.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Motor_direction_wires_step2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Motor_direction_wires_step2.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/PID_Parameters.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/PID_Parameters.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/QGroundControl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/QGroundControl.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Sensor-Calibration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Sensor-Calibration.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Step1_STM32CubeProgrammer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Step1_STM32CubeProgrammer.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Step2_STM32CubeProgrammer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Step2_STM32CubeProgrammer.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Tekko32_Pins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Tekko32_Pins.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Transmitter_Connect.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Transmitter_Connect.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/Tune_Initial_Table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/Tune_Initial_Table.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/UAV_log_viewer_attitude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/UAV_log_viewer_attitude.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/UAV_log_viewer_tuning_result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/UAV_log_viewer_tuning_result.png
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/pid_tuning_interface.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/pid_tuning_interface.jpg
--------------------------------------------------------------------------------
/1_Assembly/ArduPilot_Kakute/transmitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/ArduPilot_Kakute/transmitter.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Acoda_ESC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Acoda_ESC.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Acoda_quadrotor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Acoda_quadrotor.jpg
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Aocoda_RCH743_pins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Aocoda_RCH743_pins.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Autopilot_ESC.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Autopilot_ESC.jpg
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/BetaFlight_Import_Config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/BetaFlight_Import_Config.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/BetaFlight_flash_finished.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/BetaFlight_flash_finished.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/BetaFlight_interface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/BetaFlight_interface.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Betaflight_Config_flash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Betaflight_Config_flash.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Betaflight_Config_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Betaflight_Config_save.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Configurator_MotorDirection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Configurator_MotorDirection.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Configurator_MotorSetting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Configurator_MotorSetting.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Flash_Custm_firmware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Flash_Custm_firmware.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Flash_online_firmware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Flash_online_firmware.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Modes_Angle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Modes_Angle.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Modes_Arm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Modes_Arm.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Motor_ESC_Connection_step1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Motor_ESC_Connection_step1.jpg
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Motor_ESC_Connection_step2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Motor_ESC_Connection_step2.jpg
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/Receiver_ports.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/Receiver_ports.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/battery_measure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/battery_measure.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/calibrate_acc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/calibrate_acc.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/current_scale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/current_scale.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/drone_battery_metter.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/drone_battery_metter.jpg
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/install_betaflight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/install_betaflight.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/logo.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/power_voltage_calibration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/power_voltage_calibration.png
--------------------------------------------------------------------------------
/1_Assembly/BetaFlight_Aocoda/transmitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/BetaFlight_Aocoda/transmitter.png
--------------------------------------------------------------------------------
/1_Assembly/Chassis/Lightning_X_Lite.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/Chassis/Lightning_X_Lite.jpg
--------------------------------------------------------------------------------
/1_Assembly/Chassis/Lightning_X_Lite_step1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/Chassis/Lightning_X_Lite_step1.jpg
--------------------------------------------------------------------------------
/1_Assembly/Chassis/Lightning_X_Lite_step2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/Chassis/Lightning_X_Lite_step2.jpg
--------------------------------------------------------------------------------
/1_Assembly/PX4_X500/autoploit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/PX4_X500/autoploit.png
--------------------------------------------------------------------------------
/1_Assembly/PX4_X500/chassis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/PX4_X500/chassis.png
--------------------------------------------------------------------------------
/1_Assembly/PX4_X500/drone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/PX4_X500/drone.png
--------------------------------------------------------------------------------
/1_Assembly/PX4_X500/power.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/PX4_X500/power.png
--------------------------------------------------------------------------------
/1_Assembly/Transmitter/protocols.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/1_Assembly/Transmitter/protocols.png
--------------------------------------------------------------------------------
/2_0_Simulation_ROS.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_0_Simulation_ROS.md
--------------------------------------------------------------------------------
/2_1_Simulation_ROS_PX4.md:
--------------------------------------------------------------------------------
1 | roslaunch# Simulation setup ROS, PX4, Gazebo and mavros (Mavlink)
2 | This is to setup simulation environment to simulate drone (PX4) in Gazebo and ROS.
3 |
4 | Software and ROS packages needed include
5 | - **ROS**,
6 | - **PX4** as framework of autopilot,
7 | - **mavros** for communication between PX4 and ROS,
8 | - Controller library (optional).
9 |
10 | ## Table of contents
11 | - [Step 1 Install ROS](#step-1-install-ros)
12 | - [Step 2 Build PX4 from source code](#step-2-build-px4-from-source-code)
13 | - [Step 2.5 Enable roslaunch to launch PX4 in Gazebo](#step-25-enable-roslaunch-to-launch-px4-in-gazebo)
14 | - [Step 3 Build mavros (Mavlink) from source code](#step-3-build-mavros-Mavlink-from-source-code)
15 |
16 |
17 | ## Step 1 Install ROS
18 | ROS version should be chosen according to OS. Now, ROS LTS (see [here](http://wiki.ros.org/ROS/Installation)) are provided for
19 | - Ubuntu 18.04 (ROS Melodic),
20 | - Ubuntu 20.04 (ROS Noetic).
21 |
22 | Installing guide of Noetic for Ubuntu 20.04 can be found [here](http://wiki.ros.org/noetic/Installation/Ubuntu).
23 |
24 | ## Step 2 Build PX4 from source code
25 | 1. Download PX4 of version 1.12.3
26 | ```bash
27 | cd Robot_Firmware # somewhere you like
28 | git clone -b v1.12.3 https://github.com/PX4/PX4-Autopilot.git --recursive
29 | ```
30 | Check PX4 version with
31 | ```bash
32 | git describe
33 | ```
34 | we should get
35 |
36 |
38 | px4 version
39 |
40 |
41 | 2. Run the script to install dependencies and tools for nuttx, jMAVSim, Gazebo s
42 | ```bash
43 | cd PX4-Autopilot
44 | bash ./Tools/setup/ubuntu.sh
45 | ```
46 | 3. Test PX4 within Gazebo
47 | ```bash
48 | make px4_sitl gazebo
49 | ```
50 | ## Step 2.5 Enable roslaunch to launch PX4 in Gazebo
51 | Following steps of *Install PX4 SITL(Only to Simulate)* [here](https://github.com/ZhongmouLi/mavros_controllers)
52 | ```shell
53 | cd PX4-Autopilot
54 | DONT_RUN=1 make px4_sitl_default gazebo
55 | ```
56 | In cases of errors, do
57 | ```bash
58 | cd PX4-Autopilot
59 | make clean
60 | rm -r ~/catkin_ws/devel ~/catkin_ws/build
61 | ```
62 |
63 | Modify .bashrc by adding
64 | (replace ${address_of_PX4-Autopilot} by where you install PX4-Autopilot int the following commande)
65 |
66 |
67 | ```bash
68 | source ${address_of_PX4-Autopilot}/Tools/setup_gazebo.bash ${address_of_PX4-Autopilot} ${address_of_PX4-Autopilot}/build/px4_sitl_default
69 | export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${address_of_PX4-Autopilot}
70 | export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${address_of_PX4-Autopilot}/Tools/sitl_gazebo
71 | ```
72 | 5. Check if ros can find px4 package
73 | ```bash
74 | rospack find px4
75 | ```
76 | It should give
77 |
78 |
79 |
81 | px4 found by ros
82 |
83 |
84 | Finally, it should be able to use roslaunch to create px4-gazebo simulation environment by
85 | ```bash
86 | roslaunch px4 posix_sitl.launch
87 | ```
88 |
89 |
91 | px4-gazebo simulation environment
92 |
93 |
94 |
95 | Common errors:
96 | 1. gazebo dies
97 |
98 |
99 | gazebo errors
100 |
101 |
102 | do
103 | ```bash
104 | ps aux | grep gzserver
105 | kill -2
106 | ```
107 |
108 | ## Step 3 Build mavros (Mavlink) from source code
109 | Mavlink is a protocol for communicating with drones (PX4).
110 |
111 | There are two ways of using Mavlink for communication
112 | - mavros wrappers Mavlink into ROS,
113 | - MavSDK provides various programming languages to interface with Mavlink systems.
114 |
115 | Our development is conducted in ROS, thus is natural to consider using Mavlink somehow in ROS for the purpose of communicating with drones in ROS environment. Therefore, we take mavros.
116 |
117 | PX4 provides guides to install mavros and Mavlink [ROS with MAVROS Installation Guide](https://docs.px4.io/master/en/ros/mavros_installation.html)
118 |
119 | Here we show do to build MAVROS from source code .
120 |
121 |
122 | 1. Install building and managing tools, **catkin_tools** and **wstool** see the [install catkin tools](https://catkin-tools.readthedocs.io/en/latest/installing.html) and [install wstool](http://wiki.ros.org/wstool).
123 |
124 | 2. Create catkin workspace using catkin tools
125 | ```bash
126 | cd ~
127 | mkdir catkin_ws
128 | cd catkin_ws
129 | mkdir src
130 | catkin init
131 | ```
132 | Then, add the path of catkin_ws into .bashrc
133 | ```bash
134 | echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
135 | ```
136 |
137 | 3. Initialize your source space with wstool. The target directory of wstool is src
138 |
139 | ```bash
140 | cd catkin_ws
141 | wstool init ./src
142 | ```
143 |
144 | 4. Install Mavlink
145 | (1). note: tee is to write the output of rosinstall_generator into the file mavros.rosinstall
146 |
147 | ```bash
148 | # We use the Kinetic reference for all ROS distros as it's not distro-specific and up to date
149 | rosinstall_generator --rosdistro kinetic Mavlink | tee /tmp/mavros.rosinstall
150 | ```
151 |
152 | (2). install MAVROS with stable one
153 | ```bash
154 | rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
155 | ```
156 | As a consequence, we can cat the "/temp/mavros.rosinstall" that is shown below. We can see from that, wstool just records the git rep information, such as URL, branch name and version.
157 |
158 | ```bash
159 | - git:
160 | local-name: Mavlink
161 | uri: https://github.com/Mavlink/Mavlink-gbp-release.git
162 | version: release/kinetic/Mavlink/2021.3.3-1
163 |
164 | - git:
165 | local-name: mavros
166 | uri: https://github.com/Mavlink/mavros.git
167 | version: 1.10.0
168 | ```
169 |
170 | 5. Create workspace & deps (explanation of wstool see [here](https://docs.ros.org/en/independent/api/rosinstall/html/rosws.html))
171 |
172 | ```bash
173 | # run this commande in /catkin_ws which merges config in /tmp/mavros.rosinstall to src/.rosinstall
174 | wstool merge -t src /tmp/mavros.rosinstall
175 |
176 | # This command pulls changes from remote to your local filesystem.
177 | # download the source codes from git
178 | wstool update -t src -j4
179 |
180 | //
181 | rosdep install --from-paths src --ignore-src -y
182 | ```
183 |
184 | 6. Install [GeographicLib](https://geographiclib.sourceforge.io/) dataset
185 |
186 | ```bash
187 | ./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
188 |
189 | # if /bin/bash^M: bad interpreter: No such file or directory
190 | Try running *dos2unix* on the script:
191 |
192 | http://dos2unix.sourceforge.net/
193 | ```
194 |
195 | 7. build source
196 |
197 | ```bash
198 | cd catkin_ws
199 | catkin build
200 | ```
201 |
202 | 8. use setup.bash or setup.zsh from workspace.
203 |
204 | ```bash
205 | cd catkin_ws
206 | source ./devel/source.bash
207 | ```
208 |
209 | 9. check if MAVROS and Mavlink are well installed
210 |
211 | ```bash
212 | rospack find mavros
213 |
214 | rospack find Mavlink
215 | ```
216 |
217 |
218 | which gives
219 |
220 |
221 |
223 | mavros and Mavlink are installed
224 |
225 |
226 | 10. run mavros for communication in simulation
227 | ```bash
228 | roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
229 | ```
230 | Note ```fcu_url:="udp://:14540@127.0.0.1:14557"``` indicates that a drone is simulated by this PC.
231 |
--------------------------------------------------------------------------------
/2_1_X500_Pixhawk5.md:
--------------------------------------------------------------------------------
1 | # Assembly X500 drone kits
2 | This note shows main steps to build a drone from kits (hardware).
3 |
4 | Tutorial in details can be found [https://docs.px4.io/main/en/frames_multicopter/holybro_x500V2_pixhawk5x.html](https://docs.px4.io/main/en/frames_multicopter/holybro_x500V2_pixhawk5x.html).
5 |
6 | ## 1. Drone kits and commercial elements
7 | 1. Drone frame Kits: [Holybro X500 V2 Kit](http://www.holybro.com/product/x500-v2-kit/) cluding
8 | - X500 V2 Frame Kit
9 | - Motors – Holybro 2216 KV920 Motor
10 | - ESCs – BLHeli S ESC 20A
11 | - Self locking propellers 1045 (cheaper options T1045 Self locking Props)
12 | - Power Distribution Board – XT60 plug for battery & XT30 plug for ESCs & peripherals
13 | 2. Autopliot and framework
14 | - Pixhawk 4 mini and Pixhawk 5
15 | - PX4 version (1.12)
16 | 3. Onboard computer and OS
17 | - Raspberry PI 4b+
18 | 4. Remote controller and receiver
19 | - FrSky Taranis X9D
20 | - FRsky X8R
21 | ## 2. Overview of main elements
22 |
23 |
25 |
26 |
27 | ## 3. Steps
28 | ### 3.1 Build chassis
29 |
30 |
32 |
33 |
34 | ### 3.2 Connect power module
35 |
36 |
38 |
39 |
40 | ### 3.3 Drone is ready.
41 |
42 |
44 |
45 |
--------------------------------------------------------------------------------
/2_2_LightningXLite_Kakute.md:
--------------------------------------------------------------------------------
1 | ## 1 Develop kits
2 | 1. Drone frame:
3 | - Chassis TransTEC Lightning X Lite
4 | - Motor FPV 致盈EX2306 PLUS [site in Taobao](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.27.52b858176s1EdF&id=634695941707)
5 | 2. ESC:
6 | - [Tekko32 F4 Metal 4in1 65A ESC (65A)](https://holybro.com/collections/fpv-esc/products/tekko32-f4-metal-4in1-65a-esc-65a)
7 | - [HAKRC 3260A ESC BLHeli-32 ](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.32.193244beujIlvo&id=624599427940)
8 | 3. Autopilot and framework
9 | - Kakute H7 v1.3 [site in Taobo](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.28.56917484ySIhA5&id=684452325988)
10 | - Ardupilot 4.3
11 | 4. Onboard computer and OS
12 | - Navidia NX
13 | - Ubuntu 20.04
14 | 5. Transmitter
15 | - RadioLink AT9S Pro
16 | - RadioLink R12DSM [Site in Tabo](https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-22611654662.9.59a41dc7RXezIK&id=561805355565)
17 |
18 | 6. Useful notes
19 | - CUAV on Copters [https://doc.cuav.net/tutorial/copter/](https://doc.cuav.net/tutorial/copter/)
20 | - ArduPilot Copter [https://ardupilot.org/copter/index.html](https://ardupilot.org/copter/index.html)
21 | - [How to methodically tune (almost) any multicopter using ArduCopter 4.4.x](https://discuss.ardupilot.org/t/how-to-methodically-tune-almost-any-multicopter-using-arducopter-4-4-x/110842), please read this together with this tutorial.
22 | - [Analytical Multicopter Flight Controller PID Optimization](https://discuss.ardupilot.org/t/analytical-multicopter-flight-controller-pid-optimization/109759).
23 |
24 | ## 2. Assembly and configuration steps for manual flights
25 | ### 2.1 Build chassis
26 | First, take parts from Lightning X Lite and prepare alex keys.
27 |
28 |
30 |
31 |
32 | We build the base like the picture below. Then, we add the upper part and use M3 screws to fix them together.
33 |
34 | | | |
35 | | ----------------------------------- | ----------------------------------- |
36 | |  |  |
37 |
38 |
39 | It is the time to place them on the chassis
40 |
41 | ### 2.2 Link ESC with power and actuation modules
42 | Lets take Tekko32 for example.
43 |
44 | First, we its order for motors.
45 |
46 |
48 |
49 |
50 | Then we place four motors in the correct order. We weld them like this
51 |
52 | | | |
53 | | ----------------------------------- | ----------------------------------- |
54 | |  |  |
55 |
56 |
57 | After that, we weld a power wire with XT60 and a 35v 470uf capacitance to the power input of Tekko32.
58 |
59 |
60 |
62 |
63 |
64 | ### 2.3 Connect autopilot to ESC
65 | ### Kakute H7 to Tekko32
66 | Following the instruction shown below
67 |
68 |
70 |
71 | we weld them like
72 |
73 |
75 |
76 |
77 |
78 | #### Kakute H7 to HAKRC
79 |
80 |
82 |
83 |
84 | ### 2.4 Connect transmitter and receiver
85 | It can been that [RadioLink R12DSM](https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-22611654662.9.59a41dc7RXezIK&id=561805355565) supports S.BUS and PPM protocols.
86 |
87 | Also, check pins of Kakute at [Holybro Kakute H7 V1](https://ardupilot.org/copter/docs/common-holybro-kakuteh7.html).
88 |
89 | Therefore, the three ports of R12DSM should be connected to Kakute in the following way:
90 | - "+" of R12DSM ----> 5V of Kakute
91 | - "-" of R12DSM ----> GND of Kakute
92 | - "S.B/PPM" of R12DSM ----> RX6 of Kakute
93 |
94 |
95 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/2_2_Simulation_ROS_Ardupilot.md:
--------------------------------------------------------------------------------
1 |
2 | ## 1 Build Gazebo environment
3 | It is suggested to choose one gazebo version between [Gazebo Garden](#1.1-gazebo-garden) and [Gazebo 11](#1.2-gazebo-11)
4 |
5 |
6 | Main references are
7 | - [Using SITL with Gazebo](https://ardupilot.org/dev/docs/sitl-with-gazebo.html) for Gazebo Garden.
8 | - [Using SITL with legacy versions of Gazebo](https://ardupilot.org/dev/docs/sitl-with-gazebo-legacy.html#sitl-with-gazebo-legacy) for Gazebo 11.
9 |
10 | ### 1.1 Gazebo Garden
11 |
12 | Install Gazebo Garden following the steps at [Docs/Gazebo Garden-->Binary Installation on Ubuntu](https://gazebosim.org/docs/garden/install_ubuntu), which are
13 | ```shell
14 | sudo apt-get update
15 | sudo apt-get install lsb-release wget gnupg
16 | ```
17 | and then
18 | ```shell
19 | sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
20 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
21 | sudo apt-get update
22 | sudo apt-get install gz-garden
23 | ```
24 | To test if the installation is done, we can run
25 | ```shell
26 | gz sim -v4 -r shapes.sdf
27 | ```
28 | and it is OK if we can see
29 |
30 |
31 |
32 |
33 | ### 1.2 Gazebo 11
34 |
35 | Video tutorials provided by Intelligent Quads can be found on Youtube [Drone Dev Environment Ubuntu 20 04 Update](https://youtu.be/1FpJvUVPxL0)
36 |
37 |
38 | Given that our development environments are
39 | - Ubunt 20.04
40 | - ROS noetic
41 | - Gazebo 11.12.0
42 |
43 | 0. install gazebo 11
44 | ```shell
45 | sudo apt-get install gazebo11 libgazebo11-dev
46 | ```
47 | 1. get source code of Ardupilot plugins for gazebo 11.X
48 | ```shell
49 | cd where_you_want
50 | git clone https://github.com/khancyr/ardupilot_gazebo
51 | ```
52 |
53 | 2. build ardupilot plugins for gazebo 11.X
54 | ```shell
55 | mkdir build
56 | cd build
57 | cmake ..
58 | make -j4
59 | sudo make install
60 | echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
61 | ```
62 | 3. add the path of models and worlds provided by ardupilot plugins into .bashrc after you change where_your_ardupilot_gazebo_is below
63 | ```shell
64 | echo 'export GAZEBO_MODEL_PATH=where_your_ardupilot_gazebo_is/ardupilot_gazebo/models' >> ~/.bashrc
65 | ```
66 | 4. add gazebo mode path
67 | ```shell
68 | echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/iq_sim/models" >> ~/.bashrc
69 | ```
70 | 5. launch a gazebo environment with iris model with iq_sim pkg
71 | - get source code of iq_sim
72 | ```shell
73 | git clone https://github.com/Intelligent-Quads/iq_sim.git
74 | ```
75 | - add mode path of iq_sim to gazebo
76 | ```shell
77 | echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/iq_sim/models" >> ~/.bashrc
78 | ```
79 | - build and resource iq_sim pkg
80 | - roslaunch gazebo env of iris_arducopter_runway
81 | ```shell
82 | roslaunch iq_sim runway.launch
83 | ```
84 |
85 | ## 2 Install and run Ardupilot firmware in simulation
86 | ### 2.1 Install Ardupilot
87 | Check Youtube [Drone Dev Environment Ubuntu 20 04 Update](https://youtu.be/1FpJvUVPxL0) to install Ardupilot.
88 |
89 | Read [Setting up the Build Environment (Linux/Ubuntu)](https://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux).
90 |
91 | ### 2.2 Simulate a single quadrotor with Ardupilot
92 | Run ardupilot firmware
93 | ```shell
94 | cd Ardupilot/ArduCopter
95 | sim_vehicle.py -v ArduCopter -f gazebo-iris --console
96 | # OR
97 | sim_vehicle.py -v ArduCopter --console --map
98 | ```
99 | we should find an interface, a council and a terminal.
100 |
101 |
103 |
104 |
105 | ### 3 Enable ROS communication with Ardupilot using mavros
106 | The ROS package mavros provides support for Ardupilot. Then we can run mavros to get drone information into ROS.
107 |
108 | In simulation, we specify '''fcu_url:=udp://127.0.0.1:14551@14555'''.
109 | ```shell
110 | roslaunch mavros apm.launch fcu_url:=udp://127.0.0.1:14551@14555
111 | ```
112 |
113 | With the help of mavros, we can get mavros topics in ROS showing drone information
114 |
115 |
117 |
118 |
119 | Since we command the drone to switch to guided mode and take off to a height of 5m with
120 | ```shell
121 | mode guided
122 | arm throttle
123 | takeoff 5
124 | ```
125 | then we check drone state and position in ROS
126 | ```shell
127 | rostopic echo /mavros/state
128 | rostopic echo /mavros/local_position/pose
129 | ```
130 | with the state being guided and position being 5m
131 |
132 |
134 |
135 |
136 |
137 | ### 3 Test simulation of Ardupilot in Gazebo and communication using mavros
138 |
139 | #### 3.1 Gazebo Garden
140 | 1. run
141 | ```shell
142 | gz sim -v4 -r iris_runway.sdf
143 | ```
144 |
145 | 2. run Ardupilot firmware
146 | ```shell
147 | cd Ardupilot/ArduCopter
148 | sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --map --console
149 | ```
150 |
151 | 3. run mavros to enable communication between Ardupilot and ROS
152 | ```shell
153 | roslaunch mavros apm.launch fcu_url:=udp://127.0.0.1:14551@14555
154 | ```
155 |
156 | 4. make drone switch to guided mode and take off
157 | In the same terminal of running sim_vehicle.py, we use the following commands to make the drone take off
158 | ```shell
159 | mode guided
160 | arm throttle
161 | takeoff 5
162 | ```
163 | We should see the drone take off and hover in Gazebo
164 |
165 |
167 |
168 |
169 | if we echo rostopics /mavros/state and /mavros/local_position/pose, then we should find
170 | - the drone's mode is guided
171 | - its height is 5m.
172 |
173 | #### 3.2 Gazebo 11
174 | 1. run Gazebo environment
175 | ```shell
176 | gazebo --verbose worlds/iris_arducopter_runway.world
177 | ```
178 |
179 | 2. run Ardupilot firmware
180 | ```shell
181 | cd Ardupilot/ArduCopter
182 | ../Tools/autotest/sim_vehicle.py -f gazebo-iris --console --map
183 | ```
184 |
185 | 3. -- 4. are the same with Gazebo Garden
186 |
187 |
188 |
190 |
191 |
--------------------------------------------------------------------------------
/2_3_LightningXLite_Aocoda.md:
--------------------------------------------------------------------------------
1 | # 1 Develop kits
2 | 1. Drone frame:
3 | - Chassis TransTEC Lightning X Lite
4 | - Motor FPV 致盈EX2306 PLUS [site in Taobao](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.27.52b858176s1EdF&id=634695941707)
5 | 2. ESC: Aocoda 60A 4 in 1 [site in Taobao](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xw5sv5&id=682898024012)
6 |
7 | 3. Autopilot and framework
8 | - Aocoda RC H743 [site in Taobo](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xUOMZu&id=679995875558)
9 | - BetaFlight 4.4.0
10 | 4. Onboard computer and OS
11 | - Navidia NX
12 | - Ubuntu 20.04
13 | 5. Transmitter
14 | - RadioLink AT9S Pro
15 | - RadioLink R12DSM [Site in Tabo](https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-22611654662.9.59a41dc7RXezIK&id=561805355565)
16 | 6. Workstation
17 | - Ubuntu 20.04
18 |
19 | # 2 Assembly MAVs
20 | ## 2.1 Build chassis
21 | First, take parts from Lightning X Lite and prepare alex keys.
22 |
23 |
25 |
26 |
27 | We build the base like the picture below. Then, we add the upper part and use M3 screws to fix them together.
28 |
29 | | | |
30 | | ----------------------------------- | ----------------------------------- |
31 | |  |  |
32 |
33 |
34 | It is the time to place them on the chassis
35 |
36 | ### 2.2 Link ESC with power and actuation modules
37 | Lets take Tekko32 for example.
38 |
39 | First, we its order for motors.
40 |
41 |
43 |
44 |
45 | We weld a power wire with XT60 and a 35v 470uf capacitance to the power input of Acoda ESC. Then, we weld four motors in the correct order. We weld them like this
46 |
47 | | | |
48 | | ----------------------------------- | ----------------------------------- |
49 | |  |  |
50 |
51 |
52 | ### 2.3 Connect autopilot to ESC
53 |
54 | We can find the pins of ESC and autopilot at the [Aocoda 60A 4 in 1](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xw5sv5&id=682898024012) and [Aocoda RC H743](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xUOMZu&id=679995875558).
55 |
56 |
57 |
59 |
60 |
61 | More specifically, they share the same structure and we can connect them directly like this
62 |
63 |
65 |
66 |
67 |
68 | ## 2.4 Connect receiver to autopilot
69 | It can been from [Site in Tabo](https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-22611654662.9.59a41dc7RXezIK&id=561805355565) that R12DSM supports S.BUS and PPM protocols working with 4.8v-6v.
70 |
71 | Also, check pins of Aocoda and find RX1 is for receivers. Note that R12DSM needs to be connected 5v instead of 4.5v (example in the image).
72 |
73 |
74 | Therefore, the three ports of R12DSM should be connected to Kakute in the following way:
75 | - "+" of R12DSM ----> 5V of Aocoda
76 | - "-" of R12DSM ----> GND of Aocoda
77 | - "S.B/PPM" of R12DSM ----> RX1 of Aocoda
78 |
79 |
81 |
82 |
83 | ##TODO
84 |
85 |
87 |
88 |
--------------------------------------------------------------------------------
/2_3_Simulation_PX4_Gazebo.md:
--------------------------------------------------------------------------------
1 | # Run Px4-gazebo-ROS simulation
2 | Simulation is to test our methods to robots in a safe way and help debug before real-time experiments.
3 |
4 |
5 | Here, we use PX4-Gazebo to test auto flights. PX4 provides an *Offboard* mode for auto flights that allow onboard computers to take control of drones.
6 |
7 | ## 1. Auto flights with GPS
8 | This is to create a simulation case where **drone navigation information is from GPS and IMU**.
9 |
10 | ### 1.1 Step 1 Config PX4 to use GPS information and offboard mode
11 | First read prearm,arm and disarm specified by [PX4](https://docs.px4.io/master/en/advanced_config/prearm_arm_disarm.html). How can I comment on this: it is not better than shit.
12 |
13 | Arming and disarming decides what cases will stop drones. One of the cases is that should a drone be stopped, or disarmed, if it cannot receive RC signals for a certain amount of time.
14 |
15 | 1. allow arming drones without RC signal
16 | We allow drones armed in offboard modes by setting ```COM_RCL_EXCEPT=4``` like
17 |
18 |
20 | Explanation of COM_RCL_EXCEPT
21 |
22 | Only setting this can we keep our drone armed when there is no RC input.
23 |
24 |
25 | 2. change timeout parameters
26 | Other parameters can be set to allow more time to take actions
27 |
28 | ```bash
29 | COM_OF_LOSS_T = 10
30 | COM_DISARM_LAND =10
31 | COM_DISARM_LAND = -1 means disable this
32 | ```
33 | ### 1.2 Step 2 Choose drone controller library
34 | There are several libraries developed for PX4 drones.
35 |
36 | Here are some good reps:
37 | - Jaeyoung-Lim/mavros_controllers, https://github.com/Jaeyoung-Lim/mavros_controllers
38 | - uzh-rpg/rpg_quadrotor_control, https://github.com/uzh-rpg/rpg_quadrotor_control
39 |
40 | ### 1.3 Step 3 Prepare simulation
41 | 1. start by creating a px4-drone model in simulation in Gazebo
42 | ```shell
43 | roslaunch px4 posix_sitl.launch
44 | ```
45 | 2. call mavros to enable communication between PX4 and PC throught ROS
46 | ```shell
47 | roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
48 | ```
49 | 3. apply controller, for instance geometric_controller, to control drone fly
50 | ```shell
51 | roslaunch geometric_controller sitl_trajectory_track_circle.launch
52 | ```
53 | Note: check if controllers to be run already call mavros or not.
54 |
55 | ## 2 Auto flights with Vicon
56 | This simulation case is to simulate **drone navigation information is from external vision system**, like Vicon and Qualisys.
57 |
58 | Let us take Vicon for example.
59 |
60 |
61 | ### 2.1 Step 1. Config PX4 to use Vicon information
62 | Therefore, we need to configure PX4 such that it takes navigation information from Vicon instead of GPS or IMU. Tutorials are given by PX4, i.e.[EKF2 Tuning/Configuration, Using Vision or Motion Capture Systems for Position Estimation](https://dev.px4.io/v1.11_noredirect/en/ros/external_position_estimation.html)
63 |
64 |
65 |
66 | 1. setting ```EKF2_AID_MASK = 3: vision position fusion + 4: vision yaw fusion```, we set position information is from Vicon.
67 |
68 |
69 |
70 | 2. setting ```EKF2_HGT_MODE = 3: Vision```, we set height information is also from Vicon
71 |
72 |
73 |
74 | ### 2.2 Step 2. Create a fake Vicon and feed Vicon information to Mavros
75 | If you dont want to read details, I have provided packages for you [drone_simulation_tools](https://github.com/EEEManchester/drone_simulation_tools).
76 |
77 | What you need to do is
78 | 1. clone the packages into ```catkin_src```
79 | ```shell
80 | git clone git@github.com:EEEManchester/drone_simulation_tools.git
81 | ```
82 | 2. build the packages
83 | ```shell
84 | catkin build
85 | ```
86 | 3. run launch file
87 | ```shell
88 | roslaunch drone_simulation_tools drone_sim_vision_map_mavros.launch
89 | ```
90 | Finally, two nodes apart from PX4 and Mavros will be running:
91 | + package ```fake_qualisys``` fakes a Vicon sytem taking drone pose information from Gazebo and publishes to topics in a Vicon way
92 | + package ```mocap_to_mavros_sim``` takes drone pose information from Vicon (through a topic) and publish to ```/mavros/vision_pose/pose``` **feeding Vicon information to drone**.
--------------------------------------------------------------------------------
/2_4_Config_Ardupilot.md:
--------------------------------------------------------------------------------
1 | # Install and flash Ardupilot firmware
2 | ## 1 Check pre-builtin firmware
3 | Different pre-built firmware lead to different installation ways.
4 |
5 | It is suggested to ask the manufacturer about the pre-built firmware and its version.
6 |
7 | Our Kakute H7 v1.3 has a pre-built firmware of BetaFlight. Then the version can be found with the help of BetaFlight Configurator that can auto detect the pre-built board and firmware.
8 |
9 | Run BetaFlight Configurator, in Disconnected status, we click Firmware Flasher on the left sidebar, then it will auto detect the board and the firmware version
10 |
11 |
13 |
14 |
15 | Also, we can switch to Connected status by clicking connect on the top right. Click CLI on the left side bar, typing dump on the terminal on the right will give more information
16 |
17 |
19 |
20 |
21 | ## 2 Prepare Ardupilot firmware and flash it
22 | ### 2.1 Install driver and bootloader
23 | Tutorials are given by Ardupilot at [Loading Firmware onto boards without existing ArduPilot firmware¶](https://ardupilot.org/copter/docs/common-loading-firmware-onto-chibios-only-boards.html). Read this before going further.
24 |
25 | ### 2.2 Obtain Ardupilot firmware for KakuteH7
26 | #### Download Ardupilot firmware
27 | Since Kakuteh7's prebuilt firmware is not Ardupilot, installation files should include bootloaders.
28 |
29 | Following steps shown in [Loading Firmware onto boards without existing ArduPilot firmware](https://ardupilot.org/planner/docs/common-loading-firmware-onto-chibios-only-boards.html):
30 |
31 | 1. Go to webpage [https://firmware.ardupilot.org/Copter/stable-4.4.0/KakuteH7/](https://firmware.ardupilot.org/Copter/stable-4.4.0/KakuteH7/)
32 |
33 | 2. Download arducopter_with_bl.hex.
34 |
35 | Or, we can build an Ardupilot firmware ourself.
36 | #### Build Ardupilot firmware from source code
37 | 1. use Waf to build an Ardupilot firmware for the chosen board. Tutorials to use Waf https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md.
38 | - clean previous built firmware
39 | ```shell
40 | cd ardupliot
41 | ./waf distclean
42 | ```
43 | - The available list can be found by
44 | ```shell
45 | cd ardupliot
46 | ./waf list_boards
47 | ```
48 |
49 |
50 |
51 |
52 | - video tutorial for next two steps https://youtu.be/lNSvAPZOM_o.
53 | - choose firmware - it is Pixhawk5X for us
54 | ```shell
55 | cd ardupliot
56 | ./waf configure --board Pixhawk5X
57 | ```
58 |
59 |
60 |
61 |
62 | - build it
63 | ```shell
64 | cd ardupliot
65 | ./waf copter
66 | ```
67 |
68 |
69 |
70 |
71 | - find the built ardupliot file at /ardupliot/build/board_name/bin, like
72 |
73 |
74 |
75 |
76 | ### 2.3 Write Firmware into FC
77 | There are two ways to write Ardupilot firmware into Kakuteh7: STM32CubeProgrammer or BetaFlight Configurator.
78 |
79 | **Connect FC in DFU mode**
80 |
81 | Kakute must be connected in DFU mode. To do that, press the button of Kakute, and then connect it to the work station through a USB port.
82 |
83 | Check if Kakute is in DFU mode, we type
84 | ```shell
85 | sudo dfu-util --list
86 | ```
87 | if we can see something like Internal Flash, shown below, it means Kakute is in DFU mode.
88 |
89 |
91 |
92 |
93 | **Use STM32CubeProgrammer**
94 | 1. Download STM32CubeProgrammer software for Linux from [its official site](https://www.st.com/en/development-tools/stm32cubeprog.html?dl=r%2FDZ7hJ7r7LZnJS4M%2Bj%2FYg%3D%3D%2CrqQw3Z8zMJTVH%2FiHwZRxG3hJGQZEmlN4OzbGJFeuEufO47XaPWyM38drgWLJg%2F%2FukxP6agHPDG343C5L3VFsTTk12wTB%2FrA3oq9%2FGySQjLM3nRGLsi7eIQH9DlYY5OUSVtr25RNJsWoeocZdEfwKn9T7waqy41WKTicuSubVQdd1fd%2B0ydjzklycTlZd3z5c2CLMiyXRW6Dp3sndw6IxOB14m2l2wbA6%2FKQhfiyTPQe7NHIEkvcHbRwAyYBAJ22lSYc%2FzN8rHJSJh9EFm6ND6vltYTICAqp%2BihBh%2BHCVrrPfkE3nf9OUm%2BaBrMd9breQH71gc8%2B31MtN75QSPpBOAHqhdAD1VdxVDoGwk9GEUJVc8oE6F5dxFST1GI2xA6eC)
95 | 1. Install and run STM32CubeProgrammer
96 | 2. Choose USB as connection way and choose USB1, according to your station, as Port. Click flash button next port if nothing shows there.
97 |
98 |
99 |
101 |
102 |
103 | 3. Click Open file and choose downloaded arducopter_with_bl.hex.
104 | 4. Click button Download and it begins wiring Ardupilot into Kakuteh7.
105 |
106 |
107 |
108 |
109 | 5. Click button Disconnect and unplug the USB cable.
110 |
111 | **Use BetaFlight Configurator (To check)**
112 |
113 |
114 | ## 3 Configure Ardupilot
115 | Please read [Mandatory Hardware Configuration](https://ardupilot.org/copter/docs/configuring-hardware.html) first.
116 |
117 | ### 3.1 Choose Frame Class and Type Configuration
118 | Connecting the autopilot with a working station through a USB port. Run Mission Planner.
119 |
120 | Go to Setup-->Mandatory Hardware-->Frame Type.
121 | - Choose Quad in tap Frame Class (Quad stands for Quadrotor)
122 |
123 |
124 |
125 | - Since our chassis and ESC are for BetaFlight type, we need to go to Configuration->Full parameter list, and set FRAME_TYPE to be 12.
126 |
127 | All supported types are available [here](https://ardupilot.org/copter/docs/connect-escs-and-motors.html)
128 |
129 |
131 |
132 |
133 | ### 3.2 Configure receiver and transmitter
134 | 1. Bind receiver and transmitter
135 | Please see [Transmitter](2_6_Transmitter.md) searching for RadioLink AT9S Pro and RadioLink R12DSM.
136 |
137 | For the receiver's protocol, it is suggested to use SBUS. It can be done by pressed the button for 2s and we should see the LED flashes blue.
138 |
139 |
140 | 2. Configure Ardupilot to use transmitter
141 | Ardupilot will automatically detect Radio inputs. There is nothing to be configured.
142 |
143 | When calibrate the transmitter, it is important to set two switches: one to kill, i.e. stop motors, and the other is to change flight modes. They must be on different sides to be user friendly.
144 |
145 |
146 |
148 |
149 |
150 |
151 | ### 3.3 Configure motors and ESCs
152 | #### 3.3.1 motors order and direction
153 | Connect a battery to the drone and also connect the drone to the work station running Mission Planner through a USB port.
154 |
155 | 1. Test motor order
156 | This is to check if the motors are connected to the ESC board correctly, motor 1 is corrected to the ESC's pin for motor 1.
157 |
158 | We can see from [Connect ESCs and Motors](https://ardupilot.org/copter/docs/connect-escs-and-motors.html) that the motors' ordering and direction for BetaFlightX.
159 |
160 |
162 |
163 |
164 |
165 | Then, open Initial Setup->Optional Hardware->Motor Test.
166 |
167 |
168 |
169 |
170 |
171 | Control motors in sequence to see if the correct motors spin:
172 | - motor A - motor 2 in the front right,
173 | - motor B - motor 1 on the back right,
174 | - motor C - motor 3 on the back left,
175 | - motor D - motor 4 on the front left spin.
176 |
177 | It is essential to notice that ArduPilot keeps this tradition naming motor A, B, C, D in a different way than 1, 2, 3, 4 in Motor Test.
178 |
179 | If one motors responds in a wrong way, we need to check if it is connected to ESC at the correct pins.
180 |
181 | 2. Test motor direction
182 |
183 | Motors directions also must be checked tests. As we can see from the image above that
184 | - motor A, or motor 2, must spin in CCW,
185 | - motor B, or motor 1, must spin in CW,
186 | - motor C, or motor 3, must spin in CCW,
187 | - motor D, or motor 4, must spin in CW.
188 |
189 | Dont worry if they are not in the correct direction. There are two ways to to inverse the direction of a motor.
190 |
191 | ##### Change motor direction by switching two wires
192 | Image motor 3 is connected to the ESC with 3 wires. We find its direction needs to be inverted.
193 |
194 |
195 |
196 |
197 | We can inverse the direction by switching any two of the three wires. One example is shown below.
198 |
199 |
200 |
201 |
202 | ##### Change motor direction with BLHeLiSuite32
203 |
204 | Since our ESC is BLHeli32, we can use BLHeLiSuite32 to decide motors' direction.
205 |
206 | Config Ardupilot to enable using to change the motors' directions following the steps in [Pass-Through Support](https://ardupilot.org/copter/docs/common-blheli32-passthru.html).
207 |
208 |
209 | Adjust the motors' directions following the Youtube video [How To Update BLHeli 32 & Change Motor Directions](https://youtu.be/pjPI1xvcntw?si=SvltkIvUdiLomp0G).
210 |
211 | It is suggested to update BLHeli32 firmware first and then begin modify parameters.
212 |
213 |
214 |
215 |
216 | Steps:
217 | - Connect a battery to the drone and a USB cable to a computer.
218 | - We click connect and check buttons. Then, we can find the versions of BLHeili that are 32.8 as shown below
219 |
220 |
222 |
223 | - We update the BLHeili versions. Lets click Flash BLHeili and we can see that it is possible to update to 32.9. Click OK.
224 |
225 |
227 |
228 | - Wait for 4 ESCs to be updated
229 |
230 |
232 |
233 | - Click Disconnect button. Disconnect the battery and the USB cable.
234 |
235 | - Reconnect the battery and the USB cable. Click Connect and Check button to see if all ESCs are updated.
236 |
237 | - However spinning motors to check their directions does not work. More investigation is needed here. We need to go back to MissionPlanner to use Motor Tests to spin motors.
238 |
239 | - For instance, motor 1 needs to reverse its direction. We can modify Section Motor Direction from Normal to Reversed, then we click button Write Setup.
240 |
241 |
243 |
244 | - Click Disconnect button. Disconnect the battery and the USB cable. Reconnect the battery and the USB cable. Use MissionPlanner's Motor Test to check if their directions are correct now.
245 |
246 | After that, disconnect the battery.
247 |
248 | #### 3.3.2 ESCs protocols and calibration
249 | 1. we need to choose protocols for our ESC by setting parameter MOT_PWM_TYPE. More details can be found at [Electronic Speed Controller (ESC) Calibration](https://ardupilot.org/copter/docs/esc-calibration.html?highlight=mot_pwm_type).
250 |
251 | 2. As our ESCs supports multiple protocols, we can choose DShot600 as it suits most UAVs. How to choose protocols can be found at [DShot ESCs](https://ardupilot.org/copter/docs/common-dshot-escs.html?highlight=mot_pwm_type).
252 |
253 | 3. Therefore, we set MOT_PWM_TYPE as 6 that is for DShot600.
254 |
255 |
256 |
257 |
258 |
259 | 4. Whether ESCs need calibration depends on what protocols are. Check Section About ESC Calibration at [Electronic Speed Controller (ESC) Calibration](https://ardupilot.org/copter/docs/esc-calibration.html).
260 |
261 | Since our ESCs use DShot600, there is no need to calibrate them. We can skip this step.
262 |
263 | For others, there are several ways for ESC calibration at [Electronic Speed Controller (ESC) Calibration](https://ardupilot.org/copter/docs/esc-calibration.html?highlight=mot_pwm_type). But Semi Automatic ESC-by-ESC Calibration is suggested, as it easier and time-efficient.
264 |
265 |
266 | Source:
267 | - [Ardupilot wiki: BLHeli32 and BLHeli_S ESCs](https://ardupilot.org/copter/docs/common-blheli32-passthru.html)
268 | - [Ardupilot community: My Method for Iteratively Configuring Motor Ordering and Direction](https://discuss.ardupilot.org/t/my-method-for-iteratively-configuring-motor-ordering-and-direction/67644)
269 | - [Youtube: How To Update BLHeli 32 & Change Motor Directions](https://youtu.be/pjPI1xvcntw?si=3Kq7bqo38yqXqJUn)
270 |
271 |
272 | ### 3.4 Calibrate battery
273 | ##TODO
274 |
275 | ### 3.5 Calibrate sensors: accelerometer and gyroscope
276 | If you prefer using QGroundControl, you can read [Sensor Setup using QGroundControl for Ardupilot](https://docs.qgroundcontrol.com/master/en/SetupView/s.ensors_ardupilot.html).
277 |
278 | If you prefer Mission Planner, you can watch this video [ArduPilot FPV Drone Setup (MICRO FPV ARDUCOPTER!)](https://youtu.be/1dmB8oZFucA?si=_w-zzgJoHhbr73cZ).
279 | #### No compass
280 | Note that there is no compass for Kakute
281 | Note that Kakute does not have an internal compass. We can see from [Kakute' introduction at Holybro](https://holybro.com/products/kakute-h7) that
282 |
283 |
285 |
286 |
287 | IMU is MPU6000 and we can look for MPU6000 information from its datasheet at [MPU6000 at TDK](https://product.tdk.com/en/search/sensor/mortion-inertial/imu/info?part_no=MPU-6000).
288 |
289 |
291 |
292 |
293 | Therefore, we need to set ```COMPASS_ENABLE``` to be 0 which means the compass is disabled.
294 |
295 | #### Calibrate accelerometer
296 | Go to SETUP->Mandatory Hardware->Accelerometer Calibration
297 |
298 |
300 |
301 |
302 | Click button Calibrate Accel, then we place the drone into different pose: flat, left, right etc. We need to first place the drone to the requested pose, and click button Next.
303 |
304 | Then, it is also suggested to Calibrate Level. We put the drone on a flat surface, then click that button.
305 |
306 | #### Calibrate gyroscope
307 | However, it seems MissionPlanner does not offer a gyroscope calibration and it is no necessary? Double check is needed here.
308 |
309 | Now the solution is to run QGroundControl. Go to Vehicle Setup->Sensors->Gyroscope.
310 |
311 | Place the vehicle on a surface and leave it still and click OK to begin.
312 |
313 |
315 |
316 |
317 | ## 4 Arm drone now!
318 | Two things are to be done before arming the drone for the first time.
319 |
320 | First, insert a SD card to the Kakute to record logs. Then in Mission Planner, we need to set parameters such that flight logs are recorded during tasks.
321 |
322 |
323 | Second, check failure safe and kill switch:
324 | 1. check the flight mode is STABILIZE
325 | 2. turn off kill switch
326 | 3. place the left stick on right-down position for 5 seconds and we should see propellers spin.
327 |
328 | If arming failed, please check the following resources:
329 | 1. [PreArm: Logging not started , PreArm: Logging Failed , Bad Logging : copter 3.6.9](https://discuss.ardupilot.org/t/prearm-logging-not-started-prearm-logging-failed-bad-logging-copter-3-6-9/43753)
330 | 2. [Prearm: Logging Failed error](https://discuss.ardupilot.org/t/prearm-logging-failed-error/98750)
331 | 3. [Prearm logging failed and no logs with the version 4.0.3](https://discuss.ardupilot.org/t/prearm-logging-failed-and-no-logs-with-the-version-4-0-3/58475/8)
332 | 4. [Logging failed, preventing arming](https://discuss.ardupilot.org/t/logging-failed-preventing-arming/34060/6)
333 | 5. [“Compass not healthy” preventing arming even though compasses are disabled (using SLAM instead)](https://discuss.ardupilot.org/t/compass-not-healthy-preventing-arming-even-though-compasses-are-disabled-using-slam-instead/45011/2)
334 |
335 |
336 | ## 5 Tune gains for manual flight
337 | Read [Analytical Multicopter Flight Controller PID Optimization](https://discuss.ardupilot.org/t/analytical-multicopter-flight-controller-pid-optimization/109759) first.
338 |
339 | ### 5.1 Use initial tune parameters
340 | Guides can be found at [ArduCopter, Tuning](https://ardupilot.org/copter/docs/common-tuning.html).
341 |
342 | Parameters for motors, battery, and PID gains are needed to be tuned roughly before the first flight. Details can be found at [Setting the Aircraft Up for Tuning](https://ardupilot.org/copter/docs/setting-up-for-tuning.html#setting-up-for-tuning).
343 |
344 | To avoid complex tuning, MissionPlanner gives a tool to set parameters based on the drone. We ca find a tool at SETUP->Mandatory Hardware->Initial Parameter Setup, we can automatically obtain the needed parameters after inputting the size of propellers, the number of cells, and voltages of battery.
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 | If the quadrotor can takeoff, not perfectly, then we can continue tuning.
355 |
356 |
357 | ### 5.2 Interface and guides for tuning attitude and rate
358 | There is a cascade control in Ardupilot framework. During manual flights, usually STABILIZE mode, we input target attitudes to the attitude controller. It computes the target bodyrates, then the motor torques are computed and sent to motors.
359 |
360 | The schematic view is given as below.
361 |
362 |
363 |
364 | source = Copter Attitude Control, https://ardupilot.org/dev/docs/apmcopter-programming-attitude-control-2.html.
365 |
366 | For a cascade controller, we begin with the gains of inner loop. In other words, we first tune the PID gains for bodyrates, which are
367 | - ATC_RAT_PIT_P
368 | - ATC_RAT_PIT_I
369 | - ATC_RAT_PIT_D
370 | - ATC_RAT_RLL_P
371 | - ATC_RAT_RLL_I
372 | - ATC_RAT_RLL_D
373 |
374 | Then, we tune gains for attitude
375 | - ATC_ANG_PIT_P
376 | - ATC_ANG_RLL_P
377 | - ATC_ANG_YAW_P
378 |
379 | PID parameters are in Tab Extended Tuning
380 |
381 |
382 |
383 |
384 |
385 | CUAV provides an explanation of this interface in Chinese.
386 |
387 |
388 |
389 |
390 | source: [CUAV, 扩展调参(pid)](https://doc.cuav.net/tutorial/copter/extension-tuning.html)
391 |
392 | Use the parameters in the table given by TMac
393 |
394 |
395 |
396 |
397 | source: Arducopter Tuning (AUTOTUNE, PIDs & FILTERS, FLIGHT TESTS!), [https://youtu.be/AF6aA2z6rhw?si=U-aBvI92rl0DwJIR](https://youtu.be/AF6aA2z6rhw?si=U-aBvI92rl0DwJIR).
398 |
399 |
400 | ### 5.3 Analyse logs with to tune PID gains
401 | #### 5.3.1 Setup for recording Logs
402 | Logs are essential for us to monitor a drone's status and to tune gains and parameters.
403 |
404 | It is Dataflash, or we call log, that can record flight information. It can be saved on a SD card and downloaded using Mavlink.
405 |
406 | Read [Downloading and Analyzing Data Logs in Mission Planner](https://ardupilot.org/copter/docs/common-downloading-and-analyzing-data-logs-in-mission-planner.html) to undestand how to setup logs.
407 |
408 | Two important parameters are
409 | - *LOG_BACKEND_TYPE* that decides saving logs on a SD card or into board dataflash memory.
410 | - *LOG_BITMASK* chooses what flight data to be recorded, like IMU, GPS, etc.
411 |
412 | The [table 1](https://discuss.ardupilot.org/t/how-to-methodically-tune-almost-any-multicopter-using-arducopter-4-4-x/110842/45?u=robind) and [table 2](https://discuss.ardupilot.org/t/how-to-methodically-tune-almost-any-multicopter-using-arducopter-4-4-x/110842/52?u=robind) of [Analytical Multicopter Flight Controller PID Optimization](https://discuss.ardupilot.org/t/analytical-multicopter-flight-controller-pid-optimization/109759) explain Log message and LOG_BITMASK value.
413 | #### 5.3.2 Log analysis
414 | We can use Mission planner to download a log and see *Downloading logs via MAVLink* of [Downloading and Analyzing Data Logs in Mission Planner](https://ardupilot.org/copter/docs/common-downloading-and-analyzing-data-logs-in-mission-planner.html).
415 |
416 | Flight data are saved in the form of messages in logs, please refer to [Onboard Message Log Messages](https://ardupilot.org/copter/docs/logmessages.html#logmessages) to find which message is for which data. For instance, message ACC records IMU accelerometer data.
417 |
418 | [UAV log viewer](https://plot.ardupilot.org/#/) is a tool for Ardupilot to analyse its logs, which allows us to find ref and actual values of attitude and bodyrates.
419 |
420 | In *Plot Individual Field*, we choose *ATT* to plot reference and actual values of roll, pitch and yaw angles. *RATE* allows us to checking bodyrate tracking.
421 |
422 | One example of checking roll tracking is given here.
423 |
424 |
425 |
426 |
427 | Fly drones and record their data into logs, then tune attitude and rate controllers based on logs.
428 |
429 | Here is one example of tuning just for 2 times
430 |
431 |
432 |
433 |
434 |
435 | ### 5.4 Advanced tuning (optional)
--------------------------------------------------------------------------------
/2_5_Config_BetaFlight.md:
--------------------------------------------------------------------------------
1 | # Install and configure BetaFlight
2 | ## 1 Install and flash BetaFlight firmware
3 |
4 |
6 |
7 |
8 | [BetaFlight](https://betaflight.com/) is flight controller firmware for flying multi-rotor craft and fixed wing craft. Because of its cutting edge performances, BetaFlight is one of the largest flight firmwares in the FPV drone racing and freestyle community.
9 | ## 2.1 Install BetaFlight Configurator
10 | BetaFlight Configurator is a tool for us to flash and calibrate firmwares.
11 |
12 | Setup Guide shows steps to install BetaFlight Configurator.
13 |
14 | 1. Download deb for Ubuntu 20.04.
15 |
16 |
17 |
18 |
19 | 2. Install deb pkg by running
20 | ```shell
21 | sudo dpkg -i betaflight-configurator_10.9.0_amd64.deb
22 | ```
23 | 3. Run BetaFlight Configurator and see the following interface
24 |
25 |
26 |
27 |
28 |
29 | ## 2.2 build BetaFlight for Aocoda H743
30 | #### 2.2.1 Build Betaflight firmware from source
31 | Steps to build firmware H743 for example
32 | 1. install official firmware, i.e. .hex
33 | 2. save the result of ```diff all``` into config.txt
34 | 3. use make to build firmware .hex
35 | ```shell
36 | cd Betaflight
37 | make TARGET=STM32H743
38 | ```
39 | 4. check output message from make
40 | ```shell
41 | text data bss dec hex filename
42 | 466697 6364 90236 563297 89861 ./obj/main/betaflight_STM32H743.elf
43 | ```
44 | 5. get the built firmware
45 | it is located at *BetaFlight/obj/XXX.hex*.
46 |
47 | ## 2.3A flash BetaFlight to Aocoda H743
48 | 1. connect autopilot board to a work station through a USB port. It is supposed to see the LED flashing after connection.
49 |
50 | 2. run BetaFlight Configurator
51 |
52 | 3. write customized firmware
53 | - **enable DFU mode of the autopilot board**
54 | - enable "no reboot sequence"
55 | - enable "Full clip erase" if your previous installation failed and you cannot connect your autopilot
56 | - click "Load Firmware" and choose the obtained firmware XXX.hex.
57 | - click "Flash Firmware" and the process is done when 'programming:successful' can is shown.
58 |
59 |
60 |
61 |
62 | 5. load pre-built config
63 | - wait for 20s for the autopilot board to refresh, and disconnect and reconnect the USB cable if it does not response.
64 | - click button connect on the top right
65 | - choose ''Apply custom defaults''
66 | - click CLI tap
67 | - load file and choose preconfig.txt, i.e. the txt file in the 3rd step or Aoco_H7_Config_Manufacturer.txt in /firmware/Aocoda. Do not worry if you see some errors in the terminal.
68 |
69 |
70 |
71 |
72 | - type save in the terminal and it will automatically reboot. Then after connecting again, we should be able to see a 3D quadrotor model. This 3D model will show the same attitude of the autopilot when we rotate it, which means the firmware can obtain sensor information through ports on Aoco.
73 |
74 |
75 |
76 |
77 | ## 2.3B flash BetaFlight to KakuteH7Mini
78 | 1. Enable DFU mode of KakuteH7Mini and connect it to a base station with Betaflight Configurater running.
79 | 2. Download and flash official firmware by choosing KakuteH7Mini as the target board with
80 | - "no reboot sequence" enabled
81 | - "full chip erase" enabled
82 |
83 |
84 |
85 | Then, click Flash Firmware.
86 | 2. Find the built firmware *BetaFlight/obj/XXX.hex*, chick local firmware and choose it.
87 | 3. Flash own firmware with
88 | - "no reboot sequence" enabled
89 |
90 |
91 |
92 | 4. Reboot and choose ''Apply custom defaults''
93 |
94 | ## 3 Configure and calibrate BetaFlight
95 | **REMOVE propellers before doing anything else**
96 |
97 | ### 3.1 Configure transmitter and receiver
98 |
99 | #### 3.1.1 Bind receiver and transmitter
100 | Please see [Transmitter](2_6_Transmitter.md) searching for RadioLink AT9S Pro and RadioLink R12DSM
101 |
102 | #### 3.1.2 Configure receiver using BetaFlight Configurator
103 | 1. Define ports as Serial (via UART)
104 | 2. Choose protocol
105 | - SBUS and switch the RadioLink R12DSM into S-BUS model when the LED flashes blue.
106 | - PPM not tested
107 | 3. Enable Telemetry port.
108 |
109 |
110 |
111 |
112 | 4. It is suggested to use our transmitter test thrust, roll, pitch, yaw controls by seeing the 3D model's animation. You can modify the sequence of AETR1234 in Channel Map according to your needs. AETR1234 means
113 |
114 |
115 |
117 |
118 | 5. Adjust sticks' sensitivities with the buttons in green circles such that central positions of sticks should correspond to around 1507. **Note** use the buttons in green circles to make the range of each channel to be 1505-2000, especially for the thrust channel as Betaflight does not allow arming if the thrust channel is above 1050 by default.
119 |
120 | ### 3.2 Configure motors
121 | NOTE: REMOVE propellers if you did not do that.
122 |
123 | 1. Check frame type and motor order.
124 |
125 | Choose QUAD X as our chassis is TransTEC Lightning X Lite. Other chassis may lead to different choices here.
126 |
127 | The ESC board has marks, i.e. 1,2,3,4, help place motors in order. It is suggested to choose the same layout as shown here. Please remember the direction of the quadrotor on the autopilot is illustrated by an arrow in white.
128 |
129 |
130 |
131 |
132 | 2. Test motors' spinning
133 |
134 | Now, it is time to test if we can spin motors. To do that, the first thing is to connect a battery to the ESC board while keeping the connect between the work station and the autopilot board.
135 |
136 | Then, it is necessary to set the ESC/Motor Output dropdown to the correct protocol. Usually DShot300 or DShot600 should be chosen for most ESCs available nowadays. Here is the explanation given by BetaFlight Configurator;
137 | - DShot300 is better for FCs with slower processors, like F411 boards. DShot600 is better for faster processors, like anything from the F7 family. F405 may work too, but it can cause too high of a CPI load when a lot of peripherals are in use
138 | - The DShot speed also depends on the gyro (and thus also the PID loop) speed. If you have a gyro that runs at 8kHz (MPU6000), you can use DShot600. If you have a gyro that runs at 3.2KHz (BMI270), you should use DShot300. Using higher DShot speeds on slower gyros shoudn't cause any issues, but it also won't give you any benefits.
139 |
140 | On the right side, we click "I understand the risk", then we can test motors' spinning individually by using sidebars with 1,2,3,4 or together using Master. if The motors, ESC, and the autopilot board are connected correctly, we should be able to see motors are spinning according to our commands.
141 |
142 | 3. Change motors' spinning direction.
143 |
144 | After successfully spinning motors, we need to check the motors' direction if they are in the correct way that is shown on the left.
145 |
146 | As we can see, motor 1 and 4 are in clockwise direction, while motor 2 and 3 are in counterclockwise direction. If one or two motors are not spinning in the correct way, then we can click button Motor direction and change the direction of them.
147 |
148 |
150 |
151 |
152 | Choose motor by index first, and then if the direction is wrong, we just need to click "Reverse".
153 |
154 | ### 3.3 Configure flight modes
155 |
156 | There are several modes:
157 | - Arm mode. It used as a kill switch as it can enable and disable motor output.
158 | - Angle mode. The input to the autopilot board is angle, that is usually chosen for manual flights.
159 | - Angle_rate_hold. This mode can receive angle commands and bodyrate commands, which is used for auto flights.
160 |
161 | 1. Set Arm mode.
162 | - Click Add Range
163 | - Choose Auto and switch SwF of transmitter on and off, then it will automatically set the channel of SwF, maybe AUX 1, for mode Arm.
164 | - There is a yellow bar for every mode. In fact, the area covered by that corresponds to the transmitter' channel's status.
165 |
166 | Take Arm for instance, when the channel is in the yellow bar's area, the drone is armed, while the channel is outside, the drone is disarmed.
167 |
168 |
169 |
170 |
171 | 2. Set Angle mode and Angle_rate_hold mode
172 | Make them use the same channel of SwG, then adjust the yew bar for two stages where one stage of SwG corresponds to mode Angle, and the other lies in mode Angle_rate_hold.
173 |
174 |
175 |
176 |
177 | Read the following resources:
178 | 1. Modes Tab from BetaFlight, [https://betaflight.com/docs/wiki/configurator/modes-tab](https://betaflight.com/docs/wiki/configurator/modes-tab)
179 | 2. Betaflight 4.3 Modes Tab, [https://youtu.be/kDAotpevszs?si=QKJp7 5aN2eq35jE8](https://youtu.be/kDAotpevszs?si=QKJp75aN2eq35jE8)
180 |
181 | Other modes can be found at [Modes](https://betaflight.com/docs/development/Modes):
182 | 1. If we link two modes, then enabling one will trigger the other.
183 | 2. ACRO mode takes commands as body rates from pilots. This mode is usually used in FPV. In fact, you cannot find this mode and it is a default mode: the drone switches to ACRO mode if we arm the drone while no mode, like Angle mode, is chosen.
184 |
185 |
186 |
187 | ### 3.4 Configure power & battery
188 | 1. check if BetaFlight Configurator find the correct number of cells.
189 |
190 |
191 | 2. Choose battery source
192 | Two options are available here
193 | - Onboard ADC means the voltage and current are measured by the autopilot's ADC.
194 | - ESC means they are measured by ESC telemetry. To use ESC telemetry for voltage measurement, the ESC board needs have a pin named after telemetry that is connected to the autopilot. A pin named after current is needed for current measurement.
195 |
196 | We choose Onboard ADC when batteries of 2s-6s are used, then ESC is a better choice when batteries of more than 6s are chosen.
197 |
198 |
199 |
200 |
201 |
202 |
203 | 3. Amperage Meter (Current)
204 | - This depends on ESC instead of autopilots.
205 | - The parameter Scale in Amperage Meter should be given by manufacturer. As for our Aocoda 3060A 4 in 1 [site in Taobao](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xw5sv5&id=682898024012), the scale is set to be 160. It is 120 for KakuteH7Mini [site at Holybro](https://holybro.com/products/kakute-h7-mini-stacks).
206 |
207 |
208 |
209 |
210 | 4. Voltage Meter (Voltage)
211 | Here is what we should do first
212 | - connect a battery to the drone
213 | - connect a voltage meter to the battery to read the voltage
214 |
215 |
217 |
218 |
219 |
220 | Click the button Calibration, entre the voltage value read from the meter anc lick button Calibrate.
221 |
222 |
223 |
224 |
225 | After hearing the music, we can click the button Save.
226 |
227 |
228 |
229 | ### 3.4 Calibrate sensors
230 |
231 | Aocoda has embedded an accelerometer and a gyroscope.
232 |
233 | First let us calibrate the accelerometer. Place the drone on the flat surface, and then click the button Calibrate Accelerometer.
234 |
235 | It finishes when the message "Accelerometer calibration finished" is displayed on the top left. Note do not move the drone during the calibration.
236 |
237 |
238 |
239 |
240 |
241 | ### 3.5 First flights and PID tuning
242 | ##TODO
--------------------------------------------------------------------------------
/2_6_Transmitter.md:
--------------------------------------------------------------------------------
1 | # Big picture of transmitter, receiver and autopilot
2 |
3 |
5 |
6 | source: https://oscarliang.com/rc-protocols/#RX-Protocols
7 |
8 | ## 1 Configure transmitter
9 | 1. create new model such that one model for one receiver
10 | - press mode to entre basicConfig menu
11 | - choose Model Sel
12 | - select a new model for this receiver. It means that if this transmitter already uses model 1 and 2 for another 2 receivers, then we should select other models, like 3. But remember which model is for which receiver.
13 | - go back to basic menu by pressing End and entre Model Type. choosing multirotor or your type of UAV in option TYPE.
14 |
15 | 3. set transmitter channel
16 | - get 12 channels:
17 | - press mode to entre basic menu
18 | - entre System and change "CH-Select" to be "12CH" such that it provide 12 channels for this transmitter
19 | - change channel mapping
20 | - our aims is to use SwF (2-stage, on the left) for kill switch, Swg (3-stages, on the right)for switching flight modes
21 | - channels 1,2,3,4 are by default for thrust, yaw, roll and pitch, so we set SwF as channel 6 and SwG as channel 7.
22 | - press mode to entre basic menu
23 | - choose AUX-CH, and set SwF for CH6 and SwG for CH7.
24 |
25 | 4. modify/reverse transmitter channel
26 | - problem: it could be possible that channel mapping is in the opposite way: when we push roll stick, the drone flip backward, while is it supposed to flip forward.
27 | - solution:
28 | - press mode to entre basic menu
29 | - entre Reverse, go the wrong channel and then switch to REV if it is NOR, or switch to NOR or it is REV.
30 |
31 | ## 2 Configure receiver
32 | One receiver can possibly support different protocols. For instance, RadioLink R12DSM can support both SBUS and PPM.
33 |
34 | Therefore, it is significant to check which can be supported by the chosen autopilot and adjust the receiver to work using that protocol.
35 |
36 | ## 3 Bind transmitter and receiver
37 | - Binding RadioLink AT9S Pro and RadioLink R12DSM is shown at [RadioLink at Youtube: How to| Make RadioLink receiver R12DSM bind with transmitters](https://www.youtube.com/watch?v=KpSXgxUHlPw&ab_channel=RadioLink).
--------------------------------------------------------------------------------
/2_Simulation_ROS_Ardupilot/Ardupilot_Gazebo_Garden_Mavros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_ROS_Ardupilot/Ardupilot_Gazebo_Garden_Mavros.png
--------------------------------------------------------------------------------
/2_Simulation_ROS_Ardupilot/gz_installed_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_ROS_Ardupilot/gz_installed_test.png
--------------------------------------------------------------------------------
/2_Simulation_Setup_ROS_PX4/Installed_mavros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_Setup_ROS_PX4/Installed_mavros.png
--------------------------------------------------------------------------------
/2_Simulation_Setup_ROS_PX4/gazebo_errors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_Setup_ROS_PX4/gazebo_errors.png
--------------------------------------------------------------------------------
/2_Simulation_Setup_ROS_PX4/px4_gazebo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_Setup_ROS_PX4/px4_gazebo.png
--------------------------------------------------------------------------------
/2_Simulation_Setup_ROS_PX4/px4_ros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_Setup_ROS_PX4/px4_ros.png
--------------------------------------------------------------------------------
/2_Simulation_Setup_ROS_PX4/px4_version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/2_Simulation_Setup_ROS_PX4/px4_version.png
--------------------------------------------------------------------------------
/3_Simulation_Gazebo_Control/COM_RCL_EXCEPT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/3_Simulation_Gazebo_Control/COM_RCL_EXCEPT.png
--------------------------------------------------------------------------------
/3_Simulation_Gazebo_Control/Setting_4_Vicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/3_Simulation_Gazebo_Control/Setting_4_Vicon.png
--------------------------------------------------------------------------------
/3_Simulation_Gazebo_Control/Setting_4_Vicon_height.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/3_Simulation_Gazebo_Control/Setting_4_Vicon_height.png
--------------------------------------------------------------------------------
/3_Simulation_Gazebo_Control/Setting_4_Vicon_position.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/3_Simulation_Gazebo_Control/Setting_4_Vicon_position.png
--------------------------------------------------------------------------------
/4_Experiment_Communication_Pi_Pixhawk.md:
--------------------------------------------------------------------------------
1 | # Communication between Raspberry Pi 4B+ and Pixhawk 5.
2 |
3 | There are two ways for communication between a Pixhawk 5 and a Raspberry pi 4B+:
4 | - through serial ports
5 | - through USB ports
6 |
7 | There are also different methods to power Raspberry Pi:
8 | - through battery and BEC
9 | - through autopilot (not tested)
10 |
11 | ## 1 Communication through serial ports of Raspberry Pi
12 | ### 1.1 Connect Raspberry Pi and Pixhawk 5
13 | Let us have a look at all the ports provided by Pixhawk 5.
14 |
15 |
17 | Pixhawk ports
18 |
19 | Therefore, we will use Telem 2 as the port for Raspberry Pi.
20 |
21 | The details of Telem 2 is shown by the figure below
22 |
23 |
25 | Pins of Tele 2 port
26 |
27 |
28 | Pins in red and black can be indentified by using cables with Pixhawk. Here is an example.
29 |
30 |
32 | Pixhawk ports
33 |
34 |
35 |
36 |
38 | Pixhawk ports
39 |
40 |
41 | We need to make a wire to connect them like the way below
42 |
43 |
45 | Pixhawk 5x - Raspberry Pi
46 |
47 |
48 | ### 1.2 Set parameters on PX4
49 | Some parameters are needed to be modified to enable serial communication between Pixhawk and Raspberry Pi.
50 |
51 | Here are the list
52 | - MAV_2_CONFIG = TELEM 2
53 | - MAV_2_MODE = Onboard
54 | - MAV_2_RATE= 80000 Bytes/s
55 | - MAV_2_FORWARD = True
56 | - SER_TEL2_BAUD = 921600 baud
57 |
58 |
59 | ## 2 Communication through USB ports of Raspberry Pi
60 |
61 |
62 |
63 |
64 | https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply
65 |
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Pi.md:
--------------------------------------------------------------------------------
1 | # Set Raspberry Pi 4B as an onboard computer
2 | Big picture of a drone with a Pixhawk 5 and a Raspberry Pi 4b.
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 | ## 1. Brief introduction of onboard computer (Raspberry Pi 4B)
13 | Onboard computer is responsible for transfer commands from base station to autoploit and convert sensor information from autoploit, cameras etc. back to Onboard computers.
14 |
15 | Choices for onboard computers are Raspberry Pi, Odroid, Tegra K1 etc. Here we show how to buid a drone using Raspberry Pi, i.e. Raspberry Pi 4B.
16 |
17 |
20 | Raspberry Pi 4B
21 |
22 |
23 | Raspberry Pi requires an operating system (OS). However, The supported OSs by Raspberry Pi depend on versions. Raspberry Pi 4B can only support Ubuntu desktop 21.04 (Not LTS), Raspberry Pi OS, Ubuntu server 20.04 (LTS), Ubuntu Core 20, which can be found at (see [Ubuntu for Raspberry Pi](https://ubuntu.com/download/raspberry-pi)).
24 |
25 | ## 2. Tools for installing operating systems on Raspberry Pi 4B
26 | **Note:** An image is provided for team members that is Ubuntu Mate for Raspberry Pi 20.04 with ROS and mavors.
27 | Raspberry Pi Imager is official tool to install OS for raspberry pi boards. It can be downloaded from [https://www.raspberrypi.com/software/](https://www.raspberrypi.com/software/).
28 |
29 | A Youtube video is available [here](https://youtu.be/y45hsd2AOpw).
30 |
31 |
32 |
34 | Raspberry Pi Imager
35 |
36 |
37 | Here are several potions for OS to be used on Raspberry Pi 4b:
38 | - Ubuntu Desktop/Server 20.04
39 | - **(recommended)** Ubuntu Mate 20.04 for Raspberry Pi
40 | - Raspberry Pi OS
41 |
42 | ## 3. Install Ubuntu Server 20.04
43 | A server is lighter than a Desktop as it does not contain packages for GUI and Office. Thus, choosing server is also a good choice for an onboard computer.
44 |
45 | 1. Choose Ubuntu Server 20.04 LTS using Raspberry Pi Imager.
46 | 2. Insert the SD carder in Raspberry Pi and start it with a mouse, keyboard and a monitor connected.
47 | 3. Log in Ubuntu server with
48 | - username ubuntu
49 | - password ubuntu
50 | 4. Connect Raspberry Pi to Wifi using netplan explained [here](https://itsfoss.com/connect-wifi-terminal-ubuntu/)
51 | - check Internet class ```ls /sys/class/net```
52 | - find and edit config file ```sudo nano /etc/netplan/50-cloud-init.yaml```
53 | - put available wifi infor as
54 | ```
55 | wifis:
56 | wlan0:
57 | dhcp4: true
58 | optional: true
59 | access-points:
60 | "WIFI_ID":
61 | password: "WiFi_password"
62 | ```
63 | - apply this config ```sudo netplan generate```
64 | - connect to Wifi ```sudo netplan apply```
65 | 5. **reboot**
66 | 6. Install Mate Desktop environment
67 | - ```sudo apt install taskel```
68 | - ```sudo apt install ubuntu-mate-desktop```
69 | - choose gmd3 or lightdm (recommended)
70 |
71 | ## 4. Install Ubuntu Mate (for Raspberry Pi) 20.04 from Ubuntu Server 20.04
72 | Repeat Steps 1-5 above in Step 2A.
73 |
74 | 6. Use Desktopify to convert Ubuntu server 20.04 to Ubuntu Mate 20.04. A video tutorial is available [Install Ubuntu Mate On the Raspberry Pi 4 with Desktopify The Fastest Desktop Experience For The Pi4](https://youtu.be/zo5eReiXYuo).
75 | - ```cd ~```
76 | ```git clone https://github.com/wimpysworld/desktopify.git```
77 | - ```cd desktopify```
78 | ```sudo ./desktopify --de ubuntu-mate```
79 | Take the sd card and put it into the sd slot.
80 |
81 | Connect the Raspberry Pi with a monitor through a HDMI cable, a mouse through a USB port, a keyboard through a USB port. Then, use the power supply module provided by the manufacturer.
82 |
83 | Now, we should see a Ubuntu Mate start in the monitor. Here is what we need to do for configure basics of the OS.
84 |
85 | 1. Boot your Ubuntu MATE
86 | - set language and user names
87 | - user name: droneREEG
88 | - passwork: 123456
89 | - computer name: drone1 (drone2 for a second drone)
90 | - this can also be done by specifying options of Raspberry Pi Imager before installing
91 | 2. Disable auto update in *Software&Updates > Updates*
92 | - stop ubuntu kernel update
93 | ```
94 | sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
95 | ```
96 |
97 | ## 5 Install Raspberry Pi OS (not fully tested)
98 | Raspberry Pi OS is an official operating system supported by Raspberry Pi.
99 |
100 | After understanding how to use Raspberry Pi Imager, a choice is going to be made for choosing a version of Raspberry Pi OS, yes, another choice of versions :( . In fact, Raspberry Pi OS is built using a Linux kernel of Debian, therefore we can find Debian version information of each Raspberry Pi OS. Raspberry Pi OS uses Debian 11 (Bullseye), while Raspberry Pi OS (Legacy) takes Debian 10 (Buster).
101 |
102 |
104 | Raspberry Pi OS with Debian 11 (Bullseye)
105 |
106 |
107 |
109 | Raspberry Pi OS (Legacy) with Debian 10 (Buster)
110 |
111 |
112 |
113 | Wait a minute. Think about the most important tools are to be used on onboard computers; that is ROS. Choosing Raspberry Pi OS (Debian 11) or Raspberry Pi OS (Legacy) (Debian 10) depends on which one allows us to use a proper ROS.
114 |
115 | Till April 2022, there two ROS options to choose: ROS Melodic and ROS Noetic. Noetic is developed for Debian 10 (Buster) and Melodic is for Debian 9 (Stretch). So, Debian 11 (Bullseye) is not supported yet for ROS 1 or never. The only choice is Debian 10 (Buster), then we must install Raspberry Pi OS (Legacy).
116 |
117 | Flashing Raspberry Pi OS (Legacy) into a SD card and use that to boot Raspberry Pi.
118 |
119 |
120 | ## 6 Install Ubuntu Core for Raspberry Pi
121 | ### 6.1 Introduction of Ubuntu Core
122 | In one word, **Ubuntu Core** is the optimised version of Ubuntu for robotics and ROS. **Snaps**, the de facto container for packaging software on Ubuntu, enhanced to support ROS applications.
123 |
124 | [Ubuntu official site](https://ubuntu.com/core/docs) states that
125 | - Ubuntu Core is a version of the Ubuntu operating system designed and engineered for **Internt of Things (IoT)** and embedded systems.
126 | - Ubuntu Core is ideal for embedded devices because it manages itself. Whether it’s running on an **Intel NUC** hidden for media streaming, or a **Raspberry Pi** handling garage door automation, Ubuntu Core remains transparent, trustworthy and autonomous.
127 |
128 | More information about how Ubuntu supports robotics can be found at
129 | - [Robotics document](https://ubuntu.com/robotics/docs)
130 | - [Robotics explanation](https://ubuntu.com/robotics/docs/explanation)
131 |
132 | ### 6.2 Tutorial for using ROS on Ubuntu Core
133 | https://ubuntu.com/core/docs/uc20/install-raspberry-pi#heading--requirements
134 |
135 |
136 | Ref:
137 | - [How to get started with Ubuntu Core on Raspberry Pi](https://www.youtube.com/watch?v=aekZhezFCHM&t=681s&ab_channel=CanonicalUbuntu)
138 | - [Your first robot, part 1: A beginner's guide to ROS and Ubuntu Core](https://www.youtube.com/watch?v=KidVVqbsIHI&ab_channel=KyleFazzari)
139 | - [Ubuntu Core](https://www.youtube.com/watch?v=6NDWqH1SrGs&list=PLwFSk464RMxk54Xdcb90rgfoyRlKUOjLM&ab_channel=CanonicalUbuntu)
140 | ##TODO
141 | Ubuntu ESM for ros [ROS Expanded Security Maintenance](https://ubuntu.com/robotics/ros-esm)
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Drone_components.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Drone_components.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/GPIO_Raspberry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/GPIO_Raspberry.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Mate_rapspberry.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Mate_rapspberry.jpg
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Pi_power_supply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Pi_power_supply.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Pixhawk_raspberry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Pixhawk_raspberry.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/RaspberPi_4B.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/RaspberPi_4B.jpg
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Raspberry_OS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Raspberry_OS.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Raspberry_OS_option1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Raspberry_OS_option1.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/Raspberry_OS_option2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/Raspberry_OS_option2.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/check_ssh_installation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/check_ssh_installation.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ntp_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ntp_on.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ntp_status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ntp_status.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/px4_port_raspberry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/px4_port_raspberry.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/px4_telem2_ports.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/px4_telem2_ports.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/px4_telen2_ports_drone.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/px4_telen2_ports_drone.jpeg
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/raspberry_pi_imager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/raspberry_pi_imager.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ssh_host_connect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ssh_host_connect.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ssh_host_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ssh_host_name.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ssh_pwd_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ssh_pwd_user.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/ssh_request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/ssh_request.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/static_IP.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/static_IP.png
--------------------------------------------------------------------------------
/4_Experiment_OnboardComputer_Setup/write_mate_2004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/4_Experiment_OnboardComputer_Setup/write_mate_2004.png
--------------------------------------------------------------------------------
/4_Experiment_ROS_Communication_Pi_BaseStation.md:
--------------------------------------------------------------------------------
1 | # ROS communication through WIFI between onboard computer and base station
2 |
3 | ## 1 Install ROS and ROS pkgs for onboard computer
4 | ### 1.1 Install ROS
5 | - for team members, please skip this step
6 | - for Ubuntu or Ubuntu Mate, please refer to [ROS Installation](http://wiki.ros.org/ROS/Installation).
7 |
8 | - for Raspberry Pi OS,
9 | - ROS Melodic is still possible to be installed on Raspberry Pi with Raspbian Buster following a different approach [ROSberryPi/Installing ROS Melodic on the Raspberry Pi](http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Melodic%20on%20the%20Raspberry%20Pi).
10 |
11 | - A tutorial to install Melodic on Raspberry Pi OS is given [here](https://www.linkedin.com/pulse/easiest-way-install-ros-melodic-raspberrypi-4-shubham-nandi/).
12 | ### 1.2 Install mavros
13 | - for team members, please skip this step
14 | - for others, please ref to Section Simulation_ROS.
15 |
16 |
17 | ## 2 Enable WIFI communication between onboard computer and base station
18 |
19 | ### 2.1 Set static IP address for onboard computer and base station
20 | Connect to WIFI and open Internet settings.
21 |
22 | Find Tap IPv4, then choose Manual instead of DHCP.
23 |
24 | Then, input an address like 192.168.31.191 where the router's address is 192.168.31.1. Note here, the first three parts must be the same with your router's. Netmask usually should be ```255.255.255.0```. More details can be found at [Subnets of Linux Journey](https://linuxjourney.com/lesson/subnets).
25 |
26 |
27 |
28 |
29 |
30 | ### 2.2 Set ssh for remote login
31 | Install ssh on both machines
32 | ```shell
33 | sudo apt install openssh-client openssh-server
34 | ```
35 | and we ca check the installation by
36 |
37 |
38 |
39 |
40 |
41 | On base station, we can connect to Raspberry Pi with
42 | ```shell
43 | ssh username@servername
44 | ```
45 | where servername can be IP address like 192.168.31.171 and site address like example.com
46 |
47 | Lets say our username is drone1 and its pws is 123456.
48 |
49 | From base station to connect.
50 | 1. We start ssh request
51 | ```shell
52 | ssh drone1@192.168.31.171
53 | ```
54 | and entre yes then
55 |
56 |
58 |
59 |
60 | 2. We entre the pwd of the user of sever, i.e. drone1, which should be 123456.
61 |
62 |
64 |
65 |
66 | 3. We are now in the server as the user drone1, as you can see a new user name and a new machine name in the terminal.
67 |
68 | 4. It is not surprised that we dont want to type ip address every time. Since we know the ip address of the Raspberry Pi wont change, it is nature to think can we type something meaningful as long as my machine can understand my input and link that to the correct ip address.
69 |
70 | Here, we can modify /etc/hosts to enable our machine to do that.
71 |
72 | We give a name for our Raspberry Pi as dronepi1, as
73 |
74 |
75 |
76 |
77 | 5. Now, we can connect to the Raspberry Pi with drone1@dronepi1
78 |
79 |
80 |
81 |
82 | References on ssh:
83 | 1. [How to use SSH (to connect to another computer), Youtube](https://www.youtube.com/watch?v=3bQRaOPns9k&ab_channel=SyntheticEverything)
84 |
85 | 2. [Running ROS across multiple machines](http://wiki.ros.org/ROS/Tutorials/MultipleMachines)
86 |
87 | 3. [How to enable SSH on Linux Ubuntu (Easy step by step guide), Youtube](https://www.youtube.com/watch?v=Wlmne44M6fQ&ab_channel=KnowledgeSharingTech)
88 |
89 | 4. [SSH in Chinese](https://wangdoc.com/ssh/client)
90 |
91 | ## 3 Set ROS communication through WIFI between onboard computer and base station
92 |
93 | ### 3.1 time synchronisation with ntp
94 | We are going to use ntp service for time synchronisation such that time of onboard computer is based on that of base station.
95 |
96 | First of all, install ntp by running
97 | ```bash
98 | sudo apt install ntp
99 | ```
100 | Check if ntp service is on or not
101 | ```bash
102 | service --status-all
103 | ```
104 |
105 |
107 | Ntp service is on
108 |
109 | and check its status
110 |
111 | ```bash
112 | sudo systemctl status ntp.service
113 | ```
114 |
115 |
117 |
118 | Check all the servers
119 | ```bash
120 | ntpq -p
121 | ```
122 | ### 3.2 time synchronisation with chrony (todo)
123 |
124 | ### 3.2 ROS communication between Raspberry Pi and base station
125 | Once we can ensure Internet connection between the onboard computer and our base station, we can process ROS communication between them.
126 |
127 | We only need to specify the IP addresses of onboard computer and base station into ROS.
128 |
129 | 1. for the onboard computer, open ```.bashrc``` and add
130 | ```bash
131 | export ROS_MASTER_URI=http://IP_base_station:11311
132 | export ROS_IP=IP_onboard_computer
133 | ```
134 |
135 | 2. for the base station, open ```.bashrc``` and add
136 | ```bash
137 | #export ROS_MASTER_URI=http://master:11311
138 |
139 | export ROS_MASTER_URI=http://IP_base_station:11311
140 | export ROS_IP=IP_base_station
141 | ```
142 | Note: this configuration only works for THE WLAN. We may need to modify the IP addresses for different WLANs.
143 |
144 | Also, we need to comment the two commands below and uncomment the one above in order to do local simulation and experiments.
145 |
146 | More details can be found at [Running ROS on multiple machines](https://husarion.com/tutorials/ros-tutorials/5-running-ros-on-multiple-machines/).
--------------------------------------------------------------------------------
/5_Experiment_Hardware_Setup.md:
--------------------------------------------------------------------------------
1 | # Hardware setup
2 | ## Big picture of Pixhawks_Rapebrrypi
3 |
4 |
6 | PX4 system and Companion Computer (https://docs.px4.io/master/en/concept/px4_systems_architecture.html)
7 |
8 |
9 | ## Power Raspberry Pi
10 | ### Power requirements of Raspberry Pi 4
11 | Power supply for Rasberry Pi can be found [Power Supply](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply).
12 |
13 |
15 | PX4 system and Companion Computer (https://www.raspberrypi.com/products/raspberry-pi-4-model-b/specifications/)
16 |
17 |
18 |
19 |
21 | USB ports of Raspberry Pi (https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#universal-serial-bus-usb)
22 |
23 |
24 | https://www.raspberrypi.com/documentation/computers/os.html#gpio-and-the-40-pin-header
25 |
26 | https://pinout.xyz/pinout/5v_power#
27 |
28 | PX4 is configured by default to connect to a companion computer connected to the TELEM 2 serial port. No additional PX4-side configuration should be required if you use this port
29 |
30 | ### Solutions to power Raspberry Pi 4
31 |
32 |
33 |
34 | ### Setup Wifi rooter in F46
35 |
36 | username and password are admin.
37 |
--------------------------------------------------------------------------------
/5_Experiment_Hardware_Setup/raspberry_bard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/5_Experiment_Hardware_Setup/raspberry_bard.png
--------------------------------------------------------------------------------
/5_Experiment_Hardware_Setup/raspberry_usb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/5_Experiment_Hardware_Setup/raspberry_usb.png
--------------------------------------------------------------------------------
/5_Experiment_Hardware_Setup/schematic_pixhawks_rasperry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/5_Experiment_Hardware_Setup/schematic_pixhawks_rasperry.png
--------------------------------------------------------------------------------
/6_Vicon/ECL_overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/ECL_overview.png
--------------------------------------------------------------------------------
/6_Vicon/Vicon_cage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_cage.jpg
--------------------------------------------------------------------------------
/6_Vicon/Vicon_calibrate.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_calibrate.PNG
--------------------------------------------------------------------------------
/6_Vicon/Vicon_live.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_live.png
--------------------------------------------------------------------------------
/6_Vicon/Vicon_object.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_object.PNG
--------------------------------------------------------------------------------
/6_Vicon/Vicon_origin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_origin.png
--------------------------------------------------------------------------------
/6_Vicon/Vicon_system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/Vicon_system.png
--------------------------------------------------------------------------------
/6_Vicon/object_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/object_name.png
--------------------------------------------------------------------------------
/6_Vicon/static_ip_base_station.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/static_ip_base_station.png
--------------------------------------------------------------------------------
/6_Vicon/vicon_bridege_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/vicon_bridege_setting.png
--------------------------------------------------------------------------------
/6_Vicon/vicon_frame.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/vicon_frame.PNG
--------------------------------------------------------------------------------
/6_Vicon/vicon_in_ros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/vicon_in_ros.png
--------------------------------------------------------------------------------
/6_Vicon/vicon_rename_in_ros.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/vicon_rename_in_ros.png
--------------------------------------------------------------------------------
/6_Vicon/vicon_ros_msg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/vicon_ros_msg.png
--------------------------------------------------------------------------------
/6_Vicon/wand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/wand.png
--------------------------------------------------------------------------------
/6_Vicon/yaw_oritation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/6_Vicon/yaw_oritation.png
--------------------------------------------------------------------------------
/6_Vicon_Setup_Use.md:
--------------------------------------------------------------------------------
1 | # Use Vicon for drone indoors flight
2 |
3 | Here is where you are going to fly drones with Vicon at the University of Manchester.
4 |
5 |
6 |
7 |
8 | Indoor flights with a drone and a Vicon system is illusrated by the figure below.
9 |
10 |
11 |
12 |
13 | Several points to understand this figure:
14 | - every thing is connected to a WIFI router,
15 | - Vicon system detects the markers attahced to a drone and computes its pose,
16 | - base station runs the package vicon_bridge to get Vicon information into ros topics,
17 | - control signals computed by base station are sent to drone by publishing to ros topics that are provided by mavros.
18 |
19 |
20 | ## 1. How to configurate Vicon for the 1st time
21 | ### 1.1 Start Vicon system at Vicon computer
22 | 1. Satart *Vicon tracker*
23 | 2. **Calibrate system** (do it everytime before experiments)
24 | - dance with favourite music waving your magic wand.
25 |
26 |
27 |
28 | - camera's light becomes green: it mean OK.
29 | - all cameras's light becoming blinking if they are all calibrated.
30 |
31 |
32 |
33 | 3. Set origin
34 | - set volume origin
35 | - put the bar on the ground where you want **the origin** is
36 | - and click *Start* and *Set*
37 | - you should find the cameras' position in the **3D perspective** as the same as the real world.
38 |
39 |
40 |
41 | - **NOTE** the red-gren-bleu coordinate at the left bottom indicates x, y, z directions.
42 |
43 | 4. Recalibrate Vicon
44 | - **Donot touch cage or gate to impact cameras**.
45 | - once a camera's light is blinking, redo calibration.
46 | 5. Set static IP
47 | - set a static IP for Vicon system when connecting to WIFI.
48 | ### 1.2 Build rigid body in Vicon at Vicon computer
49 | 1. Put markers on a drone
50 | - not symmetric
51 | - not covered
52 | - put drone in flight cage and check if all markers can be seen in Vicon
53 | 2. In *Vicon tracker*, Choose *Objects* tag and select all markers
54 | 3. Name object and then create
55 | 4. Select object in *Object* Tag: the object DRONE_z is chosen.
56 |
57 |
58 |
59 | 6. *Go Live*
60 |
61 |
62 |
63 | and we should see the object like below
64 |
65 |
66 |
67 |
68 | ### 1.3 Get Vicon information in ros at base station
69 | This is done at base station.
70 |
71 | 1. Download and build ros package *vicon_bridge* from EEEManchester [https://github.com/EEEManchester/vicon_bridge.git](https://github.com/EEEManchester/vicon_bridge.git).
72 |
73 | 2. Connnect base station to WIFI with a static IP, like 192.168.10.XX
74 | - given a base station with Ubuntu 20.04 and WIFI name being *drone_wifi-5GHz*,
75 | - WIFI settings can be used configure static IP
76 |
77 |
78 |
79 |
80 | - change IPv4 method to be *Manual* meaning that IP adress for this base statino is set manually by us instead of being allocated dynamically,
81 | - put a user-defined address in the first line below *Address*. Puting 192.168.1.21 means that once this base station is connected to *drone_wifi-5GHz*, its IP address will always be 192.168.1.21.
82 | 3. Check WIFI connection between base station and Vicon system
83 | - at vicon computer, ping base station with the static IP just set
84 | ```shell
85 | ping base_station_IP
86 | ```
87 | - at base tation, ping vicon system,
88 | ```shell
89 | ping vicon_system_IP
90 | ```
91 | - this can also be used to test WIFI connection among Vicon, base station and drone. For instance, at drone, do
92 | ```shell
93 | ping base_station_IP
94 | ping vicon_system_IP
95 | ```
96 |
97 | 4. in Vicon launch file, put the IP address of Vicon system as the
98 | **datastream_hostport**, like 192.168.10.183::801 in the launch file below.
99 |
100 |
101 |
102 | 5. run vicon_bridge by
103 | ```shell
104 | roslaunch vicon_bridge vicon_launch
105 | ```
106 | 6. then, a rostopic named after */vicon/object_name/object_name* should be generated and drone pose information should be found there.
107 |
108 |
109 |
110 |
111 |
112 | It is possible to change the topic of the object in vicon like make DRONE_z' pose information be published to the topic /vicon/drone
113 | ```xml
114 |
115 | ```
116 | then we can find /vicon/drone in rostopic list
117 |
118 |
119 |
120 |
121 | 7. Vicon ros msg includes position information and attitude in quaterion
122 |
123 |
124 |
125 |
126 |
127 | ## 2. How to use Vicon
128 | 1. **Calibrate Vicon**
129 | - dance with favourite music
130 | - camera's light becomes green: it mean OK.
131 | - all cameras's light becoming blinking if they are all calibrated.
132 | 2. run *vicon_bridge* at base station
133 | ```shell
134 | roslaunch vicon_bridge vicon_launch
135 | ```
136 | 3. check drone pose information by
137 | ```shell
138 | rostopic echo /vicon/object_name/object_name
139 | ```
140 | 4. **NOTE change yaw rotation**
141 | It is highly recommended that drones are placed with zero yaw angle.
142 |
143 | Take a quadrotor for example. We usually set the reference yaw angle to be zero, which can cause a potenial risk if the drone is palced with a non-zero yaw angle.
144 |
145 | This image shows a 180 yaw rotation from the origin.
146 |
147 |
148 |
149 |
150 |
151 | ## 3. Use rospackages developed for F46.
152 | 1. get vicon_bridge from https://github.com/ZhongmouLi/vicon_bridge
153 | 2. get drone_experiment_tool from https://github.com/EEEManchester/drone_experiment_tools_F46
154 |
155 | 3. change object name in line 5
156 | ```xml
157 |
158 | ```
159 | 4. run
160 | ```shell
161 | roslaunch drone_experiment_tools drone_ex_F46_setup.launch
162 | ```
163 |
164 | ##TODO
165 |
166 | ### 3.1 Use Vicon information in drone controller
167 |
168 |
169 | ### 3.2 Use Vicon information in PX4
170 |
171 | Indoor flights need Motion Capture System to provide pose information for drones. Vicon is setup in F46 and we shall configure PX4 such that our drone takes pose information from Vicon to meet auto flight conditions.
172 |
173 | EKF2_AID_MASK is the parameter to be tuned:
174 | - click 3 if **horizontal position data** will be used and set EKF2_HGT_MODE = 3 if **vertical position data**,
175 | - click 8 if **velocity data** is used,
176 | - click 4 if **orientation data** is used for **for yaw estimation**, or click 6 if vision reference frame offset will be estimated and used to rotate the external vision system data.
177 |
178 | https://risc.readthedocs.io/1-indoor-flight.html
179 |
180 |
181 | https://docs.px4.io/main/en/advanced/switching_state_estimators.html
182 |
183 | https://docs.px4.io/main/en/ros/external_position_estimation.html
184 |
185 | https://docs.px4.io/main/en/ros/external_position_estimation.html#reference-frames-and-ros
186 |
187 | https://docs.px4.io/v1.12/en/computer_vision/motion_capture.html
188 |
189 | https://docs.px4.io/v1.12/en/tutorials/motion-capture-vicon-optitrack.html
190 |
191 | https://docs.px4.io/v1.12/en/ros/external_position_estimation.html#reference-frames-and-ros
192 |
193 |
194 | Source:
195 | 1. External Vision System, PX4, https://docs.px4.io/v1.12/en/advanced_config/tuning_the_ecl_ekf.html.
196 | 2. EKF2_AID_MASK, https://docs.px4.io/v1.12/en/advanced_config/parameter_reference.html#EKF2_AID_MASK.
197 |
198 | ## Set frame transmition
199 |
200 |
201 |
202 | SYS_MC_EST_GROUP
203 |
204 |
205 | https://404warehouse.net/2015/12/20/autopilot-offboard-control-using-mavros-package-on-ros/
206 |
207 |
208 | TODO
209 | ## 2 Communication schematic among MoCap, drone and base station
210 |
211 |
212 | ### 2.1 State estimation operated by PX4
213 | https://docs.px4.io/v1.12/en/advanced_config/tuning_the_ecl_ekf.html
214 |
215 |
218 | EKF in PX4 ECL
219 |
220 |
221 | Choosing instances of EKF depends on the number of IMUs and the number of magnetometers. For pixhawks 5x, there are
222 | - 3 IMUS,
223 | - 1 magnetometer,
224 |
225 | therefore, we should set
226 |
227 | - EKF2_MULTI_IMU = 3,
228 | - EKF2_MULTI_MAG = 1,
229 |
230 | which leads to
231 | ```
232 | N_instances = MAX(EKF2_MULTI_IMU , 1) x MAX(EKF2_MULTI_MAG , 1) = 3
233 | ```
234 | Following the guide [https://docs.px4.io/v1.12/en/advanced_config/tuning_the_ecl_ekf.html](https://docs.px4.io/v1.12/en/advanced_config/tuning_the_ecl_ekf.html), we should set
235 | - SENS_IMU_MODE = 1 as 1: Publish primary IMU selection,
236 | - SENS_MAG_MODE = 1 as 1: Publish primary magnetometer
237 |
--------------------------------------------------------------------------------
/7_Mavros_Controller.md:
--------------------------------------------------------------------------------
1 | # Understand and apply mavros_controller
2 | This tutorial is to help understand and apply introduce mavros_controller.
3 |
4 | The package mavros_controller provides two packages
5 | 1. **trajectory_publisher** is a node publishing setpoints as states from motion primitives / trajectories for the controller to follow.
6 | 2. **geometric_controller** is a node computing and sending commands to drones in order to follow reference trajectory published by **trajectory_publisher**.
7 |
8 | # Understand mavros_controller
9 | ## 2 geometric_controller
10 | Here is a schematic for **geometric_controller**.
11 |
12 |
14 |
15 |
16 | This node
17 | - computes control commands **body rate** and send to mavros/setpoint_raw/attitude
18 | - receives reference trajectory in **ref position** and **ref velocity** from reference/setpoint
19 |
20 |
21 | ### 2.1 Step 1. receivce reference position and velocity
22 |
23 | **Reference position** and **velocity** are gained at the topic reference/setpoint that is published by **trajectory_publisher**. Then Reference acce are computed with the derivative of velocity.
24 |
25 |
26 | Code between line 122-137 in geometric_control.cpp shows that
27 | + reference position is ```targetPos_```
28 | + reference velocity is ```targetVel_```
29 | + reference acc is ```targetAcc_```
30 |
31 | ```C++
32 | // Line 122-137
33 | void geometricCtrl::targetCallback(const geometry_msgs::TwistStamped &msg) {
34 | reference_request_last_ = reference_request_now_;
35 | targetPos_prev_ = targetPos_;
36 | targetVel_prev_ = targetVel_;
37 |
38 | reference_request_now_ = ros::Time::now();
39 | reference_request_dt_ = (reference_request_now_ - reference_request_last_).toSec();
40 |
41 | targetPos_ = toEigen(msg.twist.angular);
42 | targetVel_ = toEigen(msg.twist.linear);
43 |
44 | if (reference_request_dt_ > 0)
45 | targetAcc_ = (targetVel_ - targetVel_prev_) / reference_request_dt_;
46 | else
47 | targetAcc_ = Eigen::Vector3d::Zero();
48 | }
49 |
50 | ```
51 | ### 2.2 Step 2. Control application
52 |
53 | Callback function ```cmdloopCallback``` is defined in the constrcuctor as
54 | ```c++
55 | // Line 69
56 | cmdloop_timer_ = nh_.createTimer(ros::Duration(0.01), &geometricCtrl::cmdloopCallback, this);
57 | ```
58 |
59 | Core code is in ```cmdloopCallback``` with main functions:
60 | + ```controlPosition``` calculates desired acc from reference position, vel and acc.
61 | + ```computeBodyRateCmd```
62 | + ```pubReferencePose```
63 | + ```pubRateCommands```
64 | + ```appendPoseHistory```
65 | + ```pubPoseHistory```
66 |
67 | ```C++
68 | // Line 225 - 263
69 | void geometricCtrl::cmdloopCallback(const ros::TimerEvent &event) {
70 | /*--------------*/
71 |
72 | case MISSION_EXECUTION: {
73 | Eigen::Vector3d desired_acc;
74 | if (feedthrough_enable_) {
75 | desired_acc = targetAcc_;
76 | } else {
77 | // 1. calculates desired acc from reference position, vel and acc.
78 | desired_acc = controlPosition(targetPos_, targetVel_, targetAcc_);
79 | }
80 | // 2.
81 | computeBodyRateCmd(cmdBodyRate_, desired_acc);
82 | // 3.
83 | pubReferencePose(targetPos_, q_des);
84 | // 4.
85 | pubRateCommands(cmdBodyRate_, q_des);
86 | // 5.
87 | appendPoseHistory();
88 | // 6.
89 | pubPoseHistory();
90 | break;
91 | }
92 |
93 | /*--------------*/
94 |
95 | }
96 | ```
97 |
98 |
99 | #### 2.2.1 ```controlPosition```
100 | ```C++
101 | desired_acc = controlPosition(targetPos_, targetVel_, targetAcc_);
102 | ```
103 | ```controlPosition``` is programmed including three funcationalities:
104 | + ```acc2quaternion``` compute **reference attitude** in quaterion, see [acc2quaternion](#acc2quaternion) in [Appendix](#6-appendix)
105 | + ```quat2RotMatrix``` transfer **reference attitude** in rotation matrix from quaterion
106 | + ```poscontroller``` use a PD contro (position and vel) to compute feedback reference acc, see [poscontroller](#poscontroller) in [Appendix](#6-appendix).
107 | + final desired acc, $\mathbf{a}_{des}$, is calculated
108 | $$\mathbf{a}_{des} = \mathbf{a}_{fd} + \mathbf{a}_{ref} - \mathbf{a}_{rd} - \mathbf{g}$$
109 |
110 | ```C++
111 | // Line 365
112 | Eigen::Vector3d geometricCtrl::controlPosition(const Eigen::Vector3d &target_pos, const Eigen::Vector3d &target_vel,
113 | const Eigen::Vector3d &target_acc) {
114 | /// Compute BodyRate commands using differential flatness
115 | /// Controller based on Faessler 2017
116 | const Eigen::Vector3d a_ref = target_acc;
117 | if (velocity_yaw_) {
118 | mavYaw_ = getVelocityYaw(mavVel_);
119 | }
120 |
121 | const Eigen::Vector4d q_ref = acc2quaternion(a_ref - g_, mavYaw_);
122 | const Eigen::Matrix3d R_ref = quat2RotMatrix(q_ref);
123 |
124 | const Eigen::Vector3d pos_error = mavPos_ - target_pos;
125 | const Eigen::Vector3d vel_error = mavVel_ - target_vel;
126 |
127 | // Position Controller
128 | const Eigen::Vector3d a_fb = poscontroller(pos_error, vel_error);
129 |
130 | // Rotor Drag compensation
131 | const Eigen::Vector3d a_rd = R_ref * D_.asDiagonal() * R_ref.transpose() * target_vel; // Rotor drag
132 |
133 | // Reference acceleration
134 | const Eigen::Vector3d a_des = a_fb + a_ref - a_rd - g_;
135 |
136 | return a_des;
137 | }
138 | ```
139 |
140 | #### 2.2.2 ```computeBodyRateCmd```
141 | ```C++
142 | // Line 392-408
143 | void geometricCtrl::computeBodyRateCmd(Eigen::Vector4d &bodyrate_cmd, const Eigen::Vector3d &a_des) {
144 | // Reference attitude
145 | q_des = acc2quaternion(a_des, mavYaw_);
146 |
147 | // Choose which kind of attitude controller you are running
148 | bool jerk_enabled = false;
149 | if (!jerk_enabled) {
150 | if (ctrl_mode_ == ERROR_GEOMETRIC) {
151 | // 2.2.a
152 | bodyrate_cmd = geometric_attcontroller(q_des, a_des, mavAtt_); // Calculate BodyRate
153 |
154 | } else {
155 | // 2.2.b
156 | bodyrate_cmd = attcontroller(q_des, a_des, mavAtt_); // Calculate BodyRate
157 | }
158 | } else {
159 | // 2.2.c
160 | bodyrate_cmd = jerkcontroller(targetJerk_, a_des, q_des, mavAtt_);
161 | }
162 | }
163 | ```
164 |
165 | 2.1 compute reference attitude using the output from **controlPosition** with
166 |
167 | ```c++
168 | q_des = acc2quaternion(a_des, mavYaw_);
169 | ```
170 |
171 | 2.2 calculate control input **body rate** by one of three methods
172 | + ```bodyrate_cmd = geometric_attcontroller(q_des, a_des, mavAtt_);```
173 | which is
174 | ```c++
175 | // Line 494 - 517
176 | Eigen::Vector4d geometricCtrl::geometric_attcontroller(const Eigen::Vector4d &ref_att, const Eigen::Vector3d &ref_acc,
177 | Eigen::Vector4d &curr_att) {
178 | // Geometric attitude controller
179 | // Attitude error is defined as in Lee, Taeyoung, Melvin Leok, and N. Harris McClamroch. "Geometric tracking control
180 | // of a quadrotor UAV on SE (3)." 49th IEEE conference on decision and control (CDC). IEEE, 2010.
181 | // The original paper inputs moment commands, but for offboard control, angular rate commands are sent
182 |
183 | Eigen::Vector4d ratecmd;
184 | Eigen::Matrix3d rotmat; // Rotation matrix of current attitude
185 | Eigen::Matrix3d rotmat_d; // Rotation matrix of desired attitude
186 | Eigen::Vector3d error_att;
187 |
188 | rotmat = quat2RotMatrix(curr_att);
189 | rotmat_d = quat2RotMatrix(ref_att);
190 |
191 | error_att = 0.5 * matrix_hat_inv(rotmat_d.transpose() * rotmat - rotmat.transpose() * rotmat_d);
192 | ratecmd.head(3) = (2.0 / attctrl_tau_) * error_att;
193 | rotmat = quat2RotMatrix(mavAtt_);
194 | const Eigen::Vector3d zb = rotmat.col(2);
195 | ratecmd(3) =
196 | std::max(0.0, std::min(1.0, norm_thrust_const_ * ref_acc.dot(zb) + norm_thrust_offset_)); // Calculate thrust
197 |
198 | return ratecmd;
199 | }
200 | ```
201 | + ```bodyrate_cmd = attcontroller(q_des, a_des, mavAtt_)```
202 | ```c++
203 | // Line 436-456
204 | Eigen::Vector4d geometricCtrl::attcontroller(const Eigen::Vector4d &ref_att, const Eigen::Vector3d &ref_acc,
205 | Eigen::Vector4d &curr_att) {
206 | // Geometric attitude controller
207 | // Attitude error is defined as in Brescianini, Dario, Markus Hehn, and Raffaello D'Andrea. Nonlinear quadrocopter
208 | // attitude control: Technical report. ETH Zurich, 2013.
209 |
210 | Eigen::Vector4d ratecmd;
211 |
212 | const Eigen::Vector4d inverse(1.0, -1.0, -1.0, -1.0);
213 | const Eigen::Vector4d q_inv = inverse.asDiagonal() * curr_att;
214 | const Eigen::Vector4d qe = quatMultiplication(q_inv, ref_att);
215 | ratecmd(0) = (2.0 / attctrl_tau_) * std::copysign(1.0, qe(0)) * qe(1);
216 | ratecmd(1) = (2.0 / attctrl_tau_) * std::copysign(1.0, qe(0)) * qe(2);
217 | ratecmd(2) = (2.0 / attctrl_tau_) * std::copysign(1.0, qe(0)) * qe(3);
218 | const Eigen::Matrix3d rotmat = quat2RotMatrix(mavAtt_);
219 | const Eigen::Vector3d zb = rotmat.col(2);
220 | ratecmd(3) =
221 | std::max(0.0, std::min(1.0, norm_thrust_const_ * ref_acc.dot(zb) + norm_thrust_offset_)); // Calculate thrust
222 |
223 | return ratecmd;
224 | }
225 | ```
226 | + ```bodyrate_cmd = jerkcontroller(targetJerk_, a_des, q_des, mavAtt_)```
227 | ```c++
228 | // Line 458-492
229 | Eigen::Vector4d geometricCtrl::jerkcontroller(const Eigen::Vector3d &ref_jerk, const Eigen::Vector3d &ref_acc,
230 | Eigen::Vector4d &ref_att, Eigen::Vector4d &curr_att) {
231 | // Jerk feedforward control
232 | // Based on: Lopez, Brett Thomas. Low-latency trajectory planning for high-speed navigation in unknown environments.
233 | // Diss. Massachusetts Institute of Technology, 2016.
234 | // Feedforward control from Lopez(2016)
235 |
236 | double dt_ = 0.01;
237 | // Numerical differentiation to calculate jerk_fb
238 | const Eigen::Vector3d jerk_fb = (ref_acc - last_ref_acc_) / dt_;
239 | const Eigen::Vector3d jerk_des = ref_jerk + jerk_fb;
240 | const Eigen::Matrix3d R = quat2RotMatrix(curr_att);
241 | const Eigen::Vector3d zb = R.col(2);
242 |
243 | const Eigen::Vector3d jerk_vector =
244 | jerk_des / ref_acc.norm() - ref_acc * ref_acc.dot(jerk_des) / std::pow(ref_acc.norm(), 3);
245 | const Eigen::Vector4d jerk_vector4d(0.0, jerk_vector(0), jerk_vector(1), jerk_vector(2));
246 |
247 | Eigen::Vector4d inverse(1.0, -1.0, -1.0, -1.0);
248 | const Eigen::Vector4d q_inv = inverse.asDiagonal() * curr_att;
249 | const Eigen::Vector4d qd = quatMultiplication(q_inv, ref_att);
250 |
251 | const Eigen::Vector4d qd_star(qd(0), -qd(1), -qd(2), -qd(3));
252 |
253 | const Eigen::Vector4d ratecmd_pre = quatMultiplication(quatMultiplication(qd_star, jerk_vector4d), qd);
254 |
255 | Eigen::Vector4d ratecmd;
256 | ratecmd(0) = ratecmd_pre(2); // TODO: Are the coordinate systems consistent?
257 | ratecmd(1) = (-1.0) * ratecmd_pre(1);
258 | ratecmd(2) = 0.0;
259 | ratecmd(3) =
260 | std::max(0.0, std::min(1.0, norm_thrust_const_ * ref_acc.dot(zb) + norm_thrust_offset_)); // Calculate thrust
261 | last_ref_acc_ = ref_acc;
262 | return ratecmd;
263 | }
264 | ```
265 | 2.3 how to choose attiude control methods
266 | + Paramers for choosing attitude control mode are defined in geometric_controller.h
267 | ```c++
268 | // Line 75-76
269 | #define ERROR_GEOMETRIC 2
270 | #define ERROR_QUATERNION 1
271 | ```
272 | + Variable to choose the mode is read from ros param **ctrl_mode**
273 | ```c++
274 | //Line 84
275 | nh_private_.param("ctrl_mode", ctrl_mode_, ERROR_QUATERNION);
276 | ```
277 | which is specified in launch file, e.g. sitl_trajectory_track_circle.launch using **command_input**.
278 |
279 | ```shell
280 | # Line 7
281 |
282 | # Line 17
283 |
284 | ```
285 | **Remarks**:
286 | 1. Usually, only ```attcontroller``` and ```geometric_attcontroller``` are available
287 | 2. Set ```command_input = 2``` leads to ```geometric_attcontroller```, while ```command_input = 1``` leads to ```attcontroller```.
288 |
289 | #### 2.2.3 ```pubReferencePose```
290 | This function is to publish reference position and attitude to the topic reference/pose as
291 | ```c++
292 | pubReferencePose(targetPos_, q_des);
293 | ```
294 |
295 | ```c++
296 | // Line 290-303
297 | void geometricCtrl::pubReferencePose(const Eigen::Vector3d &target_position, const Eigen::Vector4d &target_attitude) {
298 | geometry_msgs::PoseStamped msg;
299 |
300 | msg.header.stamp = ros::Time::now();
301 | msg.header.frame_id = "map";
302 | msg.pose.position.x = target_position(0);
303 | msg.pose.position.y = target_position(1);
304 | msg.pose.position.z = target_position(2);
305 | msg.pose.orientation.w = target_attitude(0);
306 | msg.pose.orientation.x = target_attitude(1);
307 | msg.pose.orientation.y = target_attitude(2);
308 | msg.pose.orientation.z = target_attitude(3);
309 | referencePosePub_.publish(msg);
310 | }
311 | ```
312 |
313 |
314 | #### 2.2.4 ```pubRateCommands```
315 | This function is to publish the control input (body rate and thrust) to the topic command/bodyrate_command as
316 | ```c++
317 | pubRateCommands(cmdBodyRate_, q_des);
318 | ```
319 | where is maped to /mavros/setpoint_raw/attitude
320 | ```shell
321 |
322 | ```
323 |
324 | ```c++
325 | // Line 305-321
326 | void geometricCtrl::pubRateCommands(const Eigen::Vector4d &cmd, const Eigen::Vector4d &target_attitude) {
327 | mavros_msgs::AttitudeTarget msg;
328 |
329 | msg.header.stamp = ros::Time::now();
330 | msg.header.frame_id = "map";
331 | msg.body_rate.x = cmd(0);
332 | msg.body_rate.y = cmd(1);
333 | msg.body_rate.z = cmd(2);
334 | msg.type_mask = 128; // Ignore orientation messages
335 | msg.orientation.w = target_attitude(0);
336 | msg.orientation.x = target_attitude(1);
337 | msg.orientation.y = target_attitude(2);
338 | msg.orientation.z = target_attitude(3);
339 | msg.thrust = cmd(3);
340 |
341 | angularVelPub_.publish(msg);
342 | }
343 | ```
344 |
345 | #### 2.2.5 ```pubReferencePose``` and ```pubPoseHistory()```
346 | Here we do two things
347 | + with ```appendPoseHistory()```, we record the drone's position and attitude and save them into a vector ```posehistory_vector_``` with a size of```posehistory_window_``` (default = 200).
348 | ```c++
349 | // Line 243-244
350 | appendPoseHistory();
351 | pubPoseHistory();
352 | ```
353 | ```c++
354 | // Line 343-348
355 | void geometricCtrl::appendPoseHistory() {
356 | posehistory_vector_.insert(posehistory_vector_.begin(), vector3d2PoseStampedMsg(mavPos_, mavAtt_));
357 | if (posehistory_vector_.size() > posehistory_window_) {
358 | posehistory_vector_.pop_back();
359 | }
360 | }
361 | ```
362 | + with ```pubPoseHistory()```, ```posehistory_vector_``` is published to the topic geometric_controller/path
363 |
364 | ```c++
365 | // Line 323-331
366 | void geometricCtrl::pubPoseHistory() {
367 | nav_msgs::Path msg;
368 |
369 | msg.header.stamp = ros::Time::now();
370 | msg.header.frame_id = "map";
371 | msg.poses = posehistory_vector_;
372 |
373 | posehistoryPub_.publish(msg);
374 | }
375 | ```
376 | # 3 trajectory_publisher
377 | It is implemented in ```trajectoryPublisher.cpp```.
378 |
379 |
380 | ## 3.1 Step 1
381 | In the constructor,
382 | ```c++
383 | trajectoryPublisher::trajectoryPublisher(const ros::NodeHandle& nh, const ros::NodeHandle& nh_private)//
384 | : nh_(nh), nh_private_(nh_private), motion_selector_(0)//
385 | ```
386 | 1. read ```num_primitives_``` from ros parameter ```number_of_primitives```
387 | ```c++
388 | nh_private_.param("number_of_primitives", num_primitives_, 7);
389 | ```
390 | 2. change the size of ```inputs_``` to be ```num_primitives_```
391 | ```c++
392 | inputs_.resize(num_primitives_);
393 | ```
394 |
395 | 4. ```initializePrimitives``` is called at the end of constructor.
396 |
397 | ```c++
398 | initializePrimitives(trajectory_type_);
399 | ```
400 | ```c++
401 | void trajectoryPublisher::initializePrimitives(int type) {
402 | if (type == 0) {
403 | for (int i = 0; i < motionPrimitives_.size(); i++)
404 | motionPrimitives_.at(i)->generatePrimitives(p_mav_, v_mav_, inputs_.at(i));
405 | } else {
406 | for (int i = 0; i < motionPrimitives_.size(); i++)
407 | motionPrimitives_.at(i)->initPrimitives(shape_origin_, shape_axis_, shape_omega_);
408 | // TODO: Pass in parameters for primitive trajectories
409 | }
410 | }
411 | ```
412 |
413 | ## 3.2 step 2 Choose trajectory planning
414 | Trajectory can be planned with two different methods:
415 | + polynomial trajectory by setting ```trajectory_type_ =0```
416 | + shape trajectory by setting ```trajectory_type_ =1```
417 | ```c++
418 | if (trajectory_type_ == 0) { // Polynomial Trajectory
419 |
420 | if (num_primitives_ == 7) {
421 | inputs_.at(0) << 0.0, 0.0, 0.0; // Constant jerk inputs for minimim time trajectories
422 | inputs_.at(1) << 1.0, 0.0, 0.0;
423 | inputs_.at(2) << -1.0, 0.0, 0.0;
424 | inputs_.at(3) << 0.0, 1.0, 0.0;
425 | inputs_.at(4) << 0.0, -1.0, 0.0;
426 | inputs_.at(5) << 0.0, 0.0, 1.0;
427 | inputs_.at(6) << 0.0, 0.0, -1.0;
428 | }
429 |
430 | for (int i = 0; i < num_primitives_; i++) {
431 | /*Poly trajectory initilisation*/
432 | motionPrimitives_.emplace_back(std::make_shared());
433 | primitivePub_.push_back(
434 | nh_.advertise("trajectory_publisher/primitiveset" + std::to_string(i), 1));
435 | inputs_.at(i) = inputs_.at(i) * max_jerk_;
436 | }
437 | } else { // Shape trajectories
438 |
439 | num_primitives_ = 1;
440 |
441 | /*Shape trajectory initilisation*/
442 | motionPrimitives_.emplace_back(std::make_shared(trajectory_type_));
443 | primitivePub_.push_back(nh_.advertise("trajectory_publisher/primitiveset", 1));
444 | }
445 | ```
446 |
447 | ```motion_selector_```
448 |
449 | ## 3.3 step 3 Publish reference trajectory and setpoints
450 | Core functions are ```loopCallback``` and ```refCallback```: ```loopCallback``` is called with a frequency of 10HZ, while ```refCallback```is called with a frequency of 100HZ.
451 |
452 | ```c++
453 | // Line 58-59
454 | trajloop_timer_ = nh_.createTimer(ros::Duration(0.1), &trajectoryPublisher::loopCallback, this);
455 | refloop_timer_ = nh_.createTimer(ros::Duration(0.01), &trajectoryPublisher::refCallback, this);
456 | ```
457 |
458 |
459 | ### ```loopCallback``` publish reference trajectory
460 | Whole/Segment reference trajecotry is publised to trajectory_publisher/trajectory.
461 | ```c++
462 | void trajectoryPublisher::loopCallback(const ros::TimerEvent& event) {
463 | // Slow Loop publishing trajectory information
464 | pubrefTrajectory(motion_selector_);
465 | pubprimitiveTrajectory();
466 | }
467 | ```
468 |
469 | 1. ```pubrefTrajectory(motion_selector_)``` publish the whole reference trajectory to trajectory_publisher/trajectory.
470 | ```c++
471 | void trajectoryPublisher::pubrefTrajectory(int selector) {
472 | // Publish current trajectory the publisher is publishing
473 | refTrajectory_ = motionPrimitives_.at(selector)->getSegment();
474 | refTrajectory_.header.stamp = ros::Time::now();
475 | refTrajectory_.header.frame_id = "map";
476 | trajectoryPub_.publish(refTrajectory_);
477 | }
478 | ```
479 | where the publisher is defined as
480 | ```c++
481 | trajectoryPub_ = nh_.advertise("trajectory_publisher/trajectory", 1);
482 | ```
483 |
484 | 2. ```pubprimitiveTrajectory()``` publishes segments of reference trajectory to trajectory_publisher/primitiveset.
485 | ```c++
486 | void trajectoryPublisher::pubprimitiveTrajectory() {
487 | for (int i = 0; i < motionPrimitives_.size(); i++) {
488 | primTrajectory_ = motionPrimitives_.at(i)->getSegment();
489 | primTrajectory_.header.stamp = ros::Time::now();
490 | primTrajectory_.header.frame_id = "map";
491 | primitivePub_.at(i).publish(primTrajectory_);
492 | }
493 | }
494 | ```
495 | ```c++
496 | primitivePub_.push_back(nh_.advertise("trajectory_publisher/primitiveset", 1));
497 | ```
498 |
499 | ## 3.4 step 4 send setpoint of reference trajectory to drone
500 | Inside ```refCallback```, we have three options to compute setpoints for drone.
501 |
502 | ```c++
503 | void trajectoryPublisher::refCallback(const ros::TimerEvent& event) {
504 | // Fast Loop publishing reference states
505 | updateReference();
506 | switch (pubreference_type_) {
507 | case REF_TWIST: // REF_TWIST = 8
508 | pubrefState();
509 | break;
510 | case REF_SETPOINTRAW: // REF_TWIST = 16
511 | pubrefSetpointRaw();
512 | // pubrefSetpointRawGlobal();
513 | break;
514 | default: // pubreference_type_ by default = 2
515 | pubflatrefState();
516 | break;
517 | }
518 | }
519 | ```
520 |
521 | | ```pubreference_type_``` | Function | Commamds | Topic |
522 | | ----------- | ----------- |----------- |----------- |
523 | | 2 (default) |```pubflatrefState``` | p_targ, v_targ, a_targ |```reference/flatsetpoint``` |
524 | | 8 | ```pubrefState``` |p_targ, v_targ| ```reference/setpoint```|
525 | | 16 | ```pubrefSetpointRaw``` |p_targ, v_targ, a_targ | ```mavros/setpoint_raw/local```|
526 |
527 |
528 | ```c++
529 | void trajectoryPublisher::updateReference() {
530 | curr_time_ = ros::Time::now();
531 | trigger_time_ = (curr_time_ - start_time_).toSec();
532 |
533 | p_targ = motionPrimitives_.at(motion_selector_)->getPosition(trigger_time_);
534 | v_targ = motionPrimitives_.at(motion_selector_)->getVelocity(trigger_time_);
535 | if (pubreference_type_ != 0) a_targ = motionPrimitives_.at(motion_selector_)->getAcceleration(trigger_time_);
536 | }
537 | ```
538 |
539 |
540 | # 4 Appendix
541 | ## 4.1 algorithm in geometirc_controller
542 | ### acc2quaternion
543 | ```acc2quaternion``` is to compute a reference rotation from reference acceleration, which is called in ```controlPosition```and ```computeBodyRateCmd```
544 | ```c++
545 | // Line 374
546 | // Or Line 394
547 | const Eigen::Vector4d q_ref = acc2quaternion(a_ref - g_, mavYaw_);
548 | ```
549 | where the function ```acc2quaternion``` is defined as below
550 | ```C++
551 | // line 420 - 434
552 | Eigen::Vector4d geometricCtrl::acc2quaternion(const Eigen::Vector3d &vector_acc, const double &yaw) {
553 | Eigen::Vector4d quat;
554 | Eigen::Vector3d zb_des, yb_des, xb_des, proj_xb_des;
555 | Eigen::Matrix3d rotmat;
556 |
557 | proj_xb_des << std::cos(yaw), std::sin(yaw), 0.0;
558 |
559 | zb_des = vector_acc / vector_acc.norm();
560 | yb_des = zb_des.cross(proj_xb_des) / (zb_des.cross(proj_xb_des)).norm();
561 | xb_des = yb_des.cross(zb_des) / (yb_des.cross(zb_des)).norm();
562 |
563 | rotmat << xb_des(0), yb_des(0), zb_des(0), xb_des(1), yb_des(1), zb_des(1), xb_des(2), yb_des(2), zb_des(2);
564 | quat = rot2Quaternion(rotmat);
565 | return quat;
566 | }
567 | ```
568 | and more explanation can be found in slides. TO DO.
569 |
570 |
571 | ### ```poscontroller```
572 | ```poscontroller``` uses PD control to computes a reference acc from position and vel error, which is called in ```cmdloopCallback``` at line 238.
573 |
574 | In fact, it can be represented using the following equation
575 |
576 | $$\mathbf{a}_{fb} = K_{pos} \cdot \mathbf{e}_p + K_{vel} \cdot \mathbf{e}_v \,.$$
577 |
578 | ```c++
579 | // Line 410
580 | Eigen::Vector3d geometricCtrl::poscontroller(const Eigen::Vector3d &pos_error, const Eigen::Vector3d &vel_error) {
581 | Eigen::Vector3d a_fb =
582 | Kpos_.asDiagonal() * pos_error + Kvel_.asDiagonal() * vel_error; // feedforward term for trajectory error
583 |
584 | if (a_fb.norm() > max_fb_acc_)
585 | a_fb = (max_fb_acc_ / a_fb.norm()) * a_fb; // Clip acceleration if reference is too large
586 |
587 | return a_fb;
588 | }
589 | ```
590 |
591 |
592 | ## ROS techniques in mavros_controller
593 | Subscriper
594 | ```C++
595 | referenceSub_ = nh_.subscribe("reference/setpoint", 1, &geometricCtrl::targetCallback, this, ros::TransportHints().tcpNoDelay());
596 | ```
597 | Usually, subscriber is ROS C++ is defined like
598 | ```C++
599 | ros::Subscriber sub = nh.subscribe("my_topic", 1, callback);
600 | ```
601 | with three arguments:
602 | - topic to subscribed,
603 | - queue sise,
604 | - callback function.
605 |
606 | Well, the full version of subscriber is defined with four arguments
607 | ```C++
608 | Subscriber ros::NodeHandle::subscribe(
609 | const std::string & topic,
610 | uint32_t queue_size,
611 | const boost::function< void(C)>& callback,
612 | const VoidConstPtr& tracked_object = VoidConstPtr(),
613 | const TransportHints& transport_hints = TransportHints()
614 | )
615 | ```
616 | 1. ```tracked_object```
617 |
618 | Parameter *tracked_object* defines a shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, and if the reference count goes to 0 the subscriber callbacks will not get called.
619 |
620 | Note that setting this will cause a new reference to be added to the object before the callback, and for it to go out of scope (and potentially be deleted) in the code path (and therefore
621 | thread) that the callback is invoked fro
622 |
623 | 2. ```transport_hints```
624 | ```transport_hints``` allows us to choose prefered connection ways by specify hints to roscpp's transport layer.
625 |
626 | We can choose one among ```unreliable, reliable, maxDatagramSize, tcpNoDelay```
627 | ```C++
628 | ros::TransportHints()
629 | .unreliable()
630 | .reliable()
631 | .maxDatagramSize(1000)
632 | .tcpNoDelay();
633 | ```
634 |
635 | just likes
636 | ```C++
637 | ros::Subscriber sub = nh.subscribe("my_topic", 1, callback, ros::TransportHints().unreliable());
638 | ```
639 |
640 | More details can be found [roscpp Overview Publishers and Subscribers](http://wiki.ros.org/roscpp/Overview/Publishers%20and%20Subscribers).
641 |
642 | [ROS API](https://docs.ros.org/en/api/roscpp/html/classros_1_1NodeHandle.html#a6b655c04f32c4c967d49799ff9312ac6)
643 |
644 | advertiseService
645 | ```C++
646 | ctrltriggerServ_ = nh_.advertiseService("trigger_rlcontroller", &geometricCtrl::ctrltriggerCallback, this);
647 | ```
648 |
649 | ```advertiseService``` allows us to creat a ```ros::ServiceServer`` that works similar to how the ```subscribe()``` method works.
650 |
651 | # Apply mavros_controller
652 |
653 | ## Modification
654 |
655 | ## Prepare real flight
656 | Bench test is to
657 | 1. check if **we can arm and offboard a drone with RC controller**
658 | 2. debuy and tune geometirc_controller without propellers
659 |
660 |
661 |
662 |
663 |
664 |
--------------------------------------------------------------------------------
/7_Mavros_Controller/bench_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/7_Mavros_Controller/bench_test.png
--------------------------------------------------------------------------------
/7_Mavros_Controller/v1_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/7_Mavros_Controller/v1_0.png
--------------------------------------------------------------------------------
/8_0_ROS2.md:
--------------------------------------------------------------------------------
1 | # ROS2
2 | This page is to step into the ROS2's world.
3 |
4 | Development envrionmen
5 | - Ubuntu 20.04
6 | - ROS2 foxy
7 |
8 | ## 0. ROS2 VS ROS
9 | [Understand ROS2 with comparation with ROS](8_1_Intro_ROS2.md)
10 |
11 |
12 | ## 1. Install ROS2
13 | [How to install ROS2 Foxy](8_2_Install_ROS2.md)
14 |
15 |
16 | ## 2. Configure ROS2 workspace
17 | [Configure ROS2 workspace](8_2_Config_Workspace.md)
18 |
19 |
20 | ## 3. Examples of Publisher and Subscriber in C++
21 | [Simple examples for publisher and subscriber](8_3_Config_Workspace.md)
22 |
23 |
24 |
25 |
26 | TODO:
27 |
28 | - https://automaticaddison.com/ros-2-tutorials-foxy-fitzroy/
29 | - https://www.youtube.com/watch?v=Gg25GfA456o&ab_channel=RoboticsBack-End
30 | - https://www.youtube.com/playlist?list=PLRE44FoOoKf7NzWwxt3W2taZ7BiWyfhCp
31 | - https://fishros.com/d2lros2/#/humble/chapt1/advanced/2.%E4%B8%AD%E9%97%B4%E4%BB%B6DDS%E6%9E%B6%E6%9E%84
32 | - https://zhuanlan.zhihu.com/p/423581728
33 | - https://mp.weixin.qq.com/s?__biz=MzkzMzI2MTU2Nw==&mid=2247484345&idx=1&sn=b5b5e0cedadacc085030eca33c3ccc47&chksm=c24e7a29f539f33f6f934c8b58ec37775f66550c6c459532f7a267579bc72d464a3d1d064e26&cur_album_id=1961689564104720387&scene=189#wechat_redirect
34 | - https://osrf.github.io/ros2multirobotbook/ros2_tools_resources.html
35 | - https://github.com/osrf/icra2023_ros2_gz_tutorial
36 | - https://github.com/osrf/vehicle_gateway
37 | - http://www.uml.org.cn/modeler/202110131.asp
38 |
39 | ### Creat own lib in ROS2
40 |
41 | How to create and use your own C++ Library with ROS2, https://youtu.be/S7AjhNKHpvs
42 |
43 |
44 | ## Reference
45 | 1. Install ROS2 Along With ROS1 | Foxy | Noetic | Simple ROS2 Tutorial | 2022 https://www.youtube.com/watch?v=CtW7Cqzeb8o&ab_channel=HarshMittal
46 | 2. Olivier Kermorgant, http://pagesperso.ls2n.fr/~kermorgant-o/teaching.html#C++_programming
47 | 3. Using colcon to build packages https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html?highlight=colcon
--------------------------------------------------------------------------------
/8_1_Intro_ROS2.md:
--------------------------------------------------------------------------------
1 | ## Structure of ROS2 Foxy
2 | ### Why move to ROS2 from ROS
3 | | | ROS2 | ROS |
4 | |:----: |:----: |:----: |
5 | |Design target | For Industry | For Academia |
6 | |Design origin | For multi robots | For single robot |
7 | |Platform | Multi-platform | Linux |
8 | |Real-time | Yes | No |
9 | |Sensor | Small processors | Complex robots and sensors |
10 | |Network environment | Unreliable network is OK| Perfect network is perfered(ideally on the same computer)|
11 | | Others| Deterministic behavior| Lot of computational power|
12 | | | Error recovery| |
13 |
14 | ### Differences in structues of ROS and ROS2
15 |
16 |
17 |
18 | Key difference is ROS 2 has no ros master.
19 |
20 | ROS 2 allows to completely create a distributed system.
21 |
22 | **API differences**
23 |
24 |
25 |
26 |
27 |
28 |
29 | switching DDS is [ROS2 - Switch Between Different DDS Implementations (Fast DDS, cyclone DDS)](https://www.youtube.com/watch?v=V3UPx_3VoyA&ab_channel=RoboticsBack-End)
30 |
31 | DDS ref https://hackmd.io/@st9540808/SkM_SOTJH
32 |
33 |
34 | - c++ and python in ROS 2 are united by using a common client library.
35 | - roscpp and rospy are independent, some functions exsit only for one or the other. It is possible to come across that the needed features only are available in rospy, while your project uses roscpp.
36 | - rclcpp and rclpy are much more simular. Both of them depend on rcl and providing the binding: all functions are implemented in rcl.
37 | - ROS 2 enables developers using other language to expereince a simular API. It is possible to use libraries in other languages like java as long as a binding between rcl ane them are developed.
38 | - A new feature once is realsed, it will be available for all languages in ROS2. Only a binding is needed. By contrast, in ROS,
39 |
40 | Supports for Python and C++
41 | - ROS 2 is only for Python 3.
42 | - ROS 2 supports C++ 11 and 14 by default, C++ 17 is also on the roadmap.
43 |
44 | **Workspace overlays**
45 |
46 | We can overlay workspace and pkgs.
47 |
48 |
49 | ### Key concepts of ROS2
50 | #### Node
51 | A node can send and receive data from other nodes via topics, services, actions, or parameters. Usually, a node should be responible for for a single and modular purpose like controlling the wheel motors and publishing the sensor data from a laser range-finder.
52 |
53 |
54 |
55 | **Difference in concept from ROS**
56 |
57 | One executable in ROS2 can contain several nodes:
58 | - ROS 1: the node is the entire executable
59 | - ROS 2: several nodes in the same executable (classes)
60 |
61 | Because of this key difference, ROS2 is very suitable for a multi-robot system. ROS2 allows one executable, or package, to be programmed for one type of task wiht each node is in charge of one individual fucntion or module.
62 |
63 | In contrast, one robot may need multiple executables/nodes.
64 |
65 | A node in ROS2 is a class that can be:
66 | - Compiled, run or stopped independently
67 | - Written in different languages (C++ / Python3)
68 |
69 |
70 | ROS1 vs ROS2, Practical Overview For ROS Developers, https://roboticsbackend.com/ros1-vs-ros2-practical-overview/
--------------------------------------------------------------------------------
/8_2_Install_ROS2.md:
--------------------------------------------------------------------------------
1 | 1. Choose ROS2 version at http://docs.ros.org/
2 |
3 |
4 |
5 | Version can be chosen according to OS. For example foxy is recommended for Ubuntu 22.04.
6 |
7 | The steps below are just following guidances given at http://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html.
8 |
9 | 2. Get locale supports of UTF-8.
10 |
11 | 2.1 Check supoort by typing
12 | ```bash
13 | local
14 | ```
15 | 2.2 It is supported.
16 | It means they are already supported if we see
17 |
18 |
19 |
20 |
21 | which shows that LANG=en.UTF-8 and UTF-8 support is set alreay.
22 |
23 | 2.3 It is not supported and needs to be installed
24 | Run the follwoing commands in the terminal.
25 |
26 | ```bash
27 | sudo apt update && sudo apt install locales
28 | sudo locale-gen en_US en_US.UTF-8
29 | sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
30 | export LANG=en_US.UTF-8
31 | ```
32 |
33 | 3. Setup Sources for ROS2
34 |
35 | We should set universal apt available for the system. This can be checked by
36 |
37 | ```bash
38 | apt-cache policy | grep universal
39 | ```
40 | which results into
41 |
42 |
43 |
44 |
45 | Then, add the ROS2 GPG key with apt.
46 |
47 | ```bash
48 | sudo apt update && sudo apt install curl -y
49 | sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
50 | ```
51 | and add the rep
52 |
53 | ```bash
54 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
55 | ```
56 | 4. Install ROS2 packages
57 | - update and upgrade
58 | ```bash
59 | sudo apt update && sudo apt upgrade
60 | ```
61 | - install desktop (Recommended): ROS, RViz, demos, tutorials
62 | ```bash
63 | sudo apt install ros-foxy-desktop python3-argcomplete
64 | ```
65 | - install development tools like compilers
66 | ```bash
67 | sudo apt install ros-dev-tools
68 | ```
69 | 5. Make ROS2 compatible with ROS
70 |
71 | .bashrc needs to be modified in order to source ROS and ROS2.
72 |
73 | - find .bashrc in ~
74 | - find and comments source commands for ROS, like ROS noetic
75 | ```bash
76 | # ROS noetic
77 | #source /opt/ros/noetic/setup.bash
78 | #source ~/catkin_ws/devel/setup.bash
79 | ```
80 | - add source commands for ROS2 such that
81 | ```bash
82 | # ROS noetic
83 | #source /opt/ros/noetic/setup.bash
84 | #source ~/catkin_ws/devel/setup.bash
85 |
86 | # ROS2 foxy
87 | source /opt/ros/foxy/setup.bash
88 | ```
89 | - NOTE switching between ROS and ROS2 is done through modifying .bashrc
90 | - use ROS by commenting source commands for ROS2
91 | ```bash
92 | # ROS noetic
93 | source /opt/ros/noetic/setup.bash
94 | source ~/catkin_ws/devel/setup.bash
95 |
96 | # ROS2 foxy
97 | #source /opt/ros/foxy/setup.bash
98 | ```
99 | - use ROS2 by commenting source commands for ROS
100 | ```bash
101 | # ROS noetic
102 | #source /opt/ros/noetic/setup.bash
103 | #source ~/catkin_ws/devel/setup.bash
104 |
105 | # ROS2 foxy
106 | source /opt/ros/foxy/setup.bash
107 | ```
108 | 6. Check ROS2 installation
109 |
110 | In a terminal
111 | ```bash
112 | ros2 run demo_nodes_cpp talker
113 | ```
114 | and in another
115 | ```bash
116 | ros2 run demo_nodes_cpp listener
117 | ```
118 |
119 | Installation is completed if we can see
120 |
121 |
122 |
123 |
124 | We can find the rqt_grap by typing rqt_gragh in termainl and
125 |
126 |
127 |
--------------------------------------------------------------------------------
/8_3_Config_Workspace.md:
--------------------------------------------------------------------------------
1 | ## Workspace Configuration for ROS2
2 | In ROS2, ament is the new building system, and on top of that we get the colcon command line tool.
3 |
4 | However, in ROS, catkin is the building system that combines CMake macros and Python scripts on top of CMake's normal workflow. That is why we use CMakeLists.txt.
5 |
6 | To better understand, we use ROS as a refernce
7 | - colcon like catkin tools, provide commands to create, build and test pkgs,
8 | - ament is iterated on catkin from ROS.
9 |
10 | ### Configuration for colcon
11 | Three tools are essential for ROS2:
12 | - ROS2, itself;
13 | - colcon as build tools.
14 |
15 | We need colcon to build and manage pkgs developed in ROS2. Workspace is where these pkgs are located. In this case, we create the workspace as the folder *ros2_ws* by
16 |
17 | ```bash
18 | cd ~
19 | mkdir ros2_ws
20 | cd ros2_ws && mkdir src
21 | ```
22 | where
23 | - *ros2_ws* is the workspace in which we use build pkgs
24 | - *ros2_ws/src* is where the built pkgs
25 |
26 | 1. colcon tools to build ROS2 pkgs
27 | Install colcon
28 | ```bash
29 | sudo apt install python3-colcon-common-extensions
30 | ```
31 | 2. Enable auto completation of colcon
32 | - check if ```colcon-argcomplete.bash``` exisits in
33 | ```bash
34 | ls /usr/share/colcon_argcomplete/hook
35 | ```
36 | - modify ~/.bashrc to source ```colcon-argcomplete.bash``` whenever a new terminal is called by adding the following command
37 | ```bash
38 | source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
39 | ```
40 | 3. Enable the searching availablity of pkgs in *ros2_ws* by adding the following command to ~/.bashrc
41 | ```bash
42 | source ~/ros2_ws/install/setup.bash
43 | ```
44 | Finally, we have added three lines into ~/.bashrc
45 | ```bash
46 | # ROS2 foxy
47 | source /opt/ros/foxy/setup.bash
48 | # ros2 workspace
49 | source ~/ros2_ws/install/setup.bash
50 | # auto completation of colcon
51 | source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
52 | ```
53 | ### colcon commands for ROS2
54 |
55 | | | ROS2 | ROS |
56 | |:----: |:--------: |:--------: |
57 | |Build pkgs | colcon build | catkin build |
58 | |Create pkg | ros2 pkg create --build-type ament_cmake | catkin create pkg |
59 | || ros2 pkg create --build-type ament_python| |
60 | |Build certain pkg| colcon build --packages-select | catkin build |
61 | |Run pkg | ros2 run | ros run |
62 | |Find exe | ros2 pkg prefix | ros pkg find |
63 |
64 | ## Build Pkgs
65 | A package is a basic organizational unit for your ROS2.
66 |
67 | ### Simple example to create pkg
68 | Steps in details to follow "how to create a hello world" C++ pkg in ROS 2 https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html.
69 |
70 | Step 1: create a hello world c++ pkg
71 |
72 | ```shell
73 | cd ros2_ws/src
74 | ros2 pkg create --build-type ament_cmake --node-name hello_node hello_package
75 | ```
76 | we should see
77 |
78 |
79 |
80 | Step 2: build hello world pkg
81 | ```shell
82 | cd ros2_ws/
83 | colcon build --packages-select hello_package
84 | ```
85 | as
86 |
87 |
88 |
89 | Step 3: source for new pkg
90 |
91 | ```shell
92 | cd ros2_ws/
93 | source install/local_setup.bash
94 | ```
95 |
96 |
97 | Sourcing the local_setup of the overlay will only add the packages available in the overlay to your environment. setup sources the overlay as well as the underlay it was created in, allowing you to utilize both workspaces.
98 |
99 | So, sourcing your main ROS 2 installation’s setup and then the ros2_ws overlay’s local_setup, like you just did, is the same as just sourcing ros2_ws’s setup, because that includes the environment of its underlay.
100 |
101 | Step 4: run pkg
102 | ```shell
103 | ros2 run hello_package hello_node
104 | ```
105 |
106 |
107 |
108 | Refereces:
109 | 1. ROS2 Basics #3 - Understanding ROS2 Packages and Workspace https://youtu.be/lN4_-l7FCWk.
110 | 2. ROS2 Tutorials #4: How to create a ROS2 Package for C++ [NEW], https://youtu.be/C2bKwFJ5HEY.
111 | 3. what is the use of --symlink-install in ROS2 colcon build?, https://answers.ros.org/question/371822/what-is-the-use-of-symlink-install-in-ros2-colcon-build/
112 |
113 |
114 | ```html
115 | my_package/
116 | CMakeLists.txt
117 | include/my_package/
118 | package.xml
119 | src/
120 | launch/
121 | ```
122 | where
123 | - CMakeLists.txt file that describes how to build the code within the package
124 | - include/ directory containing the public headers for the package
125 | - package.xml file containing meta information about the package
126 | - src directory containing the source code for the package
127 |
128 | ### CMakeLists for ament
129 |
130 | ```cmake
131 | cmake_minimum_required(VERSION 3.5)
132 | project(my_project)
133 |
134 | ament_package()
135 | ```
--------------------------------------------------------------------------------
/8_3_Examples_Pub_Subs.md:
--------------------------------------------------------------------------------
1 | ## 1 Create a simple node in pkg in ROS2
2 |
3 | ### 1.1 Write C++ scipts to creat a node
4 | ```c++
5 | // 1. get h file for using c++ in ROS2
6 | #include "rclcpp/rclcpp.hpp"
7 |
8 | int main(int argc, char **argv)
9 | {
10 | // 2. initiate ROS2 communications with rclcpp::init()
11 | rclcpp::init(argc, argv);
12 | // 3. create a node
13 | auto node = std::make_shared("my_node_name");
14 | // 3. make node spin
15 | rclcpp::spin(node);
16 | // 4. will stop ROS2 communications
17 | rclcpp::shutdown();
18 | return 0;
19 | }
20 | ```
21 | Two ways to create a node
22 | 1. ```auto node = std::make_shared("my_node_name");```
23 | - It uses a shared pointer to create an instance of class ```rclcpp::Node```. The name of node is *my_node_name*.
24 | - It is a good choice for complex node classes as it can pass additional arguments to the constructor of the ```rclcpp::Node``` class.
25 | 2. ```auto node = rclcpp::Node::make_shared("my_node_name");```
26 | - It calles a method of namespace ```rclcpp::Node``` to create a shared pointer to an instance.
27 | - It is an efficient way to creat a simple node.
28 |
29 | ### 1.2 Edit CMakeLists to build node**
30 | Since we use the binding, rclcpp, to interact with rcl, linking rclcpp to our node is necessary.
31 |
32 |
33 | ```cmake
34 | cmake_minimum_required(VERSION 3.5)
35 | project(hello_package)
36 |
37 | find_package(ament_cmake REQUIRED)
38 |
39 | #------------TO ADD------------#
40 | find_package(rclcpp REQUIRED) #like binding for rcl
41 |
42 | add_executable(hello_node src/hello_node.cpp)
43 |
44 | # link rclcpp for node
45 | ament_target_dependencies(hello_node rclcpp)
46 | # or target_link_libraries(hello_node rclcpp)
47 | # choose ament_target_dependencies if use overlay workspaces
48 |
49 | #------------TO ADD------------#
50 |
51 | install(TARGETS hello_node
52 | DESTINATION lib/${PROJECT_NAME})
53 |
54 | ```
55 | More detials about understanding cmake commands can be found in cmake tutorial of the author. Here we only explain key ideas of commands used here. Two main commands are
56 | - ```find_package(rclcpp REQUIRED)``` to locate lib rclcpp
57 | - ```ament_target_dependencies(hello_node rclcpp) ``` to link rclcpp with our node (exe).
58 |
59 | Referces
60 | 1. ament_cmake user documentation https://docs.ros.org/en/foxy/How-To-Guides/Ament-CMake-Documentation.html
61 |
62 |
63 |
64 | ### 1.3 Edit package.xml to add dependence
65 | rclcpp
66 |
67 |
68 |
69 |
70 | ### 1.4 Develop Launch file
71 | Three methods are available to create launch fiels: Python scripts, XML, YAML.
72 |
73 | XML files are used in ROS and no addiontal efforts are needed.
74 |
75 | Recall the strucre of a pkg
76 | ```
77 | my_package/
78 | CMakeLists.txt
79 | include/my_package/
80 | package.xml
81 | src/
82 | launch/
83 | ```
84 | A launch file with extention *name.launch.xml* must be created in folder launch.
85 | ```shell
86 | cd my_package/launch
87 | touch name.launch.xml
88 | ```
89 | Edit name.launch.xml to launch an exe from a pkg as
90 |
91 | ```xml
92 |
93 |
94 |
95 |
96 | ```
97 | **Note**
98 | Remember everything everying built will be installed, so we need to install the folder launch as well such that ros2 launch can find these files.
99 |
100 | In fact, when we can ros2 launch, ros2 run launch files in folder install, not in folder src. It means, everytime we modify launch files, we must rebuild the pkg.
101 |
102 | In CMakeLists.txt, we add install commands as
103 |
104 | ```cmake
105 | # install launch folder so ros2 launch can find launch files
106 | install(DIRECTORY
107 | launch
108 | DESTINATION share/${PROJECT_NAME}/
109 | )
110 | ```
111 |
112 | It is also suggested to add ```ros2launch``` in package.xml.
113 |
114 | Here is how to call hello_node from hello_package with launch file say_hello.launch.xml.
115 |
116 | ```shell
117 | # go to ros2_ws
118 | cd ros2_ws
119 | # build pkg
120 | colcon build packages-select hello_package
121 | # source
122 | source install/local_setup.bash
123 | # call launch command
124 | ros2 launch hello_package say_hello.launch.xml
125 | ```
126 |
127 | ### Reference
128 |
129 | 1. Create a ROS2 Cpp Package, https://roboticsbackend.com/create-a-ros2-cpp-package/
130 | 2. Creating a launch file, https://docs.ros.org/en/foxy/Tutorials/Intermediate/Launch/Creating-Launch-Files.html
131 |
132 | 3. ROS2 - Create a Launch File with XML, https://youtu.be/Le1vx1_KUDQ
133 |
134 | 4. Write a Minimal ROS2 Cpp Node, https://roboticsbackend.com/write-minimal-ros2-cpp-node/
135 |
136 | ## 2 Write a publisher in C++
137 | s
138 |
139 |
140 |
--------------------------------------------------------------------------------
/8_4_ROS2_Ardupilot_PX4.md:
--------------------------------------------------------------------------------
1 | ## 1 DDS for Ardupilot and PX4
2 |
3 |
4 | ## 2 Install libs and pkgs for Ardupilot
5 | Main reference is [ROS 2](https://ardupilot.org/dev/docs/ros2.html).
6 |
7 |
8 | https://ardupilot.org/dev/docs/ros2.html
9 |
10 |
11 | ### 2.2 mavros for ros2
12 |
13 | #### 2.2.1 run mavros2
14 | ```shell
15 | ros2 run mavros mavros_node --ros-args --param fcu_url:=udp://127.0.0.1:14551@14555
16 | ```
17 | #### 2.2.2 docker for mavros2
18 | docker source [rockstarartist/mavros2](https://hub.docker.com/r/rockstarartist/mavros2)
19 |
20 | 1. get ardupilot in simulation
21 | ```shell
22 | sim_vehicle.py -v ArduCopter --console
23 | ```
24 |
25 | 2. we can use mavros like
26 | ```shell
27 | roslaunch mavros apm.launch fcu_url:=udp://127.0.0.1:14551@14555
28 | ```
29 |
30 | 3. use mavros2 in docker
31 | A docker image of mavros2 is created here [rockstarartist/mavros2](https://hub.docker.com/r/rockstarartist/mavros2).
32 | - build the container from that image
33 | ```shell
34 | docker pull rockstarartist/mavros2
35 | ```
36 | - run mavros2
37 | ```shell
38 | docker run -v /dev/shm:/dev/shm --net=host rockstarartist/mavros2:humble-x86 ros2 run mavros mavros_node --ros-args -p fcu_url:=udp://:14561@localhost:5901 -p tgt_system:=1
39 | ```
40 | [Executing commands on Pixhawk with ArduPilot via MAVROS2](https://github.com/mavlink/mavros/issues/1863)
41 |
42 | [How to use mavros2](https://github.com/mavlink/mavros/issues/1718)
43 |
44 | [How to install mavros inside the container with ros2 humble preinstalled](https://github.com/mavlink/mavros/issues/1864)
45 |
46 | [MAVROS2: RC-Override in ROS2 Foxy - Equivalent of rosrun mavros mavparam set SYSID_MYGCS 1](https://github.com/mavlink/mavros/issues/1866)
47 |
48 | [basic ros2 topic run](https://github.com/mavlink/mavros/issues/1902)
49 |
50 |
51 |
52 |
53 |
54 | read those
55 |
56 | https://github.com/mavlink/mavros/issues/815
57 |
58 | https://github.com/mavlink/mavros/issues/1469
59 |
60 | https://github.com/mavlink/mavros/issues/1423
61 |
62 | https://github.com/mavlink/mavros/issues/1423
63 |
64 | https://github.com/mavlink/mavros/issues/1564
65 |
66 | https://github.com/mavlink/mavros/issues/1793
67 |
68 | https://github.com/mavlink/mavros/issues/1582
69 |
70 | user docker
71 | https://github.com/mavlink/mavros/issues/1864
72 |
73 | https://hub.docker.com/r/rockstarartist/mavros2
74 |
75 | MAvlink
76 | https://zhuanlan.zhihu.com/p/415266156
77 |
78 |
79 | ## 3. Set ROS2 for PX4
80 | Main reference is [ROS 2 User Guide](https://docs.px4.io/main/en/ros/ros2_comm.html#foxy).
81 |
82 | ```shell
83 | make px4_sitl gz_x500
84 | ```
85 |
86 | ```shell
87 | MicroXRCEAgent udp4 -p 8888
88 | ```
89 |
90 | ```shell
91 | # use ament_garge for ros2 pkgs
92 | ament_target_dependencies(frame_transforms geometry_msgs sensor_msgs)
93 | # use targe_link for pkg Eigen3
94 | target_link_libraries(frame_transforms Eigen3::Eigen)
95 | ```
--------------------------------------------------------------------------------
/8_Arduploit/Ardu_sim_Q.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/Ardu_sim_Q.png
--------------------------------------------------------------------------------
/8_Arduploit/Arduploit_PX4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/Arduploit_PX4.png
--------------------------------------------------------------------------------
/8_Arduploit/Custmer_build_Arduploit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/Custmer_build_Arduploit.png
--------------------------------------------------------------------------------
/8_Arduploit/ardupilot_interface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/ardupilot_interface.png
--------------------------------------------------------------------------------
/8_Arduploit/arduploit_simu_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/arduploit_simu_test.png
--------------------------------------------------------------------------------
/8_Arduploit/arm_throttle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/arm_throttle.png
--------------------------------------------------------------------------------
/8_Arduploit/available_boards.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/available_boards.png
--------------------------------------------------------------------------------
/8_Arduploit/build_bin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/build_bin.png
--------------------------------------------------------------------------------
/8_Arduploit/build_config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/build_config.png
--------------------------------------------------------------------------------
/8_Arduploit/build_result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/build_result.png
--------------------------------------------------------------------------------
/8_Arduploit/choose_download_ardupilot_version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/choose_download_ardupilot_version.png
--------------------------------------------------------------------------------
/8_Arduploit/drone_gazebo_takeoff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/drone_gazebo_takeoff.png
--------------------------------------------------------------------------------
/8_Arduploit/guided.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/guided.png
--------------------------------------------------------------------------------
/8_Arduploit/mavors_state_local_pose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/mavors_state_local_pose.png
--------------------------------------------------------------------------------
/8_Arduploit/mavros_topics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/mavros_topics.png
--------------------------------------------------------------------------------
/8_Arduploit/takeoff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_Arduploit/takeoff.png
--------------------------------------------------------------------------------
/8_ROS2/API_structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/API_structure.png
--------------------------------------------------------------------------------
/8_ROS2/DDS_ROS2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/DDS_ROS2.png
--------------------------------------------------------------------------------
/8_ROS2/Maruyama.ExploringROS2.2016.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/Maruyama.ExploringROS2.2016.pdf
--------------------------------------------------------------------------------
/8_ROS2/Nodes-TopicandService.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/Nodes-TopicandService.gif
--------------------------------------------------------------------------------
/8_ROS2/ROS2_Index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/ROS2_Index.png
--------------------------------------------------------------------------------
/8_ROS2/ROS2_overlays.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/ROS2_overlays.png
--------------------------------------------------------------------------------
/8_ROS2/Screenshot from 2023-06-02 17-19-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/Screenshot from 2023-06-02 17-19-02.png
--------------------------------------------------------------------------------
/8_ROS2/check_local_support.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/check_local_support.png
--------------------------------------------------------------------------------
/8_ROS2/colcon_build_pkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/colcon_build_pkg.png
--------------------------------------------------------------------------------
/8_ROS2/colcon_create_pkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/colcon_create_pkg.png
--------------------------------------------------------------------------------
/8_ROS2/colcon_pkg_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/colcon_pkg_run.png
--------------------------------------------------------------------------------
/8_ROS2/colcon_source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/colcon_source.png
--------------------------------------------------------------------------------
/8_ROS2/grapsh_talker_listener.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/grapsh_talker_listener.png
--------------------------------------------------------------------------------
/8_ROS2/structures_ROS_ROS2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/structures_ROS_ROS2.png
--------------------------------------------------------------------------------
/8_ROS2/talker_listener.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/talker_listener.png
--------------------------------------------------------------------------------
/8_ROS2/universal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EEEManchester/drone_build_tutorial/e43b8bbab732ebe356b171d265c06b7bfc5832ae/8_ROS2/universal.png
--------------------------------------------------------------------------------
/9_2_ROS_Ardupilot.md:
--------------------------------------------------------------------------------
1 | # 3 ROS and Ardupilot
2 | https://nrotella.github.io/journal/arducopter-flight-controllers.html
3 |
4 | https://nrotella.github.io/journal/ardupilot-drone-control-stack.html
5 |
6 |
7 | # 4 ROS2 and Ardupilot
--------------------------------------------------------------------------------
/9_Arduploit.md:
--------------------------------------------------------------------------------
1 | # Kiss Ardupilot
2 | Arduploit is a great choice for people tired of PX4. Of course, be a nice guy, I should cite someone telling the differences
3 |
4 |
5 |
7 |
8 |
9 |
10 | ## 2 Learn code of ArduCopter
11 | Ardupilot is mainly built on C++ and Class are used widely there.
12 |
13 | Source [Learning the ArduPilot Codebase](https://ardupilot.org/dev/docs/learning-the-ardupilot-codebase.html).
14 | [ArduCopter Flight Controllers](https://nrotella.github.io/journal/arducopter-flight-controllers.html)
15 |
16 | ```mermaid
17 | ---
18 | title: control diagram for mode stablize
19 | ---
20 | classDiagram
21 | Copter -- Mode
22 | ModeStabilize --|> Mode
23 |
24 | ModeStabilize -- AC_AttitudeControl
25 | AC_AttitudeControl_Multi --|> AC_AttitudeControl
26 | class Copter{
27 | - void fast_loop()
28 | + motors_output()
29 | }
30 |
31 | class Mode{
32 | - void update_flight_mode()
33 | + void get_pilot_desired_lean_angles()
34 | + float get_pilot_desired_yaw_rate()
35 | }
36 |
37 | class ModeStabilize{
38 | - run()
39 | }
40 |
41 | class AC_AttitudeControl{
42 | - void input_euler_angle_roll_pitch_euler_rate_yaw()
43 | + void attitude_controller_run_quat()
44 | - void control_monitor_update()
45 | }
46 |
47 | class AC_AttitudeControl_Multi{
48 | + void rate_controller_run()
49 | + void update_throttle_gain_boost()
50 | + void update_throttle_rpy_mix()
51 | }
52 |
53 | ```
54 |
55 | Explanation of methods
56 | + AC_AttitudeControl_Multi
57 | - ```rate_controller_run()```, AC_AttitudeControl_Multi.cpp, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.cpp
58 | - ```update_throttle_rpy_mix()```, AC_AttitudeControl_Multi.cpp, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.cpp
59 | - ```void update_throttle_gain_boost()```
60 | + AC_AttitudeControl
61 | - attitude_controller_run_quat, AC_AttitudeControl.cpp, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl.cpp
62 | - input_euler_angle_roll_pitch_euler_rate_yaw, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl.cpp
63 | + AC_AttitudeControl_Multi
64 | - rate_controller_run(), https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.cpp
65 | - set_throttle_out, AC_AttitudeControl_Multi, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.cpp
66 | + ModeStabilize
67 | - run()
68 | + Motor
69 | - motor output https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/ArduCopter/motors.cpp
70 | - control_monitor_update(), ControlMonitor.cpp, https://github.com/ArduPilot/ardupilot/blob/Copter-4.2/libraries/AC_AttitudeControl/ControlMonitor.cpp.
71 |
72 |
73 | ### 2.1 Position control
74 | Source:
75 | - [Copter Position Control and Navigation](https://ardupilot.org/dev/docs/code-overview-copter-poscontrol-and-navigation.html)
76 |
77 |
78 |
79 | ### 2.3 Attitude control
80 | - [Copter Attitude Control](https://ardupilot.org/dev/docs/apmcopter-programming-attitude-control-2.html)
81 |
82 | ## 3 Guided mode and Guided_NoGPS mode
83 | Guided Mode allows us to control Ardupilot from an onboard computer autonoumously. This is usually essentially needed in research on drones.
84 |
85 | Ardupilot provides us with two guided modes:
86 | - Guided mode that requires a GPS and enables to send one of post, vel and acc comands and some combinations of them.
87 | - Guided_NoGPS mode that can take angle or body rate commands.
88 |
89 | Source
90 | - [ArduCopter Flight Controllers](https://nrotella.github.io/journal/arducopter-flight-controllers.html)
91 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Drone tutorial
2 | This tutorial aims to provide guides on building a drone from kits and ending at controlling drones in experiments.
3 |
4 | ## Main contents
5 |
6 | ### 1 Simulation
7 |
8 | #### 1.1 Simulation for a **single** quadrotor with PX4 and Ardupilot in ROS
9 | It explains how to install and configure PX4 or Ardupilot, ROS and ROS packages for ROS-Gazebo simulation.
10 |
11 | - Single drone with PX4
12 | - [Set up PX4, ROS and mavros](2_1_Simulation_ROS_PX4.md) shows how to simulate a **single** quadrotor with the **PX4** firmware in Gazebo.
13 | - [Run controller in ROS-Gazebo simulation for PX4](2_3_Simulation_PX4_Gazebo.md) demonstrates how to use a **controller** in ROS to controller a **single** quadrotor with the **PX4** firmware in Gazebo.
14 |
15 | - Single drone with Ardupilot
16 | - [Set up Ardupilot, ROS and mavros](2_2_Simulation_ROS_Ardupilot.md) explains the steps to simulate a **single** quadrotor with the **Ardupilot** firmware in Gazebo.
17 | - [Run controller in ROS-Gazebo simulation for Ardupilot] ##TODO
18 |
19 |
20 | #### 1.2 Simulation for **multiple** quadrotors with PX4 and Ardupilot in ROS ##TODO
21 |
22 | - Multiple drones with PX4
23 | - Multiple drones with Ardupilot
24 |
25 |
26 | ### 2 Experiment preparation
27 |
28 | #### 2.1 Assembly drones
29 | 1. [Build Holybro X500 kit](2_1_X500_Pixhawk5.md)
30 | 2. [Build TransTEC Lightning X Lite with Kakute ](2_2_LightningXLite_Kakute.md)
31 | - Ardupilot
32 | - Chassis TransTEC Lightning X Lite
33 | - Motor FPV 致盈EX2306 PLUS [site in Taobao](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.27.52b858176s1EdF&id=634695941707)
34 | - ESC:
35 | - [Tekko32 F4 Metal 4in1 65A ESC (65A)](https://holybro.com/collections/fpv-esc/products/tekko32-f4-metal-4in1-65a-esc-65a)
36 | - [HAKRC 3260A ESC BLHeli-32 ](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.32.193244beujIlvo&id=624599427940)
37 | - Autopilot: - Kakute H7 v1.3 [site in Taobo](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.28.56917484ySIhA5&id=684452325988)
38 | 3. [Build TransTEC Lightning X Lite with Aocoda](2_3_LightningXLite_Aocoda.md)
39 | - BetaFlight
40 | - Chassis TransTEC Lightning X Lite
41 | - Motor FPV 致盈EX2306 PLUS [site in Taobao](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-22611654657.27.52b858176s1EdF&id=634695941707)
42 | - ESC: Aocoda 60A 4 in 1 [site in Taobao](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xw5sv5&id=682898024012)
43 | - Autopilot: - Aocoda RC H743 [site in Taobo](https://item.taobao.com/item.htm?spm=a1z0d.6639537/tb.1997196601.4.55627484xUOMZu&id=679995875558)
44 |
45 | #### 2.2 Configure and tune autopilot for manual flight
46 | 1. PX4
47 | 2. [Ardupilot](2_4_Config_Ardupilot.md)
48 | 3. [Betaflight](2_5_Config_BetaFlight.md)
49 |
50 | #### 2.3 Onboard computer setup
51 |
52 | It demonstrates steps to add an onboard computer to a drone. It includes how to power it within the power system of Pixhawk and how to enable ROS communication among it, Pixhawk and base station.
53 |
54 | 1. Set up onboard computer
55 | - [Set up Raspberry Pi as onboard computer](4_Experiment_OnboardComputer_Pi.md)
56 | 2. Enable communication between onboad computer and autopilot
57 | - [Set up communication between Pi and Pixhawk with PX4](4_Experiment_Communication_Pi_Pixhawk.md)
58 | 3. Enable communication between onboad computer and base station in ROS through WIFI
59 | - [Set up ROS communcation between onboard computer and base station through WIFI](4_Experiment_ROS_Communication_Pi_BaseStation.md)
60 |
61 | ### 3 Drone controllers
62 | 1. [Use mavros_controller](7_Mavros_Controller.md)
63 | It explains how the drone control package mavros_controller is designed and what to do to implement it in experiment.
64 |
65 | ### 4 Experiment in cases
66 | #### 4.1 Indoor flights with VIcon
67 | 1. [Set up and use Vicon system](6_Vicon_Setup_Use.md)
68 | It gives an idea of how to use a motion capture system for drone experiments.
69 |
70 |
71 |
72 | #### 4.2 Add functional payloads and sensors
73 | 1. [Add more devices to drone in experiment](5_Experiment_Hardware_Setup.md)
74 | It suggests what to do if more additional devices are to be added to a drone to extend its functions.
75 |
76 | ### 5 ROS2 for drones
77 | 1. [ROS2 and PX4](8_ROS2_PX4.md)
78 | It aims to move every drone techniques in ROS to ROS2.
--------------------------------------------------------------------------------
/digraph prof {.rs:
--------------------------------------------------------------------------------
1 | digraph prof {
2 | fontname="Helvetica,Arial,sans-serif"
3 | node [fontname="Helvetica,Arial,sans-serif"]
4 | edge [fontname="Helvetica,Arial,sans-serif"]
5 | node [style=filled];
6 | rankdir=LR;
7 | compound=true;
8 | // Model_Stablize
9 | subgraph cluster_0 {
10 | style=filled;
11 | color=lightgrey;
12 | node [style=filled,color=white];
13 | Model_Stablize_run0[label="run()"]
14 | Model_Stablize_update_simple_mode0[label="update_simple_mode()"]
15 | Model_Stablize_run0 -> Model_Stablize_update_simple_mode0
16 | label = "Model_Stablize";
17 | }
18 |
19 | // Copter
20 | subgraph cluster_1 {
21 | style=filled;
22 | color=lightgrey;
23 | node [style=filled,color=white];
24 | Copter_update_simple_mode0[label="update_simple_mode()"]
25 | Copter_fast_loop[label="fast_loop()"]
26 | Copter_update_flight_mode[label="update_flight_mode()"]
27 | label = "Copter";
28 | }
29 |
30 | Model_Stablize_run0 -> Copter_update_simple_mode0
31 | Copter_fast_loop -> Copter_update_flight_mode
32 | Copter_update_flight_mode -> Model_Stablize_run0
33 | Copter_fast_loop -> AC_AttitudeControl_Wulti_rate_controller_run
34 |
35 | // Mode
36 | subgraph cluster_2 {
37 | style=filled;
38 | color=lightgrey;
39 | node [style=filled,color=white];
40 | Mode_get_pilot_desired_lean_angles[label="get_pilot_desired_lean_angles()"]
41 | Mode_get_pilot_desired_yaw_rate[label="get_pilot_desired_yaw_rate()"]
42 | label = "Mode";
43 | }
44 | //
45 | Model_Stablize_run0 -> Mode_get_pilot_desired_lean_angles
46 | Model_Stablize_run0 -> Mode_get_pilot_desired_yaw_rate
47 |
48 |
49 | // AC_AttitudeControl
50 | subgraph cluster_3 {
51 | style=filled;
52 | color=lightgrey;
53 | node [style=filled,color=white];
54 | AC_AttitudeControl_input_euler_angle_roll_pitch_euler_rate_yaw[label="input_euler_angle_roll_pitch_euler_rate_yaw()"]
55 | AC_AttitudeControl_attitude_controller_run_quat[label="attitude_controller_run_quat()"]
56 | label = "AC_AttitudeControl";
57 | AC_AttitudeControl_input_euler_angle_roll_pitch_euler_rate_yaw->AC_AttitudeControl_attitude_controller_run_quat
58 | }
59 | //
60 | Model_Stablize_run0 -> AC_AttitudeControl_input_euler_angle_roll_pitch_euler_rate_yaw
61 |
62 | // AC_AttitudeControl_Wulti
63 | subgraph cluster_4 {
64 | style=filled;
65 | color=lightgrey;
66 | node [style=filled,color=white];
67 | AC_AttitudeControl_Wulti_set_throttle_out[label="set_throttle_out()"]
68 | AC_AttitudeControl_Wulti_rate_controller_run[label="rate_controller_run()"]
69 |
70 | label = "AC_AttitudeControl_Wulti";
71 | }
72 | Model_Stablize_run0 -> AC_AttitudeControl_Wulti_set_throttle_out
73 |
74 |
75 | }
--------------------------------------------------------------------------------