/// <summary> /// Handle Bumper Notifications /// </summary> /// <param name="notification">Update notification</param> private void BumperHandler(bumper.Update notification) { string message; if (!notification.Body.Pressed) { return; } // Toggle the motor state _state.MotorOn = !_state.MotorOn; // Create a motor request motor.SetMotorPowerRequest motorRequest = new motor.SetMotorPowerRequest(); if (_state.MotorOn) { // Set the motor power on motorRequest.TargetPower = 1.0; message = "Motor On"; } else { // Set the motor power off motorRequest.TargetPower = 0.0; message = "Motor Off"; } // Send the motor request _motorPort.SetMotorPower(motorRequest); // Show the motor status on the console screen LogInfo(LogGroups.Console, message); }
/// <summary> /// Post Set Motor Power with body and return the response port. /// </summary> public virtual PortSet <DefaultUpdateResponseType, Fault> SetMotorRotation(pxmotor.SetMotorPowerRequest body) { pxmotor.SetMotorPower op = new pxmotor.SetMotorPower(); op.Body = body ?? new pxmotor.SetMotorPowerRequest(); this.PostUnknownType(op); return(op.ResponsePort); }