GX40 Target Click-to-Track
Familiarity with outdoor position hold flight is required first. The following demonstration uses Windows.
5 min read · English documentation- Familiarity with outdoor position-hold flight is required first.
- The following demonstration uses Windows.
Note:
Due to the publication date of this tutorial and upgrades to product features and code:
1. The ground station version may differ from the version shown in this tutorial.
2. The names and order of custom demos in the function scripts may differ slightly.
3. The following tutorial assumes that the communication link, RTK, and Prometheus ground station are ready.
Due to the publication date of this tutorial and upgrades to product features and code:
1. The ground station version may differ from the version shown in this tutorial.
2. The names and order of custom demos in the function scripts may differ slightly.
3. The following tutorial assumes that the communication link, RTK, and Prometheus ground station are ready.
Check Whether the UAV Status Is Normal
RTK Positioning
- Connect to the UAV in Connection Settings (the positioning source must be switched to RTK positioning).
- The status bar displays the current UAV status (whether the UAV flight controller is connected, the current flight mode, control status, RTK positioning status, whether the UAV is armed, etc.).
- The x, y, and z positions should be around 0, indicating that the positioning data is normal.
- A red Prometheus status indicator means that the status is abnormal. The figure below shows a normal status.

Check the Data
- It is normal for the initial position data to be close to 0.
- An excessive error in the initial position data, greater than 0.5, is abnormal (usually caused by an initial data-fusion error or accumulated error after multiple flights).
RTK positioning is normal

Note:
1. The following two scripts, ekf2 stop and ekf2 start, reinitialize EKF2 fusion for the flight controller's position data when the initial data is abnormal or the error is excessive under RTK/MID360 positioning.
2. Run these scripts while checking the data before takeoff. Do not click or use them during flight, as doing so may cause loss of positioning and a crash. (This will be updated later to prevent accidental activation; refer to the official release notes for the applicable behavior.)
1. The following two scripts, ekf2 stop and ekf2 start, reinitialize EKF2 fusion for the flight controller's position data when the initial data is abnormal or the error is excessive under RTK/MID360 positioning.
2. Run these scripts while checking the data before takeoff. Do not click or use them during flight, as doing so may cause loss of positioning and a crash. (This will be updated later to prevent accidental activation; refer to the official release notes for the applicable behavior.)
Initial Data
- Click Function Scripts in the ground station.
- Click ekf2 stop.
- Click ekf2 start.

