hi, am a working in hardware in the loop simulation (HILS) for ardupilot mega.

the purpose of my research is to ensure that ardupilot control system works well,before I do the actual flight test.
the difference between what I do with pre-existing HILS is a model airplane that I use is a model of state space and not a model of an aircraft that already exists on xplane.

The following is an overview of its design scheme:

I have managed to describe the control block diagram for stabilization control mode from ardupilotmega.pde coding ,and compare the results between simulation control dan ardupilot hardware control. the following picture is the block diagram for stabilization control mode in matlab/simulink :

inside logitudinal block

inside lateral directional block

now, the problem is:

I have difficulty in describing the existing control algorithms ardupilotmega.pde coding  to the form of control block diagram  for auto control mode, because I do not understand the coding of the overall ardupilotmega.pde

so far, for the auto control mode, this is what I have gained:


-i a am still find a solution for make a gps simulation. now my idea is using yaw angle,speed,and inital position to estimate next position (some one help me)

-I am still trying to understand how the working process of waypoint tracking in ardupilotmega.pde coding , so that I can describe the block diagram in matlab / simulink. (some one help me)

new update (1 juni 2012)

this is my video off waypoint tracking simulation 








Views: 12753

Reply to This

Replies to This Discussion

Access denied again. Can you send it to sumitpokhrel2003@gmail.com ? Please 

A question, how could we run APM planner and simulink at the same time ? Also how could we hook up Simulink Block with APM Planner software ? 

I have few questions. I would really be thankful if you could answer them: 

1. What port number did you assign in PORT: By default it is 9090 ? But so far i remember my Ports are COM1,COM2,...,COM5.

2. In data type : there are  single,double,int8,...etc. Data from the C code is of type float. There is no float option. Which one should i select. 

3. Is the Byte order BigEndian or LittleEndian ? 

4. What is the appropriate sample time ? 

5. Your simulink Block shows UDP data- Yaw1,Roll1 etc. Are those yaw,pitch and role or yaw,pitch and roll rate - p,q and r ? 

Still says Access Denied ! 

Hi Sufendi:

I looked at your HIL video on youtube and would like to ask you: how to define those UDP data, as captured below from your video screen shoot.



Same question for the UDP data receiving from APM (pilot commands).  Question is how to configure the UDP block in Simulink in order to unpack the UDP data from APM? Thanks !

Don't use UDP. It has significant real time delay. But same questions indeed. 5 of those questions. 

anybody managed to figure out how to use the UDP block in MATLAB?

Dear sufendi


first let me to say thank you for the sharing your knowledge so others can use. and second let me apologize for the poor english I am writing in

I am a beginer with electronic and APM. how ever i want to connect it the matlab in order to send my control commands and so on

first of all i dont know how to do it ( connection for send and recive order). so I want you to help me in this field if is possible.

having a model that i can run in my computer would so helpful for me.

thank you so much


dear sufendi

access is denied to this website

may you pleas send it to my emai


thanks alot

Hi All,

This post on hardware in loop simulation with APM using Matlab seems exciting. I am also working on a similar problem. I am trying to do a Hardware in loop simulation with APM 2.6 connected to a mission planner. Instead of using flight gear or xplane, I am using Matlab to read in actuator commands from the mission planner through UDP and do simulation in Matlab and send back the sensor data to the mission planner.

I have read in actuator commands send by the mission planner through UDP and I am currently working on sending the simulated data back to the mission planner. It would be of great help to me if someone could share the details of how this has been done. I am also unable to download the simulation file. Help in this regard would be greatly appreciated.


Hello. I study HILS . I have a lot of questions.

 1. How to communicate between the APM Planer(mission planer) and Simulink(matlab)?

 2. How to communicate between the Simulink and X-plane?

I really wonder this problem, help you.

Reply to Discussion


© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service