@@ -11,6 +11,17 @@ import (
1111 "time"
1212)
1313
14+ var (
15+ defaultDishAddress = "192.168.100.1:9200"
16+ grpcTimeout = 5 * time .Second
17+ GRPCAddrPort string
18+ Duration string
19+ DataDir string
20+ FPS int
21+ CreateVideo bool
22+ Reset bool
23+ )
24+
1425func getTimeString () string {
1526 return time .Now ().UTC ().Format ("2006-01-02-15-04-05" )
1627}
@@ -39,6 +50,7 @@ func main() {
3950 flag .StringVar (& DataDir , "data_dir" , "./obstructionMapData" , "Directory to save the obstruction map frames" )
4051 flag .IntVar (& FPS , "fps" , 10 , "Frames per second for the video" )
4152 flag .BoolVar (& CreateVideo , "video" , true , "Create video from obstruction map frames" )
53+ flag .BoolVar (& Reset , "reset" , false , "Reset the obstruction map every 15 seconds, at the 12nd, 27th, 42nd, and 57th second" )
4254 flag .Parse ()
4355
4456 if CreateVideo {
@@ -76,6 +88,22 @@ func main() {
7688 return
7789 }
7890
91+ if Reset {
92+ go func (grpcClient * Exporter ) {
93+ for {
94+ now := time .Now ()
95+ sec := now .Second ()
96+ if sec == 12 || sec == 27 || sec == 42 || sec == 57 {
97+ log .Printf ("Resetting obstruction map at second: %d\n " , sec )
98+ if err := grpcClient .ResetDishObstructionMap (); err != nil {
99+ log .Println ("Error resetting obstruction map: " , err )
100+ }
101+ }
102+ time .Sleep (time .Second )
103+ }
104+ }(grpcClient )
105+ }
106+
79107 timeNow := time .Now ()
80108 timeEnd := timeNow .Add (durationSecond )
81109
@@ -99,7 +127,7 @@ func main() {
99127 log .Println ("Error writing obstruction map: " , err )
100128 }
101129 f .Close ()
102- time .Sleep (time .Second * 1 )
130+ time .Sleep (time .Millisecond * 500 )
103131 }
104132
105133 if CreateVideo {
0 commit comments