这是一个简单的无人机轨迹追踪demo,也是一份offboard实飞控制踩坑经验总结
Traj_tracking is used for MAVs to track a pre-defined trajectory. Trajectory tracking is the basis for some complex functions
- For MAVs developed using px4 as an autopilot.
- MAV flight control development using motion capture systems such as Vicon or Optitrack for positional feedback.
- Running requires trajectory message publication outside of this package, of type
trajectory_msgs::MultiDOFJointTrajectory
.
Tested on : Ubuntu 16.04 + ROS Kinetic.
cd Traj_tracking_ws/src
git clone https://github.com/bowenXuu/Traj_tracking.git
cd ..
catkin_make
source devel/setup.zsh
Before performing the following steps, make sure that:
- The motion capture is operating normally and the MAV is continuously receiving information about its own position.
- Pixhawk and on-board computer are properly connected
# Start the mavros node, connect the pixhawk to the nuc, and start receiving motion capture poses.
sh ./src/Traj_tracking/scripts/px4_mocap.sh
# Visualize poses reception and real-time setpoint
roslaunch Traj_tracking rviz.launch
- Channel 5:Control Mode
- Low:Entering STABLIZED
- Medium:Start streaming setpoints
- Channel 6:Off-board mode
- Low:MAV on lock
- Medium:
- OFFBOARD mode: Terminate all tasks and land in the same place
- Other modes: No operation
- High:Unlock and switch to OFFBOARD
- Channel 7:Emergency Mode
- Low:No operation
- High:Emergency stop
Function 1 (Used to test whether the position control of MAV is normal)
Take off from any location and send a setpoint to control the movement of the MAV in real time by remote control after taking off
rosrun Traj_tracking rc_ctl
Real flight control process:
- Make sure all channels 567 are switch to low, throttle adjusted to the lowest, start
rc_ctl
node - Channel 5 switch to in the send takeoff setpoint, at this time rviz should be visible on the setpoint in the MAV directly above the 0.8 m height, at this time the throttle adjustment to the middle position
- Channel 6 switch to high to unlock the MAV, wait for the MAV to take off, after successful takeoff will hover, before the subsequent operation
- You can change the xyz position of the MAV setpoint by controlling 123 channels
- When the mission is over, Channel 6 switch to land.
- After landing smoothly, execute Channel 7 switch to high, Channel 6 switch to low, Channel 5 switch to low, Channel 7 switch to low in turn to achieve reset.
Function 2
Take off from any location and control the MAV movement according to the pre-recorded trajectory information after take-off
rosrun Traj_tracking traj_ctl
Real flight control process:
- Make sure all channels 567 are switch to low, throttle to the minimum, start
traj_ctl
node - Channel 5 switch to send the takeoff setpoint, at this time the setpoint should be visible on the rviz at 0.8m height directly above the MAV
- Channel 6 switch to high to unlock the MAV, wait for the MAV to take off, after successful takeoff, it will automatically fly to the first point of the preset trajectory
- After reaching the starting point of the trajectory, the terminal will send
ROS INFO: You can now send the trajectory message!
- After seeing the prompt from the terminal, play the rosbag with the trajectory message, and the MAV will follow the pre-planned route and time stamp for trajectory tracking
- When the mission is over (the MAV flies back to the takeoff point in a circle along the trajectory), channel 6 will switch to land.
- After the landing is confirmed to be smooth, execute channel 7 switch to high, channel 6 switch to low, channel 5 switch to low and channel 7 switch to low in turn to achieve reset.
Find more things to keep in mind when flying here : flight instructions.