public void KinectServiceUpdateTiltHandler(kinect.UpdateTilt update) { var tilt = update.Body.Tilt; // need constants if (tilt > (short)kinect.KinectReservedSampleValues.MaximumTiltAngle || tilt < (short)kinect.KinectReservedSampleValues.MinimumTiltAngle) { update.ResponsePort.Post( Fault.FromCodeSubcodeReason( FaultCodes.Sender, DsspFaultCodes.OperationFailed, Resources.InvalidTiltAngle)); } else { var rotation = this.kinectEntity.Rotation; this.kinectEntity.DepthCam.Rotation = new xna.Vector3((float)tilt, rotation.Y, rotation.Z); this.kinectEntity.WebCam.Rotation = new xna.Vector3((float)tilt, rotation.Y, rotation.Z); this.state.TiltDegrees = tilt; this.UpdateTiltAngle(tilt); update.ResponsePort.Post(DefaultUpdateResponseType.Instance); SendNotification(this.kinectSubmgrPort, update); } }
public IEnumerator <ITask> OnRotateSingle(pantilt.Rotate rotate) { // Just convert this to a kinect tilt operation if (rotate.Body.RotatePanRequest != null && rotate.Body.RotatePanRequest.TargetRotationAngleInRadians != 0) { rotate.ResponsePort.Post(Fault.FromCodeSubcodeReason( FaultCodes.Receiver, DsspFaultCodes.ActionNotSupported, Resources.PanNotSupported)); yield break; } if (rotate.Body.RotateTiltRequest == null) { // no-op rotate.ResponsePort.Post(DefaultUpdateResponseType.Instance); yield break; } if (rotate.Body.RotateTiltRequest.IsMotionCompletionRequiredForResponse != false) { rotate.ResponsePort.Post(Fault.FromCodeSubcodeReason( FaultCodes.Receiver, DsspFaultCodes.ActionNotSupported, Resources.ResponseOnMotionCompletedNotSupported)); yield break; } if (rotate.Body.RotateTiltRequest.TargetAccelerationInRadiansPerSecondSecond != 0) { LogWarning(Resources.AccelerationIgnored); } if (rotate.Body.RotateTiltRequest.MaxSpeedInRadiansPerSecond != 0) { LogWarning(Resources.SpeedIgnored); } double targetTiltInDegrees; if (rotate.Body.RotateTiltRequest.IsRelative) { targetTiltInDegrees = this.state.TiltDegrees + (rotate.Body.RotateTiltRequest.TargetRotationAngleInRadians * DegreesPerRadian); } else { targetTiltInDegrees = rotate.Body.RotateTiltRequest.TargetRotationAngleInRadians * DegreesPerRadian; } this.panTiltState.TiltState.JointCommand.TargetAngleInRadians = targetTiltInDegrees / DegreesPerRadian; var updateTilt = new kinect.UpdateTilt { Body = { Tilt = targetTiltInDegrees }, ResponsePort = rotate.ResponsePort }; this.kinectOps.Post(updateTilt); yield break; }