What's the best way to control the time and input data of a model from another model or Matlab?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nico Spo
el 6 de Oct. de 2017
Comentada: Nico Spo
el 6 de Oct. de 2017
I want to run a simulation that is practically controlled from another PC (e.g. ROS node).
The other PC would irregularly send new input data for the simulation, which should be stored somewhere (this would be for example an array of setpoint value for specific times, e.g.
t | y_setpoint(t)
-------------------
0.1 | 5
0.2 | 6
0.3 | 6
Furthermore, the other PC should control when the simulation runs - it should be able to give the command
REMOTE: Run the simulation for one time step (until t=0.1)
and receive some output values:
SIM_PC: y_actual(0.1) = 3.78
The main simulation should then pause until another command
REMOTE: Run the simulation for one time step (until t=0.2)
comes in. SIM_PC responds as before:
SIM_PC: y_actual(0.2) = 4.35
When the simulation is paused, the simulation PC still needs to listen to new input from the remote PC of course, e.g.:
t | y_setpoint(t)
-------------------
0.3 | 5
0.4 | 5.5
What would be the most elegant/easy way to implement something like this?
0 comentarios
Respuesta aceptada
Cam Salzberger
el 6 de Oct. de 2017
Hello Nico,
The easiest and most elegant way would be to use the Robotics System Toolbox subscribe and publish functionality. The subscriber could have a callback that starts the model (assuming a Simulink model here). Once the model is done running, it can then publish the output as another ROS message to be received by the other computer. If you really need to pause and resume the model at particular timesteps, there are some ideas here.
If you are looking to modify the model while its running from the other computer, you could add a Subscribe block to the model to update values.
Hope that helps to get you started!
-Cam
Más respuestas (0)
Ver también
Categorías
Más información sobre Code Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!