Hauptinhalt

Create Your First Model for Connected I/O with Host Target

Connected I/O allows you to interact with your flight control algorithm in Simulink® and communicate with ArduPilot® firmware running on your host computer, without deploying the algorithm. This method is fast for early-stage development and debugging, as changes in your Simulink model are reflected instantly during simulation. Using the UAV Toolbox Support Package for ArduPilot Autopilots, you can build and test models using Connected I/O before moving on to deployment or SITL simulation. For more information on Connected I/O, see Communicate with Hardware Using Connected I/O

Create a Simulink Model

  1. Start MATLAB®. From the MATLAB toolstrip, click the Simulink button.

  2. Click the Blank Model template.

    The Simulink Editor opens.

  3. Add a required block using the quick insert menu. For example, Timestamp block.

    Double-click anywhere in the model canvas. In the quick insert menu that appears, enter Timestamp. A list of blocks appears. Verify that the Timestamp block from the UAV Toolbox Support Package for ArduPilot Autopilots library is selected. Check the library name listed under the block name and the block description in the pane to the right of the search results.

    Add block

    Add the Timestamp block to the model by pressing Enter.

    Add block

  4. Add a Dipslay blocks and connect the blocks by creating lines between output ports and input ports. Then, save your model.

Configure Model Parameters for SITL

Set up your model’s configuration parameters to target the ArduPilot SITL environment, specifying your vehicle type and ensuring all settings match the recommended configuration.

  1. In the Simulink model, go to the Modeling > Model Settings to open Configuration Parameters dialog box.

    Model settings

  2. In the Configuration Parameters dialog box, set the required parameters.

    Ardupilot host target configuration

    1. Click Hardware Implementation and select ArduPilot Host Target from the Hardware board list.

    2. In the Build options, Ensure that Build, load and run is selected for the Build action and sitl is selected for the Board.

    3. Set the options for Vehicle.

      Vehicle

      1. Select the required ArduPilot vehicle type.

      2. For Simulator, ensure you select SITL in Host Target.

      3. Select the desired Airframe from the drop-down list.

      4. Select the options for Launch MAVProxy Console and Launch MAVProxy Map. This will automatically launch the corresponding SITL windows when you start the simulation.

        • MAVProxy Console: This window allows you to interact with and monitor the SITL simulation using command-line commands.

        • MAVProxy Map: This window displays a real-time map view of the simulated vehicle.

  3. Click Apply and OK.

Simulate Your Simulink Model in Connected I/O

Run your Simulink model in Connected I/O mode to test and interact with your hardware in real time without full code deployment. This allows you to validate model behavior and exchange data with the hardware during simulation.

  1. Set a value for the Simulation stop time parameter. The default value is 10.0 seconds. To run the model for an indefinite period, enter inf.

    Stop time

  2. On the Hardware tab, in the in the Mode section, click Connected IO. If you see Run on board selected instead of Connected IO, click on it and choose Connected IO (inputs/outputs mode).

    Enable connected I/O

  3. Run the Model

    • Click Run with IO.

    • Simulink communicates with the hardware, exchanging data in real time.

    • Use Scope or Display blocks to observe live data.

  4. Wait for the Host Target to launch.

    • The SITL simulation environment (Host Target) will start automatically.

    • Wait for the ArduPilot SITL, MAVProxy Console, and MAVProxy Map windows to launch completely before proceeding.

      ArduPilot SITL, MAVProxy Console, and MAVProxy Map windows

  5. Additionally, you can change the rate of simulation by enabling the simulation pacing. For more information, see Simulation Pacing Options (Simulink).

    Simulation pacing

See Also

|