示例#1
0
 public static string ToJson(this WorldStateMessage self) => JsonConvert.SerializeObject(self, Converter.Settings);
示例#2
0
        public WorldStateMessage ConvertToWorldStateMessage()
        {
            WorldStateMessage wsm = new WorldStateMessage();

            foreach (var teamMate in teammateLocationList)
            {
                Robot r = new Robot();
                r.Id   = teamMate.Key;
                r.Pose = new List <double>()
                {
                    teamMate.Value.X, teamMate.Value.Y, teamMate.Value.Theta
                };
                r.TargetPose = new List <double>()
                {
                    0, 0, 0
                };
                r.Velocity = new List <double>()
                {
                    teamMate.Value.Vx, teamMate.Value.Vy, teamMate.Value.Vtheta
                };
                r.Intention    = "";
                r.BatteryLevel = 100;
                r.BallEngaged  = 0;
                wsm.Robots.Add(r);
            }

            //On prend par défaut la première balle du premier robot
            Ball b = new Ball();

            b.Position = new List <double?>()
            {
                ballLocationList[0].X, ballLocationList[0].X, 0
            };
            b.Velocity = new List <double?>()
            {
                ballLocationList[0].Vx, ballLocationList[0].Vy, 0
            };
            b.Confidence = 1;
            wsm.Balls.Add(b);

            foreach (var o in obstacleLocationList)
            {
                Obstacle obstacle = new Obstacle();
                obstacle.Position = new List <double>()
                {
                    o.X, o.Y
                };
                obstacle.Velocity = new List <double>()
                {
                    o.Vx, o.Vy
                };
                obstacle.Radius     = 0.5;
                obstacle.Confidence = 1;
                wsm.Obstacles.Add(obstacle);
            }

            wsm.Intention = "Win";
            wsm.AgeMs     = timeStampMs;
            wsm.TeamName  = "RCT";
            wsm.Type      = "worldstate";
            return(wsm);
        }