Performing HIL Simulation with Custom Firmware

Hi,

I am interested in doing hardware-in-the-loop simulation with my ArduPilot Mega 2.5.  We are developing a new controller architecture and I have implemented it in some firmware changes I've made.

When I look for information about HIL simulation, I mostly see people download a version of the firmware meant to do the simulation.  My question is, is creating an HIL version as simple as changing these parameters:

#define HIL_MODE                          HIL_MODE_DISABLED    (to HIL_MODE_SENSORS)
#define HIL_PORT 0 (to 3 for USB, or still 0?)
#define HIL_PROTOCOL HIL_PROTOCOL_MAVLINK


Could I just modify my custom firmware to include these changes, and load it as a hex the way I've been loading any custom firmware?

Also, do I have to use FlightGear (not Xplane) if I want the plane to know the raw sensor values? Or is that just a protocol issue?

Cheers!
Jon
University of Kentucky

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • hello, i want to ask to you, now i activate hil mode from source code and build that, but in parameter is still 0 for hil mode

    Menno Hochstenbach said:

    For ArduPlane is assume? ->

    Uncomment or add these lines to APM_Config.h file:

    #define HIL_MODE              HIL_MODE_SENSORS
    #define HIL_PROTOCOL      HIL_PROTOCOL_MAVLINK
    #define HIL_PORT                0

    Then just upload this custom code with ArduPilot Arduino IDE to your ArduPilot and it should work..

    Performing HIL Simulation with Custom Firmware
    Hi, I am interested in doing hardware-in-the-loop simulation with my ArduPilot Mega 2.5.  We are developing a new controller architecture and I have…
  • Hi Jon,

           Did you get solution for this? I am looking for a solution to similar problem. I need to use my modified code to work with HIL. Please help if you have a solution.

    • Sorry to drop the thread.

      I did manage to get HIL simulation working with my customized version of the 2.74b firmware and Flightgear.  In my APM_Config.h file I put

      #define HIL_MODE HIL_MODE_SENSORS
      #define HIL_PORT 0
      #define GPS_PROTOCOL GPS_PROTOCOL_HIL

      It worked very well with the exception of the airspeed.  Although the airspeed appeared in Mission Planner, the hardware did not appear to be receiving it. I managed to simulate AUTO mode by forcing the plane to use constant throttle (change min and max to same value).

  • Are you using ArduCopter or ArduPlane? For ArduPlane it should work, check: https://www.youtube.com/watch?v=tKr2C_Lrq_4.

    Menno

    • Hi Menno,

                 This video describes HIL with built in code. I am looking for solution with my modified code. Please help if you have solution.

      • For ArduPlane is assume? ->

        Uncomment or add these lines to APM_Config.h file:

        #define HIL_MODE              HIL_MODE_SENSORS
        #define HIL_PROTOCOL      HIL_PROTOCOL_MAVLINK
        #define HIL_PORT                0

        Then just upload this custom code with ArduPilot Arduino IDE to your ArduPilot and it should work..

  • Hi,

    Have you already found a solution to do HIL with custom firmware because I want to do it to :)

    Menno

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…