File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99comms = pymoos .comms ()
1010
1111def c ():
12- print ("\t |-Time Warp @ {0:.1f} \n " .format (pymoos .get_moos_timewarp ()))
13- print ("\t |-Time Warp delay @ {0:.1f} ms \n " .format ( \
14- comms .get_comms_control_timewarp_scale_factor ()* pymoos .get_moos_timewarp ()))
1512 return comms .register ('simple_var' ,0 )
1613
1714def m ():
@@ -20,19 +17,13 @@ def m():
2017
2118def main ():
2219
23- comms .set_on_connect_callback (c )
24- comms .set_on_mail_callback (m )
25- pymoos .set_moos_timewarp (20 )
26- comms .set_comms_control_timewarp_scale_factor (0.4 )
20+ comms .set_on_connect_callback (c );
21+ comms .set_on_mail_callback (m );
2722 comms .run ('localhost' ,9000 ,'pymoos' )
2823
29- last_time = time .time ()
30-
3124 while True :
32- time .sleep (1.0 )
33- # if time.time() - last_time > 1.0:
34- comms .notify ('simple_var' ,'a string' ,pymoos .time ())
35- # last_time = time.time()
25+ time .sleep (1 )
26+ comms .notify ('simple_var' ,'a string' ,pymoos .time ());
3627
3728if __name__ == "__main__" :
3829 main ()
Original file line number Diff line number Diff line change 1+ import pymoos
2+ import time
3+
4+ #another simple example - here we install a callback which
5+ #fires every time mail arrives. We need to call fetch to
6+ #retrieve it though. We send mail in simple forever loop
7+ #We also subscribe to the same message..
8+
9+ #This version demonstrates setting and using a timewarp that allows speeding up
10+ #simulations with MOOS
11+
12+ comms = pymoos .comms ()
13+
14+ def c ():
15+ print ("\t |-Time Warp @ {0:.1f} \n " .format (pymoos .get_moos_timewarp ()))
16+ print ("\t |-Time Warp delay @ {0:.1f} ms \n " .format ( \
17+ comms .get_comms_control_timewarp_scale_factor ()* pymoos .get_moos_timewarp ()))
18+ return comms .register ('simple_var' ,0 )
19+
20+ def m ():
21+ map (lambda msg : msg .trace (), comms .fetch () )
22+ return True
23+
24+ def main ():
25+
26+ comms .set_on_connect_callback (c )
27+ comms .set_on_mail_callback (m )
28+ pymoos .set_moos_timewarp (10 )
29+ comms .set_comms_control_timewarp_scale_factor (0.4 )
30+ comms .run ('localhost' ,9000 ,'pymoos' )
31+
32+ while True :
33+ time .sleep (1.0 )
34+ comms .notify ('simple_var' ,'a string' ,pymoos .time ())
35+
36+ if __name__ == "__main__" :
37+ main ()
You can’t perform that action at this time.
0 commit comments