Home → Tutorial Home → Viewing Real-Time Data |
---|
Trick View (TV) is an application for viewing/setting simulation variables in real-time. TV can be launched from the input file, or may be launched directly from the sim control panel. You can also leave TV running between simulation runs. In this case You will need to click the "Connect" button in the lower right corner of the TV GUI to re-connect to the simulation.
Fire up the simulation:
% cd $HOME/trick_sims/SIM_cannon_analytic
% ./S_main*exe RUN_test/input.py &
Start TV by either clicking the blue TV icon button or choosing the sim control panel menu option: Actions->Start TrickView. The TV GUI should pop up.
In the Variable Hierarchy Tree pane, on the left side of the
GUI, double-click dyn
, and then double-click cannon
.
Choose some variables to view. Double-click on pos[2]
, and
vel[2]
. These variables will be added to the Variable Table pane on the
right.
Since we have gone to the trouble, go ahead and save these selections.
SIM_cannon_analytic
directory, and name the file "TV_cannon".On the sim control panel, choose Actions->FreezeAt. Enter in a time of 2.0 seconds. Click OK.
On the sim control panel, click the Start button to put the simulation into action. Notice that TV parameter values have changed. When the simulation time reaches 2.0 seconds, the cannon ball position will be [86.17, 30.33].
In the Trick View variable table, select dyn.cannon.pos[0]
and
dyn.cannon.pos[1]
. You can use SHIFT-click to select both. With these
variables high-lighted, select Actions->Strip Chart on the menu bar. The
Strip Chart GUI should then appear, and represent each of the two variables as a
squiggly line, and unique color of its own. Also verify that the two values of
dyn.cannon.pos as represented in TV, and Stripchart agree.
Now force the Y position of the cannonball to drop to 10 meters. To do this, click on the dyn.cannon.pos[1] variable on the TV Parameter table. Replace 30.325... with 10.0 as a new position. Hit Enter to set the variable with the new value. The stripchart should show the drop from 30 meters to 10 meters.
Notice that dyn.cannon.vel[0] is 43.30... meters per second. To view it in feet per second:
Resume the simulation run by clicking the Start button on the sim control panel. Notice that the trajectory assumes its predetermined path. This is because we are analytically calculating the cannonball position as a function of time, rather than calculating it from the previous frame data.
If this simulation were run over and over, it would be laborious to clickety-click the variables each time. It would be advantageous to use the TV_cannon file we saved off in the last step. There are two ways to do this.
% cd $HOME/trick_sims/SIM_cannon_analytic
% ./S_main*exe RUN_test/input.py &
Choose "Actions->Start Trick View" from sim control panel.
Click the file Open or Open with a blue circle icon button on the TV toolbar or select File->Open or File->Open & Set from the main menu.
Select the TV_cannon file saved off in the last run. The Parameter table on the right is cleared and replaced with all the saved variables.
If "Set" is chosen for opening a TV file, all saved values are restored as well. Otherwise, only variables are loaded to the Parameter table. If only "Set" is selected, corresponding vaiable values are restored without the Parameter table being changed. This simulation is simple since we have a limited number of parameters. The streamlining is more pronounced when the simulation has thousands of variables, in which the process for selecting variables would become awfully repetitious.
It even gets tiresome clicking the TV input file from TV. The following example shows how to configure the simulation to automatically launch the TV with the parameters of interest. The syntax for this file is similar to the stripchart input file. Again, we need to incorporate the TV input file into our ever expanding simulation input file.
exec(open("Modified_data/realtime.py").read())
exec(open("Modified_data/cannon.dr").read())
trick.trick_view_add_auto_load_file("TV_cannon.tv")
trick.stop(5.2)
Listing 9a - Simulation TV Input File - input.py
% cd $HOME/trick_sims/SIM_cannon_analytic/RUN_test
% vi input.py <edit and save>
You may now run the sim and verify that TV pops up automatically.