实例介绍
mavlink的入门资料;适合纯粹的mavlink小白,配合笔者的博文介绍,助你理解深入理解mavlink协议。 尊重原著未删减,原名叫“MavLink Tutorial for Absolute Dummies (Part –I)” 支持开源,不要资源分。
So, you have one telemetry and one copter with aPm, thats it, go and fly happy -don' t think of more! These will be helpful for swarm copters in future. different pairs of system ids-That's the future e 2) The payload data is extracted from the message and put into a packet a packet is a data structure based on a type of information. We no longer will use the term message. that is over and done with We are interested in packet, which is basically the packed raw data 3)The packet is put into an 'appropriate data structure. There are plenty of data structures e. g for Attitude(pitch, roll, yaw orientation), GPS, RC channels, etc. that groups similar things together to be it modular, understandable. these data structures are perfectly 100% alike'at the sending and receiving ends i. e at mP and APM side) If not, your copter would have come crashing at odd times! Also, this is where the MavLink GUI generator comes to the rescue. To generate these data structures, we do not need to code a single line! Well, not quite but only a little i hope it is easy so far, if not re- read it again It is oK, to be a dummy o Ok now for the real thingy we send bi-directional messages with mavLink i From Ground station control (Gcs)to aPM/PX4 oR from APM/ PX4 to ground station control (GCS). Note, when I mean GCS I mean it as mission Planner( MP) or QGroundControllQGC) DroidPlanner (DP)or your own custom tool you are working with to communicate with the copter. GROUND STATION CONTROL(GCS)TO QUADCOPTER: So far, we know that each message( we called a packet, which has the useful information for us), has a message Id and payload put into a data structure of 'appropriate type. We switch on the main message(or mavlink MsG id) type and once that message is detected we do magic like storing the information received to permanent memory (called EEPROM), or whatever we wish to do with it As of Nov'2013, in the latest 3.0.1 RC5 (release candidate)of Arducopter these are the parameters you would find. I have tried to list the main message iD for all possible MavLink message Note that within each main message category (like the ones in bold below), you would find ' sub messages which belong to that category which basically are closely related to the payload information (the real meat)and how it deals with it. Just like the 'Bike category has Yamaha, Suzuki, harley Davidson, etc. I am listing all main message categories but only specify some of the sub category. You can look up the details yourself e because if you understand what i meant so far, you are no more a DUMMY. Get my point? MAVLINK_MSG_ID (Block of main messages 1)MAVLINK MSG ID HEARTBEAT://0 a. This is the most important message. The gcs keeps sending a message to APM/PX4 to find out whether it is connected to it every 1 second this is to make sure the mp is in sync with APM when you update some parameters. If a number of heartbeats are missed, a failsafe (can be) is triggered and copter lands continues the mission or Returns to launch(also called, RTL). The failsafe option can be enabled/ disabled in MP under ConfigureSetup Failsafe options. But you can't stop heartbeats, can you? The name is very justified !! 2)MAVLINK MSG ID REQUEST DATA STREAM: //66 a. Sensors, RC channels, GPS position, status, Extra 1/2/3 3)MAVLINK_MSG_ID_ COMMAND_LONG://76 a. Loiter unlimited, RTL, Land, Mission start, Arm/Disarm, reboot 4)SET MODE://11 a. E. g set mode(packet. custom mode); 5)MAVLINK MSG ID MISSION REQUEST_ LIST: //43 a. Total waypoints: command total variable of parameters This stores the total number of waypoints that are present (except home location, for multi-copters 6)MAVLINK MSG ID MISSION REQUEST: //40 a. Set of MAv CMd value enum members, such as: MAV CMD CHANGE ALT, SET HOME, CONDITION YAW. TAKE OFF NAV LOITER TIME 7MAVLINK MSG ID MISSION ACK: //47 a. // turn off waypoint send 8)MAVLINK MSG ID PARAM REQUEST LIST: //21 a. count_parameters Count the total parameters) 9)MAVLINK MSG ID PARAM REQUEST READ: //20 a. Receive and decode parameters make sense of param name and ld) 10)MAVLINK_MSG ID_ MISSION_ CLEAR_ALL://45 a. When you use mission planner flight data screen and say, clear mission with the mouse menu, this is where it goes. It clears the EEPrOm memory from the apm/PX4 11)MAVLINK MSG ID MISSION SET CURRENT: //41 a. This is used to change active command during mid mission. E.g. when you click on MP google map screen and click Fly To Here, as an example 12)MAVLINK_ MSG_ ID_MISSION COUNT: //44 Save the total number of waypoints(excluding home location)-> for Multicopters 13) MAVLINK MSG ID MISSION WRITE PARTIAL LIST: / a. Just keeping a global variable stating that aPm is receiving commands now. this is to avoid other mavLink actions while important parameters are being set. 14)MAVLINK MSG ID SET MAG OFFSETS: //151 a. Set the mag_ofs x, mag_ofs_y, mag_ ofs z, say after compass calibration to EEprom of APM/PX4 Mission Planner(MP) automatically does this or you can do this too by going to full parameters list under SoftWare configuration 15) MAVLINK_MSG_ID_ MISSION ITEM: //39 This is an interesting part. This message contains sub messages for taking real-time action. Like setting waypoints and advanced features. This is how it works, as below a. Receive a Waypoint(Wp)from GCS and store in EEPROM of APM/PX4 b. Sends 4 params(e.g. Delay HitRad, - and Yaw Angle) for LoITER TIME (as ID)+(Lat, Long, Alt: Defines the 3D position of object in space). these parameters are defined as an Enum in code Options (1= Store Altitude(alt)relative to home altitude Each Command (or ID) may have different parameters of interest. Mission Planner shows blank header for column because there is no parameter defined for this Id As a summary, the interesting parameters sent with every action are 4 params id of action)+(Lat, Long alt defines 3D position of copter note the 4 params can be some sort of custom action as for camera setting, camera trigger loiter time, etc C. As in figure below from Mission Planner, each id defines a waypoint (AFAIK) LOITER TIME, LOITER UNLIMITED, WAYPOINT all are waypoints that send along with other parameters(latitude, LoNGiTUdE and ALtitude)because each is saved as a waypoint in APM/PX4 Period d. Keep in mind: ALTITUDE is al ways relative to home altitude(always! )with the current design e. You can define these actions in Common. xml and use python gui generator to generate the code that aPm/pX4 will use. Let me cover this later or ask me in forum on how to. You can add your own interesting parameters for the 4 params, I mentioned 2013TA,1mEy923T Waypoints WP Radius Loiter Radius Default At 6 ■ verify Height Add below Delay I lit Rad Down 1LOITER_TIME 10 2 WAYPOINT 288 f. When APM receives thismain'commandMAVLINK MSG ID MISSioN ITEM), it reads the id from the MavLink packet and performs switch (case on the ID E. g Loiter turns, Set home Loiter time, repeat servo set servo, etc 16)MAVLINK MSG ID_ PARAM SET: //23 a. Set the parameter. Remember, we can set a value to a parameter in the mission Planner (say, Full Parameter List); this is where it goes when we do this. aPm sends the data value set for confirmation have you seen mp, saying value set failed? Also, APM/PX4 logs simultaneously this value for our analyses offline 17)MAVLINK MSG ID RC CHANNELS OVERRIDE: //70 a. Override RC channel values for HIL(Hardware-In-Loop-Simulationor complete GCS control of the switch position via Gul (I have not tried this though) 18 )MAVLINK MSG ID HIL STATE://90 a. Used for HIL simulation It is a virtual reality with your copter/ plane 19)MAVLINK_MSG_ID_ DIGICAM_CONFIGURE: / 20) MAVLINK MSG ID MOUNT CONFIGURE: / 21)MAVLINK_MSG_ID_MOUNT_CONTROL: / 22 )MAVLINK_ MSG_ ID MOUNT STATUS: / a. So far, as the name suggests configures the appropriate command settings as set by the user 23)MAVLINK_MSG ID RADIO, MAVLINK MSG ID_ RADIO STATUS:// a. Studies the packet rate of the telemetry USB and auto adjusts the delay between sending receiving packets if the signal strength is lower than expected or errors are getting higher It is like an adaptive software flow control. Look at mavlink radio t in C++(APM code) OR mavlink_radio_t (C#, Mission Planner) code. Both are defined as structs QUADCOPTER TO GROUND STATION CONTROL GCS TO QUADCOPTER: Ok, I admit. This gets more interesting. But this is far easier. the fact is that gcs is only mediator between you and your copter it gets the data from copter in return displays on the gcs If you go to Arducopter. pde file, look at this part of the code static const AP Scheduler: Task scheduler tasks[ ProGMeM=t i gcs send heartbeat, 100 156}, f update notify, 18 i one hz loop 188, 428}, i gcs check input, 558}, t gcs send heartbeat, 100, 158}, gcs send defe erre 720} i gcs data stream send, 2 958}, Don't be scared. This is easier than even breathing. This is where real-time systems concept plays a role. We want certain tasks to take certain time, and if they are not finished by then, then We dont proceed with them The first parameter is the function name, The second is the ' time it is supposed to take'(in 10ms units, i.e., 2 means, 20ms, i.e 50HZ, i.e. this function runs 50 times a second) The third parameter is the 'max time beyond Which the function should not run think this is quite straightforward! Each function that you see there, its future is destined, it runs exactly for that much time. This is why it is safe to use Real-time systems for these nasty machines, make it predictable not unpredictable!! All these functions have been handpicked for you to know that these are related to Gcs updates. Simply, go to each of the function definition and these will invariably take you to GCs_Mavlink pde where the real action of Gcs communication occurs!! The most interesting (and important) is this - send data streams in the given rate range on both links static void gcs data stream send (void) gcso data stream send(; if (gcsinitialised)i gcs data stream send o; What this does is to send data down a link (gcse is via USB and gcs is via telemetry) If you go down further /deeper, you would know that we send that the data structures back to GCs for display E.g. what happens when you move your copter with your hands and see Mission Planner>s hUD screen? You see copter moving on the screen. We are getting the Attitude data (Pitch, Roll and Yaw) every time unit. Likewise, we have Imu data, GPs data, battery data, etc So, if you have any questions shoot me a message on forums and i will try to answer it with my knowledge. With the possibilities of these kinds of protocols, it makes anew beginning with no ending. Keeps growing with a new idea!! Shyam balasubramanian Embedded UAV Researcher and Developer), Netherland Shames85@图31∈eB 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论