示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        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;
        }