AForge.Robotics.Surveyor.SRV1.RunMotors C# (CSharp) Method

RunMotors() public method

Run motors connected to SRV-1 robot.

The method provides direct access to motors setting specified, speed to both motors connected to the SRV-1 robot. The maximum absolute speed equals to 127, but the sign specifies direction of motor's rotation (forward or backward).

The method sends 'Mabc' SRV-1 command (see SRV-1 Control Protocol), which uses 2nd and 3rd timers for controlling motors/servos.

public RunMotors ( int leftSpeed, int rightSpeed, int duration ) : void
leftSpeed int Left motor's speed, [-127, 127].
rightSpeed int Right motor's speed, [-127, 127].
duration int Time duration to run motors measured in number /// of 10 milliseconds (0 for infinity), [0, 255].
return void
        public void RunMotors( int leftSpeed, int rightSpeed, int duration )
        {
            // check limits
            if ( leftSpeed == -128 )
                leftSpeed = -127;
            if ( rightSpeed == -128 )
                rightSpeed = -127;
            if ( duration > 255 )
                duration = 255;

            Send( new byte[] { (byte) 'M', (byte) leftSpeed, (byte) rightSpeed, (byte) duration } );
        }