private void OnControllerDiscovered(object sender, Robot robot) { if(robot.BluetoothName.Equals(txtController.Text)) { RobotProvider provider = RobotProvider.GetSharedProvider(); provider.ConnectRobot(robot); m_controller = (Sphero)robot; } }
private void OnRobotDiscovered(object sender, Robot robot) { Debug.WriteLine(string.Format("Discovered \"{0}\"", robot.BluetoothName)); if (_robot == null) { var provider = RobotProvider.GetSharedProvider(); provider.ConnectRobot(robot); _robot = (Sphero)robot; } }
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]); } }
private void OnControllerConnected(object sender, Robot robot) { tsConnectController.IsOn = true; tblController.Text = "接続しました。"; if (m_controller != null) { m_controller.SetRGBLED(0, 255, 0); m_controller.SetHeading(0); if (m_controller.SensorControl != null) { m_controller.SensorControl.Hz = 10; m_controller.SensorControl.AccelerometerUpdatedEvent += OnAccelerometerUpdated; } } }
public async void ConnectRobot(Robot robot) { if (!await robot.Connect()) { toastFailConnect(robot.BluetoothName); } else { EventHandler<Robot> connectedRobotEvent = ConnectedRobotEvent; if (connectedRobotEvent != null) { connectedRobotEvent.Invoke(this, robot); } connectedRobots.Add(robot); toastConnect(robot.BluetoothName); } }
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 OnRobotConnected(object sender, Robot robot) { Debug.WriteLine(string.Format("Connected to {0}", robot)); _robot.SetRGBLED(255, 255, 255); }
void OnSpheroConnectionStateChanged(Robot sender, ConnectionState state) { var handlers = this.SpheroConnectionChanged; if ((state == ConnectionState.Disconnected) || (state == ConnectionState.Connected)) { handlers(this, EventArgs.Empty); } if (state == ConnectionState.Connected) { this.sphero.SetBackLED(1.0f); } }
//! @brief when a robot is connected, get ready to drive! private void OnRobotConnected(object sender, Robot robot) { Debug.WriteLine(string.Format("Connected to {0}", robot)); ConnectionToggle.IsOn = true; ConnectionToggle.OnContent = "Connected"; m_robot.SetRGBLED(255, 255, 255); SpheroName.Text = string.Format(kSpheroConnected, robot.BluetoothName); SetupControls(); m_robot.SensorControl.Hz = 10; m_robot.SensorControl.AccelerometerUpdatedEvent += OnAccelerometerUpdated; m_robot.SensorControl.GyrometerUpdatedEvent += OnGyrometerUpdated; m_robot.CollisionControl.StartDetectionForWallCollisions(); m_robot.CollisionControl.CollisionDetectedEvent += OnCollisionDetected; }
//! @brief when a robot is discovered, connect! private void OnRobotDiscovered(object sender, Robot robot) { Debug.WriteLine(string.Format("Discovered \"{0}\"", robot.BluetoothName)); if (m_robot == null) { RobotProvider provider = RobotProvider.GetSharedProvider(); provider.ConnectRobot(robot); ConnectionToggle.OnContent = "Connecting..."; m_robot = (Sphero)robot; SpheroName.Text = string.Format(kConnectingToSphero, robot.BluetoothName); } }
private void OnRobotConnected(object sender, Robot robot) { Debug.WriteLine(string.Format("Connected to {0}", robot)); //ConnectionToggle.IsOn = true; //ConnectionToggle.OnContent = "Connected"; _robot.SetBackLED(127); //m_robot.SetRGBLED(255, 255, 255); //SpheroName.Text = string.Format(kSpheroConnected, robot.BluetoothName); //SetupControls(); //_robot.SetHeading(0); //_robot.Roll(0, 1); //m_robot.SensorControl.StopAll(); // stop rotors _robot.WriteToRobot(new DeviceMessage(2, 0x33, new byte[] { 0, 0, 0, 0 })); _robot.SensorControl.Hz = 10; _robot.SensorControl.AccelerometerUpdatedEvent += OnAccelerometerUpdated; _robot.SensorControl.AttitudeUpdatedEvent += SensorControl_AttitudeUpdatedEvent; _robot.SensorControl.GyrometerUpdatedEvent += OnGyrometerUpdated; _robot.CollisionControl.StartDetectionForWallCollisions(); _robot.CollisionControl.CollisionDetectedEvent += OnCollisionDetected; _gameState = GameState.Connected; _currentColor = Colors.Red; _robot.SetRGBLED(_currentColor.R, _currentColor.G, _currentColor.B); }
private void OnTargetConnected(object sender, Robot robot) { tsConnectTarget.IsOn = true; tblTarget.Text = "接続しました。"; m_target.SetRGBLED(255, 255, 255); }
private void OnTargetDiscovered(object sender, Robot robot) { if (robot.BluetoothName.Equals(txtTarget.Text)) { RobotProvider provider = RobotProvider.GetSharedProvider(); provider.ConnectRobot(robot); m_target = (Sphero)robot; } }