@@ -7,8 +7,10 @@ import (
77 "github.com/RoboCup-SSL/ssl-go-tools/internal/gc"
88 "github.com/RoboCup-SSL/ssl-go-tools/internal/vision"
99 "github.com/RoboCup-SSL/ssl-go-tools/pkg/persistence"
10+ "github.com/pkg/errors"
1011 "google.golang.org/protobuf/proto"
1112 "log"
13+ "math"
1214 "os"
1315)
1416
@@ -55,6 +57,8 @@ func main() {
5557 check (writeMessage (f , r .Timestamp , visionMsg .Geometry ))
5658 }
5759 if * extractDetection && visionMsg .Detection != nil {
60+ removeInfinite (visionMsg .Detection .RobotsYellow )
61+ removeInfinite (visionMsg .Detection .RobotsBlue )
5862 check (writeMessage (f , r .Timestamp , visionMsg .Detection ))
5963 }
6064 } else if r .MessageType .Id == persistence .MessageSslRefbox2013 {
@@ -79,7 +83,7 @@ func writeMessage(f *os.File, timestamp int64, v interface{}) error {
7983 var result map [string ]interface {}
8084
8185 if b , err := json .Marshal (v ); err != nil {
82- return err
86+ return errors . Wrap ( err , "Could not marshal message" )
8387 } else {
8488 if err := json .Unmarshal (b , & result ); err != nil {
8589 return err
@@ -118,3 +122,11 @@ func check(err error) {
118122 log .Println ("Unexpected error:" , err )
119123 }
120124}
125+
126+ func removeInfinite (robots []* vision.SSL_DetectionRobot ) {
127+ for _ , r := range robots {
128+ if r .Confidence != nil && (math .IsNaN (float64 (* r .Confidence )) || math .IsInf (float64 (* r .Confidence ), 0 )) {
129+ * r .Confidence = 0
130+ }
131+ }
132+ }
0 commit comments