常见指令
编译Arduplane程序
cd ardupilot/
./waf plane
进入 Tools/autotest 文件夹中,启动3D flightgear
./fg_quad_view.sh
进入ArduPLane文件夹中,启动仿真
sim_vehicle.py --map --console -L KSFO
(-L 选择起飞位置)
解锁arm throttle
起飞takeoff 50
下载航点
wp load ../Tools/autotest/Generic_Missions/CMAC-circuit.txt
wp list
多机仿真
sim_vehicle.py --map --console -I 0 has FDM in/out ports of 9002/9003 / GCS connection UDP:14550 --sysid=1
sim_vehicle.py --map --console -I 1 has FDM in/out ports of 9012/9013 / GCS connection UDP:14560 --sysid=2
sim_vehicle.py --map --console -I 2 has FDM in/out ports of 9022/9023 / GCS connection UDP:14570 --sysid=3
sim_vehicle.py --map --console -I 3 has FDM in/out ports of 9024/9025 / GCS connection UDP:14580 --sysid=4
或者
(注意无人机设定序号从0开始,实际序号从1开始)
sim_vehicle.py -v ArduPlane -n 3 --auto-sysid --mcast --console --map
sim_vehicle.py -v ArduPlane -n 4 --auto-sysid -i "0 1 2 3" --mcast --console --map
分别对无人机进行设置
更多参数设置可以参考Tools/autotest/sim_vehicle.py代码,或者启动仿真后,输入help
查看命令帮助
所有命令如下:
accelcal : do 3D accelerometer calibration
accelcalsimple : do simple accelerometer calibration
adsb : adsb control
ahrstrim : do AHRS trim
alias : command aliases
alllinks : send command on all links
alt : show altitude information
arm : arm motors #解锁油门
attitude : attitude
auxopt : select option for aux switches on CH7 and CH8 (ArduCopter only)
bat : show battery information
batreset : reset battery remaining
calpress : calibrate pressure sensors
camctrlmsg : camctrlmsg
cammsg : cammsg
cammsg_old : cammsg_old
canforward : enable CAN forwarding
capabilities : fetch autopilot capabilities
changealt : change target altitude
changealt_abs : change target absolute altitude
click : set click location
command_int : execute mavlink command_int
compassmot : do compass/motor interference calibration
console : console module
corrupt_params : corrupt param storage
devid : show device names from parameter IDs
dfu_boot : boot into DFU mode
disarm : disarm motors
engine : engine
fence : geo-fence management
flashbootloader : flash bootloader (dangerous)
forcecal : force calibration save
formatsdcard : format SD card
ftp : file transfer
gethome : get HOME_POSITION
ground : do a ground start
guided : fly to a clicked location on map
gyrocal : do gyro calibration
hardfault_autopilot : hardfault autopilot
internalerror_autopilot : cause internal error in autopilot
land : auto land
layout : window layout management
led : control board LED
level : set level on a multicopter
link : link control
lockup_autopilot : lockup autopilot
log : log file handling
long : execute mavlink long command
longloop_autopilot : cause long loop in autopilot
magcal : magcal
magresetofs : reset offsets for all compasses
magsetfield : set expected mag field by field
map : map control
mode : mode change
module : module commands
motortest : motortest commands
namedvaluefloat : send a NAMED_VALUE_FLOAT
oreoled : control OreoLEDs
output : output control
panic_autopilot : panic autopilot
parachute : parachute
param : parameter handling
pause : pause AUTO/GUIDED modes
playtune : play tune remotely
position : position
posvel : posvel
rally : rally point control
rc : RC input control
rcbind : bind RC receiver
reboot : reboot autopilot
relay : relay commands
repeat : repeat a command at regular intervals
reset : reopen the connection to the MAVLink master
resume : resume AUTO/GUIDED modes
script : run a script of MAVProxy commands
scripting : control onboard scripting
servo : servo commands
set : mavproxy settings
setorigin : set global origin
setspeed : do_change_speed
setup : go into setup mode
setyaw : condition_yaw
shell : run shell command
signing : signing control
status : show status
switch : flight mode switch control
takeoff : takeoff
terrain : terrain control
time : show autopilot time
tuneopt : Select option for Tune Pot on Channel 6 (quadcopter only)
up : adjust pitch trim by up to 5 degrees
vehicle : vehicle control
velocity : velocity
version : fetch autopilot version
watch : watch a MAVLink pattern
wipe_parameters : wipe autopilot parameters
wp : waypoint management
vehicle 1
增加自定义模式
增加replan模式,并在执行完auto模式后自动切换到此模式
-
mode.h
增加模式编号
定义类,内容先仿照guided模式,后续进行修改
-
Plane.h中添加
ModeReplan replan;
-
Control_modes.cpp中添加
-
events.cpp
-
GCS_Mavlink.cpp
[外链图片转存失败,源站可能有防盗在这里插入!链机制,建描述]议将图片上https://传(imblog.csdnimg.cn-4f8uV32c43faa14dd9af0faa6ba9ab.png132)(https://imug-blog.csdnimg.cn/cd4f8343faa14dd9af0faa6efba1a94b.png)] -
GCS_Plane.cpp
发送总航点数和已完成航点数到Mavproxy
参考代码
const float wp_dist = current_loc.get_distance(flex_next_WP_loc);
if (wp_dist <= acceptance_distance_m) {
gcs().send_text(MAV_SEVERITY_INFO, "Reached waypoint #%i dist %um",
(unsigned)mission.get_current_nav_cmd().index,
(unsigned)current_loc.get_distance(flex_next_WP_loc));
return true;
}