Start the Function Demo
Note: The following operating steps are the same for RTK/MID360 positioning. The example uses RTK positioning.
- Click Function Scripts.
- Click
GX40 Gimbal Visual Tracking.
- The onboard command is:
/home/amov/p600_experiment/src/p600_experiment/scripts/gimbalx_detection_with_tracking.sh
- A message confirming that the corresponding function demo has started appears.
- After the function demo runs, the list of ROS nodes currently running on the onboard computer is displayed.
- The current CPU usage and CPU temperature are displayed.
Retrieve the GX40 Gimbal Video
View the Stream URL
- Click System Settings.
- Click Streaming Settings.
- The default video stream URL is:
rtsp://192.168.144.60:8554/live- The default configuration can be used.
Display the Image in Video Monitoring
- Click Main Interface.
- Click Video Monitoring.
- Click Play to retrieve the video stream.
- The video stream is retrieved successfully.
Take Off
- Move SW1 to the bottom position to arm the UAV. SW2, SW3, and SW4 should be in the top position at this time.
- The current Prometheus control status is INIT, which corresponds to the flight controller's POSITION mode.
- The UAV video is normal, and general-object recognition begins.
- Move SW2 to the middle position.
- The current Prometheus control status is RC_POS_CONTROL, which is the flight controller's OFFBOARD mode.
- Move SW2 to the bottom position. SW3 and SW4 should be in the top position at this time.
- The current Prometheus control status is COMMAND_CONTROL, which is also the flight controller's OFFBOARD mode.
- The UAV will hover at its current position.
Note:
1. After entering Prometheus-controlled COMMAND_CONTROL mode, the UAV responds to control commands from the onboard computer. You do not need to operate the remote controller at this time and can set it aside while continuing to monitor the flight.
2. If the UAV status becomes abnormal, take manual control with the remote controller, move SW2 to the top position, and land the UAV manually.
1. After entering Prometheus-controlled COMMAND_CONTROL mode, the UAV responds to control commands from the onboard computer. You do not need to operate the remote controller at this time and can set it aside while continuing to monitor the flight.
2. If the UAV status becomes abnormal, take manual control with the remote controller, move SW2 to the top position, and land the UAV manually.
Run the GX40 Gimbal Target Click-to-Track Function
- Click Click.
- Recognized targets are enclosed in boxes and labeled person. (The system is in recognition mode at this point and has not started tracking.)
- Click a recognized target. Its label changes to
ID:1. The UAV then enters tracking mode, moves toward the target, and maintains the default distance from it.
- When the target moves, the UAV tracks it while maintaining a certain distance.
Cancel the Gimbal Target Click-to-Track Function
- Select Click.
- Right-click in the video to cancel tracking. The UAV will hover at its current position.
- After tracking is canceled, the recognition program continues to run normally. You can click another recognized target to track it.
Land the UAV
Land Using Prometheus Control
Landing Method 1: Send a Landing Command from the Prometheus Ground Station
- The UAV must currently be in COMMAND_CONTROL.
- Click Data Monitoring.
- Click Land.
Landing Method 2: Send a Landing Command with the H16 Remote Controller
- The UAV must currently be in COMMAND_CONTROL with a normal status. Move SW4 to the bottom position to perform a Prometheus-controlled landing.
Landing Method 3: Land Manually
- Move SW2 to the top position to enter flight-controller-controlled POSITION mode. The UAV now responds to the remote controller.
- Slowly move the left stick all the way down to control the UAV's landing manually.
- After the UAV lands, wait for it to disarm automatically, or move SW3 to the bottom position to stop the propellers with one switch action.
Gimbal Control
- Click Manual Control.
- Double-click Stop to recenter the gimbal.
Handling Abnormal UAV States
False Recognition While Tracking
- Select Click.
- Right-click in the video to cancel tracking, and then click the target to track it again.
Function Parameters
- The script used by this function is:
`/home/amov/p600_experiment/src/p600_experiment/scripts/gimbalx_detection_with_tracking.sh`
- The script contents are as follows:
gnome-terminal --window -e 'bash -c "roslaunch p600_experiment gimbalx_server.launch; exec bash"' \
--tab -e 'bash -c "sleep 2; roslaunch p600_experiment gimbalx_detection_with_tracking.launch; exec bash"' \
--tab -e 'bash -c "sleep 4; roslaunch p600_experiment gimbalx_yolov5_tracking.launch; exec bash"' \
Gimbal Driver
- The contents of gimbalx_server.launch are as follows:
- File path:
/home/amov/p600_experiment/src/p600_experiment/launch_spirecv/gimbalx_server.launch
<launch>
<node pkg="spirecv_ros" type="gimbal_server" name="gimbal_server" output="screen">
<param name="Type" type="string" value="GX40" />
<param name="Port" type="string" value="/dev/ttyTHS1" />
<param name="camera" type="string" value="192.168.144.108" />
<param name="FPS" type="int" value="30" />
<param name="H" type="int" value="720" />
<param name="W" type="int" value="1280" />
</node>
</launch>
Gimbal Tracking
- The contents of gimbalx_detection_with_tracking.launch are as follows:
- File path:
/home/amov/p600_experiment/src/p600_experiment/launch_spirecv/gimbalx_detection_with_tracking.launch
<launch>
<node pkg="spirecv_ros" type="gimbal_detection_with_tracking" name="gimbal_detection_with_tracking" output="screen">
<param name="uav_id" type="int" value="1" />
<param name="camera_parameters" type="string" value="$(find spirecv_ros)/camera_params/calib_webcam_1280x720.yaml" />
<param name="local_saving_path" type="string" value="$(find spirecv_ros)" />
<param name="input_image_topic" type="string" value="/uav1/gimbal/image_original" />
<param name="output_image_topic" type="string" value="/uav1/spirecv/image_det" />
</node>
</launch>
UAV Tracking
- The contents of gimbalx_yolov5_tracking.launch are as follows:
- File path:
/home/amov/p600_experiment/src/p600_experiment/launch_spirecv/gimbalx_yolov5_tracking.launch
<launch>
<node pkg="p600_mission" type="gimbal_yolov5_tracking" name="gimbal_yolov5_tracking" output="screen">
<param name="uav_id" value="1" />
<param name="kp_x" type="double" value="0.3" />
<param name="kp_z" type="double" value="0.1" />
<param name="kp_gimbal" type="double" value="1.0" />
<param name="max_velocity" type="double" value="2.5" />
<param name="max_yaw_rate" type="double" value="40" />
<param name="tracking_distance" type="double" value="10.0" />
</node>
</launch>
