private void ForwardButton_Click(object sender, EventArgs e) { short speedDelta = (short)SpeedDeltaNumericUpDown.Value; short speed = LastCommandedMotorSettings.Speed += speedDelta; if (speed > MaximumCommandedMotorSettings.Speed) { speed = MaximumCommandedMotorSettings.Speed; } DSMCUCommand command = new DSMCUCommand { Speed = speed, TurnRate = LastCommandedMotorSettings.TurnRate, STThetaXY = LastCommandedMotorSettings.STThetaXY, STThetaZX = LastCommandedMotorSettings.STThetaZX }; byte[] payloadByteArray = StructByteConverter.StructByteConverter.getByteArray(command); MRSPSP.SendCommandMessage(command: (byte)MRSMessageType.DSMCUSetMotors, buffer: payloadByteArray); LastCommandedMotorSettings = command; // Test conversion back to DSMCUCommand struct: //DSMCUCommand testCommand = StructByteConverter.StructByteConverter.fromBytes<DSMCUCommand>(payloadByteArray); }
private void GetMRSTestTextMessageButton_Click(object sender, EventArgs e) { // Send a text message to be locally logged / displayed and request the MRS sends a test text message back: string testMessage = "Test MSG"; byte[] dummy = ASCIIEncoding.ASCII.GetBytes(testMessage); MRSPSP.SendCommandMessage((byte)MRSMessageType.MRSTextMessage, dummy); System.Threading.Thread.Sleep(500); MRSPSP.SendCommandMessage((byte)MRSMessageType.GetTestTextMessage, dummy); }
private void StopButton_Click(object sender, EventArgs e) { DSMCUCommand command = new DSMCUCommand { Speed = 0x0000, TurnRate = 0x0000, STThetaXY = LastCommandedMotorSettings.STThetaXY, STThetaZX = LastCommandedMotorSettings.STThetaZX }; byte[] payloadByteArray = StructByteConverter.StructByteConverter.getByteArray(command); MRSPSP.SendCommandMessage(command: (byte)MRSMessageType.DSMCUSetMotors, buffer: payloadByteArray); LastCommandedMotorSettings = command; }
private void RightButton_Click(object sender, EventArgs e) { // Right turn is negative if x-axis is straight ahead and y-axis is directed to the left of the MRS chassis short turnRateDelta = (short)TurnRateDeltaNumericUpDown.Value; short turnRate = LastCommandedMotorSettings.TurnRate -= turnRateDelta; if (turnRate < MinimumCommandedMotorSettings.TurnRate) { turnRate = MinimumCommandedMotorSettings.TurnRate; } DSMCUCommand command = LastCommandedMotorSettings; command.TurnRate = turnRate; byte[] payloadByteArray = StructByteConverter.StructByteConverter.getByteArray(command); MRSPSP.SendCommandMessage(command: (byte)MRSMessageType.DSMCUSetMotors, buffer: payloadByteArray); LastCommandedMotorSettings = command; }
private void MRSTestMotorsButton_Click(object sender, EventArgs e) { byte[] dummy = { 0x00 }; MRSPSP.SendCommandMessage((byte)MRSMessageType.TestMotors, dummy); }
private void MRSSYSDiagnosticsButton_Click(object sender, EventArgs e) { byte[] dummy = { 0x00 }; MRSPSP.SendCommandMessage((byte)MRSMessageType.RunSystemDiagnostics, dummy); }
private void GetMRSStatusButton_Click(object sender, EventArgs e) { byte[] dummy = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D }; MRSPSP.SendCommandMessage((byte)MRSMessageType.TestPacketTransfer, dummy); }
// MRS Controls ******************************************************************************************************* private void TestMRSComsButton_Click(object sender, EventArgs e) { byte[] dummy = { 0x55 }; MRSPSP.SendCommandMessage((byte)MRSMessageType.ToggleBuiltInLED, dummy); }