コード例 #1
0
 public byte[] takeoff(float altitude)
 {
     MAVLink.mavlink_command_long_t req = new MAVLink.mavlink_command_long_t();//定义req为 MAVLink.mavlink_command_long_t类,填充常命令的数据包
     req.target_system    = 1;
     req.target_component = 1;
     req.command          = (ushort)MAVLink.MAV_CMD.TAKEOFF; //‘COMPONENT_ARM_DISARM’代表你要发送什么类的信息(此处为解锁信息),可自己选择(看类里有多少种)
                                                             //req.command = (ushort)MAVLink.MAV_CMD
                                                             //req.param1 = armed ? 0 : 1;//此处发送解锁信息,只需用param1。其余param2—7注释掉
     req.param1 = 0;
     req.param2 = 0;
     req.param3 = 0;
     req.param4 = 0;
     req.param5 = 0;
     req.param6 = 0;
     req.param7 = altitude;
     byte[] packet = mavlink.GenerateMAVLinkPacket_APM(MAVLink.MAVLINK_MSG_ID.COMMAND_LONG, req);//把req数据包,按照mavlink协议打包成(定义了临时变量packet)
     return(packet);
 }