示例#1
0
        public void Write(Messages.Sensor.LaserScan laserScan)
        {
            ranges     = new float[laserScan.ranges.Length];
            directions = new Vector3[laserScan.ranges.Length];
            range_max  = laserScan.range_max;
            range_min  = laserScan.range_min;

            for (int i = 0; i < laserScan.ranges.Length; i++)
            {
                ranges[i]     = laserScan.ranges[i];
                directions[i] = new Vector3(Mathf.Cos(laserScan.angle_min + laserScan.angle_increment * i), Mathf.Sin(laserScan.angle_min + laserScan.angle_increment * i), 0).Ros2Unity();
            }
            isReceived = true;
        }
示例#2
0
        public void Write(Messages.Sensor.LaserScan laserScan)
        {
            try
            {
                Debug.Log("Writing new LaserScan message");
                ranges     = new float[laserScan.ranges.Length];
                directions = new Vector3[laserScan.ranges.Length];
                range_max  = laserScan.range_max;
                range_min  = laserScan.range_min;

                for (int i = 0; i < laserScan.ranges.Length; i++)
                {
                    ranges[i]     = laserScan.ranges[i];
                    directions[i] = new Vector3(Mathf.Cos(laserScan.angle_min + laserScan.angle_increment * i), Mathf.Sin(laserScan.angle_min + laserScan.angle_increment * i), 0).Ros2Unity();
                }
                isReceived = true;
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
        }