private void HandleRobotMessage(RobotMessage message) { const float deadzone = 0.3f; switch (message.JoystickType) { case JoystickType.Direction: _robot.Direction = message.CalculateHeadingVector(deadzone); break; case JoystickType.Rotation: _robot.Rotation = message.GetScaledX(deadzone, 2, 25); break; case JoystickType.Camera: if (message.MessageType == MessageType.Reset) { _cameraController.CenterView(); } else { _cameraController.StartMove(message.CalculateHeadingVector(deadzone)); } break; case JoystickType.Translation: var direction = message.CalculatePinPosition(0.1f); const float scaleBy = 5; var newTransform = new Vector3(-direction.X * scaleBy, -direction.Y * scaleBy, 0); if (!newTransform.Similar(_robot.RelaxedStance, 0.5f)) { _robot.UpdateAboluteRelaxedStance(newTransform, _robot.RelaxedStanceRotation); } break; case JoystickType.Height: var heightAdjust = -message.CalculatePinPosition(0.1f).X; const float scaleByHeight = 5; newTransform = new Vector3(0, 0, heightAdjust * scaleByHeight); if (!newTransform.Similar(_robot.RelaxedStance, 0.5f)) { _robot.UpdateAboluteRelaxedStance(newTransform, _robot.RelaxedStanceRotation); } break; case JoystickType.BodyRotation: direction = message.CalculatePinPosition(0.1f); const float scaleByRotation = 10; var newRotation = new Rotation(0, -direction.X * scaleByRotation, direction.Y * scaleByRotation); if (!newRotation.Similar(_robot.RelaxedStanceRotation, 0.5f)) { _robot.UpdateAboluteRelaxedStance(_robot.RelaxedStance, newRotation); } break; default: throw new NotImplementedException(); } }