From what I understand, you want guidance on implementing an on-demand computation task in Simulink while ensuring that it runs in the background without interrupting the step-by-step propagation of the Simulink operation.
While one approach being you can use a combination of Stateflow and Simulink blocks. You can have steps as:
- Create a Stateflow chart: Start by creating a Stateflow chart that represents the planner module. This chart will handle the replanning task and run independently in the background. It should have states to handle the different stages of the replanning process.
- Trigger the replanning task: In Simulink, use an event-based trigger to initiate the replanning task. This trigger can be based on a condition that signals the need for replanning.
- Transition to the replanning state: When the trigger condition is met, transition to a replanning state in the Stateflow chart. This state will handle the actual computation of the new path. You can use MATLAB functions or Simulink blocks within this state to perform the replanning calculations.
- Update the path: Once the new path is calculated, update the path variable or data structure in the Stateflow chart to store the new path information.
- Transition back to the tracking state: After the path is updated, transition back to the tracking state in the Stateflow chart. This state will continue to track the vehicle's position using the previous or updated path information.
For your comment, yes, it is possible to establish communication between two Simulink models running on different computers on the same local network. One common approach is to use the Simulink Real-Time product, which allows you to connect Simulink models running on different computers using TCP/IP or UDP/IP communication protocols.
Attached below are some documentation links that you may find helpful:
Hope this helps!
Karan Singh Khati