ROS ----------- Code architecture - Overview ``````````````````````` .. figure:: ../_static/images/heifu/ArqROS_HEIFU.webp :alt: image Pre-requisites ``````````````````````` **Install ROS acording to your distribuiton:** ROS Instalation page can be found `here `__. **Setup your catkin workspace:** .. code:: bash sudo apt install python-catkin-tools Create a workspace folder .. code:: bash mkdir -p /src cd catkin build **GeographicLib dependencies:** .. code:: bash sudo apt-get install libgeographic-dev sudo apt-get install geographiclib-tools Run the script in: `install_geographiclib_datasets.sh `__ Installation ``````````````````````` **NOTE:** It’s recommended too add a SSH key to your gitlab account. **Start by cloning and compiling this repository** .. code:: bash cd /src git clone git@gitlab.pdmfc.com:drones/ros1/heifu-uav/heifu.git cd heifu git submodule update --init --recursive catkin build **Source Your Workspace:** .. code:: bash echo 'source /devel/setup.bash' >> ~/.bashrc source ~/.bashrc Installation (detailed overview) '''''''''''''' **ROS packages dependences:** \* gazebo-ros \* mavros `here `__ \* mavlink \* geographic-msgs \* tf2-eigen \* control-toolbox \* ros_utils `here `__ \* GNSS_utils `here `__ **GeographicLib dependeces:** .. code:: bash sudo apt-get install libgeographic-dev sudo apt-get install geographiclib-tools Run the script in: `install_geographiclib_datasets.sh `__ Compile this directory in your ROS workspace. Then copy the already configured files to the *mavros* directory: .. code:: bash cd ${YOUR_ROS_WORKSPACE}/src/heifu/heifu_scripts_firmware cp apm_config.yaml $(rospack find mavros)/launch/ cp apm.launch $(rospack find mavros)/launch/ cp node.launch $(rospack find mavros)/launch/ **NOTE:** Adjust the yaml loader script to deal with the argument substitution in the *roslaunch* of yaml files: .. code:: bash cd ${YOUR_ROS_WORKSPACE}/src/heifu/heifu_scripts_firmware cp loader.py /opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/ Dont forget to add `gimbal `__ and `mavros `__ to the source folder and run ``catkin build`` To run the nodes with a real drone: Just launch - Heifu_bringup .. code:: sh roslaunch heifu_bringup heifu_bringup.launch **Launch Input arguments:** .. code:: sh argSafety # Activates the safety zone mode and run the node heifu_safety. argTakeOffAltitude # Defines the Takeoff altitude. argSim # Activates the simulation mode. Loads Gazebo and a pre-configured world with the drone HEIFU. argSecredas # Activates the Secredas Usecases. (Needs extra packages secredas). argUseCase # Defines witch usecase of Secredas will be loaded. argPlanners # Loads the Planners nodes with static colision avoidance (Needs extra packages Planners). HELP - How to get going '''''''''''''' .. code:: bash roslaunch heifu-bringup heifu_bringup.launch argVehicle:="heifu" argID:=0 argSimulation:=false Package description ``````````````````````` **GCS Interface:** Interface for converting commands and information from and to a remote control station, respectively. **Waypoint Manager:** Reads mission files from the UAV and sends them to the respective nodes. Allows following a mission in guided mode. **GNSS Utils:** Auxiliary to the Waypoints manager package. Converts global coordinates to local coordinates. **Planners:** Responsible for finding a collision-free path to the desired waypoint. **Collision Avoidance:** Deals with the information from the perception sensors and ensures the safety of the UAV. **Priority Manager:** Receives all setpoints from the respective packages. Responsible for managing the priorities of each package, sending always the command with the highest priority to the navigation controller. **Mavros Commands:** Responsible for general flight commands handling, such as takeoff, land, and mode changes. **Navigation Controller:** Responsible for controlling and completing given waypoints. Can be used with position setpoints or velocity setpoints. Guarantees that the requested position is achieved. Can receive a velocity bypass setpoint. **Mavros:** Responsible for the comunication between ROS and the flight Packages ``````````````````````` Heifu Simulation '''''''''''''' First make sure that the ArduPilot firmware is correctly installed, by following the steps described `here `__. To open the simulation: 1st terminal - Launch Heifu_bringup .. code:: sh roslaunch heifu_bringup heifu_bringup.launch argSim:=true 2nd terminal - Launch ArduPilot firmware .. code:: sh cd ~/ardupilot/ArduCopter/ sim_vehicle.py -v ArduCopter -f gazebo-heifu -I1 3rd terminal - Launch Client Interface (Only to work on Beyond Skyline app) .. code:: sh cd ~/heifu_ws/src/heifu/heifu_interface python heifu_interface.py To load Multples drones in simulation: 1st terminal - Launch Heifu_bringup where that arguments must be unique: - DRONE_NAME: Drone namespace - DRONE_NUMBER: Drone ID number to simulated firmware (must be the same value launched in ArduPilot Firmware argument “-I”) - LOCAL_POSITION_X: Local position X that the drone will be spawned in meters - LOCAL_POSITION_Y: Local position Y that the drone will be spawned in meters Run Gazebo first: .. code:: sh roslaunch heifu_description gazebo.launch Script to launch a drone in simulation: .. code:: sh cd ~/heifu_ws/src/heifu/scripts sh spawn_drone.sh DRONE_NAME DRONE_ID DRONE_POSITION_X DRONE_POSITION_Y Without script: .. code:: sh roslaunch heifu_bringup heifu_bringup.launch argSim:=true argNamespace:=DRONE_NAME argID:=DRONE_NUMBER xi:=LOCAL_POSITION_X yi:=LOCAL_POSITION_Y gazebo:=false 2nd terminal - Launch ArduPilot firmware The argument -I must be the same DRONE_NUMBER .. code:: sh cd ~/ardupilot/ArduCopter/ sim_vehicle.py -v ArduCopter -f gazebo-heifu -IDRONE_NUMBER 3rd terminal - Launch Client Interface The argument DRONE_NAME must be the same on Heifu_bringup .. code:: sh cd ~/heifu_ws/src/heifu/heifu_interface python heifu_interface.py DRONE_NAME Example to 2 drones in simulation: Launch Gazebo: .. code:: sh roslaunch heifu_description gazebo.launch Launch drone 1: 1st terminal - Launch Heifu_bringup DRONE 1 .. code:: sh roslaunch heifu_bringup heifu_bringup.launch argSim:=true argNamespace:=heifu argID:=1 xi:=10 yi:=5 gazebo:=false 2nd terminal - Launch ArduPilot firmware DRONE 1 .. code:: sh cd ~/ardupilot/ArduCopter/ sim_vehicle.py -v ArduCopter -f gazebo-heifu -I1 3rd terminal - Launch Client Interface DRONE 1 .. code:: sh cd ~/heifu_ws/src/heifu/heifu_interface python heifu_interface.py heifu Launch drone 2: 1st terminal - Launch Heifu_bringup DRONE 2 .. code:: sh roslaunch heifu_bringup heifu_bringup.launch argSim:=true argNamespace:=valk argID:=2 xi:=-10 yi:=-5 gazebo:=false 2nd terminal - Launch ArduPilot firmware DRONE 2 .. code:: sh cd ~/ardupilot/ArduCopter/ sim_vehicle.py -v ArduCopter -f gazebo-heifu -I2 3rd terminal - Launch Client Interface DRONE 2 .. code:: sh cd ~/heifu_ws/src/heifu/heifu_interface python heifu_interface.py valk Heifu Bringup '''''''''''''' Responsible for load all packages. Heifu Description '''''''''''''' This package contains the drone robot HEIFU and the worlds for the simulation. Heifu Diagnostic '''''''''''''' Responsible for verify the GPS fix state of the drone and send the information to the application. Subscribers ^^^^^^^^^^^^ - /diagnostics (`diagnostic_msgs/DiagnosticArray `_) Publishers ^^^^^^^^^^^^ - /heifu/g/f/m (`std_msgs/Int8 `_) Heifu Interface '''''''''''''' This package is the bridge between the ROS and the application. Subscribers ^^^^^^^^^^^^ - /heifu/disarm (`std_msgs/Empty `_) - /heifu/takeoff (`std_msgs/Empty `_) - /heifu/land (`std_msgs/Empty `_) - /heifu/mavros/local_position/pose (`geometry_msgs/PoseStamped `_) - /heifu/mavros/local_position/velocity_local (`geometry_msgs/TwistStamped `_) - /heifu/mavros/global_position/global (`sensor_msgs/NavSatFix `_) - /heifu/mavros/state (`mavros_msgs/State `_) - /heifu/c/s (`std_msgs/String `_) - /heifu/mavros/battery (`sensor_msgs/BatteryState `_) - /heifu/mavros/global_position/raw/satellites (`std_msgs/UInt32 `_) - /heifu/g/f/m (`std_msgs/String `_) Publishers ^^^^^^^^^^^ - /warning (`std_msgs/String `_) - /heifu/frontend/cmd (`geometry_msgs/Twist `_) - /heifu/land (`std_msgs/Empty `_) - /heifu/takeoff (`std_msgs/Empty `_) - /heifu/mode_auto (`std_msgs/Empty `_) - /heifu/rtl (`std_msgs/Empty `_) - /heifu/global_setpoint_converter (`geographic_msgs/GeoPose `_) Services: ^^^^^^^^^ - /heifu/mavros/mission/clear (`mavros_msgs/WaypointPush `_) - /heifu/mavros/set_mode (`mavros_msgs/SetMode `_) - /heifu/mavros/cmd/arming (`mavros_msgs/CommandBool `_) Heifu Mavros '''''''''''''' This is the main package to control the drone. Responsible for message conversions and commands between the packages and the mavros node. Subscribers ^^^^^^^^^^^^ - /heifu/takeoff (`std_msgs/Empty `_) - /heifu/land (`std_msgs/Empty `_) - /heifu/disarm (`std_msgs/Empty `_) - /heifu/cmd_vel (`geometry_msgs/Twist `_) - /heifu/xbox_vel_raw (`geometry_msgs/Twist `_) - /heifu/mavros/local_position/pose (`geometry_msgs/PoseStamped `_) - /heifu/rtl (`std_msgs/Empty `_) - /heifu/land_vel_raw (`geometry_msgs/Twist `_) - /heifu/simulation_raw (`geometry_msgs/Twist `_) - /heifu/frontend/cmd (`geometry_msgs/Twist `_) - /heifu/mode_auto (`std_msgs/Empty `_) - /heifu/global_setpoint_converter (`geographic_msgs/GeoPose `_) - /heifu/mission/start (`std_msgs/Empty `_) - /heifu/mission/stop (`std_msgs/Empty `_) Publishers ^^^^^^^^^^^ - /heifu/mavros/setpoint_velocity/cmd_vel (`geometry_msgs/TwistStamped `_) - /heifu/xbox_vel (`geometry_msgs/Twist `_) - /heifu/land_vel (`geometry_msgs/Twist `_) - /heifu/simulation (`geometry_msgs/Twist `_) - /heifu//g/f/m (`std_msgs/Int8 `_) - /heifu/mavros/setpoint_position/local (`geometry_msgs/PoseStamped `_) Services: ^^^^^^^^^ - /heifu/mavros/cmd/arming (`mavros_msgs/CommandBool `_) - /heifu/mavros/set_mode (`mavros_msgs/SetMode `_) - /heifu/mavros/takeoff (`mavros_msgs/CommandTOL `_) Heifu Msgs '''''''''''''' This package contain the messages and services necessary to work. Heifu Safety '''''''''''''' If loaded, this package controls the flight area and velocity limit of the drone to a safety real demonstration. Subscribers ^^^^^^^^^^^^ - /heifu/mavros/local_position/pose (`geometry_msgs/PoseStamped `_) - /heifu/xbox_vel (`geometry_msgs/Twist `_) Publishers ^^^^^^^^^^^ - /heifu/xbox_vel_safety (`geometry_msgs/Twist `_) Services: ^^^^^^^^^ - /heifu/EnableSafetyFence (heifu_msgs/EnableSafety) Heifu Simple Waypoint '''''''''''''' This package receive a setpoint and make the drone fly pointed to desired position. Subscribers ^^^^^^^^^^^^ - /heifu/mission/setpoint (`geometry_msgs/Pose `_) - /heifu/mavros/local_position/pose (`geometry_msgs/PoseStamped `_) Publishers ^^^^^^^^^^^ - /heifu/mission/start (`std_msgs/Empty `_) - /heifu/mission/stop (`std_msgs/Empty `_) - /heifu/mavros/setpoint_position/local (`geometry_msgs/PoseStamped `_) Heifu Tools '''''''''''''' Responsible for convert the velocity command messages. Subscribers ^^^^^^^^^^^^ - /heifu/joy (`geometry_msgs/Twist `_) Publishers ^^^^^^^^^^^ - /heifu/dummy_vel (`geometry_msgs/Twist `_) - heifu/xbox_vel_raw (`geometry_msgs/Twist `_)