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
Hi, the link It is not working. Feel free to mail me the information to firstname.lastname@example.org I will help you!
There is a very good reference you must read http://www.amazon.com/Small-Unmanned-Aircraft-Theory-Practice/dp/06...
your question "now my idea is using yaw angle,speed,and inital position to estimate next position" is solved in that book
I am recently building a HIL simulation environment on my APM 2.5 project and saw your post at 2012 while searching for information. I used MATLAB/Simulink to build my own aircraft 6DOF simulation model, instead of using existing models from FG or Xplane, for better accuracy.
However, I couldn't find any information/manual on web to explain how to hook up APM with MATLAB/Simulink. I then saw your post and found it encouraging. I hope you can share your experience with me on how to connect MATLAB/Simulink with APM. Below describes what I intend to setup:
1) APM 2.5 connects with RC controller through radio link.
2) APM 2.5 provides control output (throttle, elevator, aileron, rudder), either in manual, stabilizer, or other modes.
3) MATLAB/Simuilink takes control outputs (from APM 2.5) as model inputs and then run the predefined 6DOF nonlinear model to generate aircraft full state outputs (p,q,r,pitch,roll,yaw, gps, etc.)
4) Model outputs from MATLAB/Simulink are fed back to APM 2.5. APM will perform internal control algorithm to calculate next state of control outputs (if in stabilizer or other auto mode). All state outputs are shown on Mission planner.
5) MATLAB/Simulink model outputs send to FG for visualization. (PS: FG is ONLY used to visualize outputs from MATLAB/Simulink. FG itself does not simulate anything. MATLAB already builds an interface with FG for this purpose).
Nice to hear a question from you. My idea is just use matlab/ simulink as xplane. In normal apm planner we can use apm planner to make a hardware in the loop simulation, right? So, the idea is use that hardware in the loop frame that provide by apm planner and than change xplane to matlab. Changed xplane to matlab mean that ,use data that send from apm planner to xplane ( udp data) , and changed that data from apm planner to send to matlab.
If, you still don't get my idea. I recommand you to read how apm planner send data to xplane or FG first.
Another method that can be use to hook up matlab with apm is use direct communication using mavlink protocol,
Hi Sufendi :
Thanks for your quick response. It is greatly appreciated.
I have done HIL with FG through mission planner before, as you pointed out. I still don't understand how could you change the sim setup in mission planner to send data to MATLAB instead of FG? What step/procedure did you perform exactly to make this works? Can you please elaborate?
Thanks greatly for your help !!
to set up mission plannner to send data to MATLAB is by changed the destination ip address or FG ip address to ip address of your simulink udp receiver block. have you ever use udp send/ receive block in simulink ?
Are you referring to the "UDP Receive" & "UDP Send" blocks under Real-Time UDP within xPC Target library? No. I never used that before but I will try if that is what works to setup the HIL SIM.
One quick question: when you send a particular data from Simulink to APM, how did you assign that data to make it recognizable by APM? For example, when sending airspeed from Simulink to APM, how does the APM know that particular data should be read as airspeed rather than anything else? Same question for data from APM to Simulink.
I just came back to work on my APM project from my busy daily works.
I still don't how to make the APM communicate with my MATLAB/Simulink model, as I am not family with the UDP send/receive block in Simulink. I realized there are several UDP receive block under: "DSP System Toolbox"; "Embedded Coder" ; "Instrument Control Toolbox" ; & "Xpc Target". Which one I should use? Would you please tell me more details about the setup?
I also use 2 PCs for this HIL-SIM setup. PC1 connects to APM and runs both mission planner and MATLAB/Simulink. PC2 runs only Flightgear to visualize aircraft outputs receiving from PC 1 MATLAB/Simulinik models. Connect between PC1 and PC2 was tested and works correctly with below setup:
PC1 IP: 192.168.0.11
PC2 IP: 126.96.36.199
What IP should I use to make PC1 talks to APM haardware?
You help are much appreciate.
I also tried to download your simulation file "simulasi.rar" but access was denied. If you should share this file with me via email, that will be greatly helpful and appreciated.
I think what I really need to knows is the UDP structure for both send and receive packages from APM site. Where did you find those information before? Would you share that with me? Thanks,
The control code used here is PID. A good and simple book to understand is http://www.amazon.com/Feedback-Control-Dynamic-Systems-Edition/dp/0.... It is a linear controller and works fine for Ardupilot UAVs. I have taken couple of classes at my university. So feel free to asks concepts .
Just a question, which Ardupilot you are using , APM 2.5 ?
What is Mavlink protocol ? Where can i look information about it ? I am really struggling for days trying to obtain all the sensor data 6 DOF IMU, Barometer, compass etc. from the ardupilot and then pass them to simulink math model and get the control signal. I am unable to find any good help so far. :(