public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { PointXYZRGB point = (PointXYZRGB)value; return(point.X + " " + point.Y + " " + point.Z + " " + point.R + " " + point.G + " " + point.B); } return(base.ConvertTo(context, culture, value, destinationType)); }
// This function should fire on each ros message public new static void CallBack(ROSBridgeMsg msg) { cloud = (PointCloud2Msg)msg; List <PointXYZRGB> points = (List <PointXYZRGB>)DepthSubscriber.cloud.GetCloud().Points; PointXYZRGB point = points[0]; Debug.Log(point.R + " | " + point.G + " | " + point.B + " ----- " + point.X + " | " + point.Y + " | " + point.Z); //Debug.Log("image received"); //Debug.Log("Here is the message received " + msg); // Update ball position, or whatever //ball.x = msg.x; // Check msg definition in rosbridgelib //ball.y = msg.y; //ball.z = msg.z; }
private PointCloud <PointXYZRGB> ReadData(byte[] byteArray) { PointCloud <PointXYZRGB> cloud = new PointCloud <PointXYZRGB> (); for (int i = 0; i < _width * _height; i++) { float x = System.BitConverter.ToSingle(_data, i * (int)_point_step + 0); float y = System.BitConverter.ToSingle(_data, i * (int)_point_step + 4); float z = System.BitConverter.ToSingle(_data, i * (int)_point_step + 8); float rgb = System.BitConverter.ToSingle(_data, i * (int)_point_step + 16); if (!float.IsNaN(x + y + z)) { PointXYZRGB p = new PointXYZRGB(x, y, z, rgb); cloud.Add(p); } } return(cloud); }