Exemplo n.º 1
0
 public CollisionData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length)
     : base(robot, code, seqNum, data, asyncCode, length)
 {
     if ((Int32)Data.Length == 16)
     {
         CollisionAccelerometerReading = new AccelerometerReading((Single)GetFloatFromBytes(0), (Single)GetFloatFromBytes(2), (Single)GetFloatFromBytes(4));
         XAxisCollision = (Data[6] & 1) > 0;
         YAxisCollision = (Data[6] >> 1 & 1) > 0;
         CollisionPower = new TwoAxisSensor((Single)GetFloatFromBytes(7), (Single)GetFloatFromBytes(9));
         SpheroSpeed = (Single)Data[11] / 255f;
         Timestamp = GetIntFromBytes((Int32)Data[12]);
     }
 }
Exemplo n.º 2
0
 public CollisionData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length)
     : base(robot, code, seqNum, data, asyncCode, length)
 {
     if ((Int32)Data.Length == 16)
     {
         CollisionAccelerometerReading = new AccelerometerReading((Single)GetFloatFromBytes(0), (Single)GetFloatFromBytes(2), (Single)GetFloatFromBytes(4));
         XAxisCollision = (Data[6] & 1) > 0;
         YAxisCollision = (Data[6] >> 1 & 1) > 0;
         CollisionPower = new TwoAxisSensor((Single)GetFloatFromBytes(7), (Single)GetFloatFromBytes(9));
         SpheroSpeed    = (Single)Data[11] / 255f;
         Timestamp      = GetIntFromBytes((Int32)Data[12]);
     }
 }
Exemplo n.º 3
0
 public AsyncSensorData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length, UInt64 mask)
     : base(robot, code, seqNum, data, asyncCode, length)
 {
     if ((Int32)Data.Length == CountBits(mask) * 2)
     {
         Int32 num = 0;
         if (MaskHasFlag(mask, (DataStreaming)((Int64)458752)))
         {
             Attitude = new AttitudeReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num = num + 6;
         }
         if (MaskHasFlag(mask, (DataStreaming)((Int64)57344)))
         {
             Accelorometer = new AccelerometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num = num + 6;
         }
         if (MaskHasFlag(mask, (DataStreaming)((Int64)7168)))
         {
             Gyrometer = new GyrometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num = num + 6;
         }
         if (MaskHasFlag(mask, DataStreaming.Quaternion))
         {
             Quaternion = new QuaternionReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4), (Single)GetFloatFromBytes(num + 6));
             num = num + 8;
         }
         if (MaskHasFlag(mask, DataStreaming.Location))
         {
             Location = new LocationReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2));
             num = num + 4;
         }
         if (MaskHasFlag(mask, DataStreaming.Velocity))
         {
             Velocity = new VelocityReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2));
             num = num + 4;
         }
     }
 }
Exemplo n.º 4
0
 public AsyncSensorData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length, UInt64 mask)
     : base(robot, code, seqNum, data, asyncCode, length)
 {
     if ((Int32)Data.Length == CountBits(mask) * 2)
     {
         Int32 num = 0;
         if (MaskHasFlag(mask, (DataStreaming)((Int64)458752)))
         {
             Attitude = new AttitudeReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num      = num + 6;
         }
         if (MaskHasFlag(mask, (DataStreaming)((Int64)57344)))
         {
             Accelorometer = new AccelerometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num           = num + 6;
         }
         if (MaskHasFlag(mask, (DataStreaming)((Int64)7168)))
         {
             Gyrometer = new GyrometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4));
             num       = num + 6;
         }
         if (MaskHasFlag(mask, DataStreaming.Quaternion))
         {
             Quaternion = new QuaternionReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4), (Single)GetFloatFromBytes(num + 6));
             num        = num + 8;
         }
         if (MaskHasFlag(mask, DataStreaming.Location))
         {
             Location = new LocationReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2));
             num      = num + 4;
         }
         if (MaskHasFlag(mask, DataStreaming.Velocity))
         {
             Velocity = new VelocityReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2));
             num      = num + 4;
         }
     }
 }
 private void OnAccelerometerUpdated(object sender, AccelerometerReading reading) {
     AccelerometerX.Text = "" + reading.X;
     AccelerometerY.Text = "" + reading.Y;
     AccelerometerZ.Text = "" + reading.Z;
 }
 private void OnAccelerometerUpdated(object sender, AccelerometerReading reading)
 {
     float dx = 100.0F * reading.X;
     float dy = 100.0F * reading.Y;
     double radian = Math.Atan2(dx, dy);
     int kakudo = (int)(radian * 180.0D / Math.PI);
     if (kakudo < 0) kakudo = 360 + kakudo;
     if (kakudo < 0) kakudo = 0;
     if (kakudo > 359) kakudo = 359;
     float kyori = (float)Math.Sqrt(Math.Pow(reading.X, 2) + Math.Pow(reading.Y, 2));
     if (m_target != null)
     {
         m_target.Roll(kakudo, kyori);
     }
 }