Autonomous Navigation Drone Implementation with PX4, ROS, T265, and LD06 Radar: Code Guide
Obtaining the Code
Clone the code repository to your home directory using Git:
cd ~
git clone https://gitee.com/your-repo/drone_autonomy.git
Alternatively, download the compressed workspace package and extract it directly to your home directory.
Workspace Compilation
Move the drone_autonomy_ws directory from the cloned repository to your home directory, then compile the ROS workspace:
cd ~/drone_autonomy_ws
catkin_make
source devel/setup.bash
System Context
This codebase enables autonomous navigation for drones using the PX4 flight stack, ROS MoveBase framework, Intel T265 visual-inertial camera, and LD06 single-line lidar. It supports both real hardware deployment and PX4 simulation environments.
Sensor Configuraton
- T265 Setup: Configure the Intel T265 to publish odometry data to MAVROS. Refer to official ROS-PX4 integration tutorials for calibration and topic mapping.
- Lidar Integration: Launch your LD06 lidar driver and confirm the
LaserScantopic is active. Update the costmap configuration indrone_autonomy_ws/src/drone_nav/config/costmap_common_params.yamlto match your lidar's coordinate frame and topic:observation_sources: lidar_scan lidar_scan: {sensor_frame: lidar_link, data_type: LaserScan, topic: /ld06/scan, marking: true, clearing: true}
Launch File Details
cartographer_slam.launch: Starts Cartographer SLAM backend (headless, no RViz visualization)mapping_launch.launch: Launches Cartographer with RViz for real-time 2D mappingmove_base_core.launch: Loads core MoveBase navigation parameters (internal use only)mapping_nav.launch: Enables simultaneous mapping and autonomous navigationlocal_nav_only.launch: Local navigation mode without pre-built maps (uses real-time sensor data for obstacle avoidance)simulation_launch.launch: Integration with PX4 Software-In-The-Loop (SITL) simulation
Key Source Files
px4_movebase_bridge.cpp: Core node that converts MoveBase's velocity commands into MAVROS-compatible messages for PX4. It includes conditional logic to handle real hardware and simulation environments, with detailed comments in the code.waypoint_navigator.cpp: Implements waypoint-based autonomous navigation. The default setup targets a single waypoint; extend the code by adding addditional waypoints to the predefined list for multi-point missions.
Operational Workflow (Local Navigation Example)
- Ensure MAVROS is connected to the PX4 flight controller and T265 odometry is active.
- Launch the local navigation stack:
cd ~/drone_autonomy_ws source devel/setup.bash roslaunch drone_nav local_nav_only.launch - Open a new terminal to start the PX4-MoveBase bridge node:
cd ~/drone_autonomy_ws source devel/setup.bash rosrun drone_nav px4_movebase_bridge - The drone will automatically take off and hover at approximately 0.6m altitude. Use RViz's 2D Nav Goal tool to send navigation targets.
Extension Options
- Alternative Localization: Replace the T265 with lidar-based SLAM (e.g., GMapping) combined with barometric altitude. Publish the odometry pose to
mavros/vision_pose/posefor integration with PX4's EKF. - Visual-Inertial Odometry: Integrate VINS-Fusion by publishing its pose estimates to
mavros/vision_pose/posefor use in PX4 navigation.