Generic Differential Drive
Glossary Item Box
The Generic Differential Drive service defines how to control a differential drive for a robot. A differential drive usually consists of two wheels that can be driven independently. However, this concept can be applied to other forms of locomotion such as legged robots, like a hexabot with three legs on each side. A key feature of a differential drive is that by driving the wheels in opposite directions the robot can rotate on the spot. This drive service is not appropriate for Ackerman-style drives such as automobiles where the drive is steered by turning a separate pair of wheels.
The Generic Differential Drive service provides the following operations as requests (actions) as well as notifications, except for Get. When used as requests, these operations support controlling the movement of the drive. As notification messages, they provide updates on changes to the state of the drive.
|AllStop||Stops the drive. This cancels any drive operation in progress and sets the power to both wheels to zero. For safety reasons, the drive is also disabled. Before you can drive the robot again you must use EnableDrive setting it to true. Until you have re-enabled the drive, all other requests will fail and return a Fault.|
|DriveDistance||Causes the drive to move forward or backward a specified distance. There are three parameters: Distance; Power; and DriveDistanceStage. The Distance must always be a positive (double) value in meters. The Power is specified using the same convention as the SetDrivePower operation, (between -1.0 and 1.0, with negative values meaning to move backwards). DriveDistanceStage must be set to DriveStage.InitialRequest. Issuing any other motion request to the drive (including another DriveDistance) should cancel a DriveDistance that is already in progress. This request requires the drive to support an encoder or some other means of measuring distance driven. Drives that rely on a timer are likely to be inaccurate.|
|EnableDrive||Enables (when set to true) or disables (when set to false) the drive. Initially the drive should be enabled. When it is disabled, all requests to move the robot will fail. Also, if the drive is disabled while it is running then it should immediately stop regardless of what type of operation is being performed.|
|Get||Returns the state of the differential drive service.|
|SetDrivePower||Sets the power settings for the left and right wheels (LeftWheelPower and RightWheelPower respectively) as values between -1.0 and 1.0 (doubles). Negative values rotate the wheel backwards, and positive values rotate the wheel forwards. Successive SetDrivePower requests can be used to vary the motor powers and achieve complex driving patterns. Each new request simply changes the power applied to the motors and supersedes the previous request. Setting a value of zero for both wheels should stop the robot. However, some drives may coast before stopping after driving at high speed. Applying equal power to both wheels but of opposite signed values (that is, one positive and the other negative) will cause the drive to rotate. The effect of a particular power value may vary for different drives.|
|SetDriveSpeed||Sets the speed of the drive in meters per second. The speed of drive depends on its geometry (such as wheel radius), the relationship of power to the rotational speed of the motors and possibly the battery voltage level. As a result this feature may not be implemented or may not be accurate for some drives.|
|RotateDegrees||Rotates the drive by the specified angle. Angles are in degrees, with positive angles meaning left or counterclockwise with respect to the center of the robot as viewed from above. There are three parameters: Degrees; Power; and RotateDegreesStage. The RotateDegreesStage must be set to DriveStage.InitialRequest. The accuracy of the rotation may vary for different drives. Lower power settings may result in more accurate turns, but some drives may stall if you set the power too low and never complete the rotation. Issuing any other motion request to the drive (including another RotateDegrees) should cancel a RotateDegrees that is already in progress. This request requires the drive to support an encoder or some other means of measuring rotation. Drives that rely on a timer are likely to be inaccurate.|
DriveDistance and RotateDegrees, operate in a similar way in that both of these operations send back a response immediately (unless there is a Fault), but also generate notifications. The DriveDistanceStage or RotateDegreesStage fields indicate the progress of the operation.
In the simplest case, sending DriveDistance or RotateDegrees request starts the drive moving returning Started in the "stage" field of its response and also its notification. When the operation completes some time later when the drive has moved the requested distance or degrees, a notification is generated returning the stage as Completed.
However, if a subsequent drive request (including also SetDrivePower, SetDriveSpeed, or AllStop requests) is received before a request completes, the DriveDistance or RotateDegrees operation is interrupted and the service generates a notification returning Canceled, and the second request is executed as usual returning its own response and notification.
The Generic Differential Drive configuration takes two required partner services: LeftMotor and RightMotor, and two optional partner services: LeftEncoder, and RightEncoder. It also supports a set of initial state properties that make up its DriveDifferentialTwoWheelState that include:
|Name||string||A descriptive identifier for the LeftWheel and RightWheel.|
|Radius||double||The radius of the wheel attached to the motor.|
|GearRatio||double||The ratio of the motor rotations divided by wheel rotations. A number less than one means the wheel is turning slower than the motor. For example, 1/5 means the wheel is turning 5 times slower than the motor.|
|DistanceBetweenWheels||double||The distance between the drive wheels (in meters).|
|IsEnabled||Boolean||Whether the drive is enabled. Typically you will set this to true when setting the drive's initial state properties.|
|DriveDistanceStage||DriveStage||The stage of the DriveDistance operation. Typically you will set this to InitialRequest when setting the drive's initial state properties.|
|RotateDegreesStage||DriveStage||The stage of the RotateDegrees operation. Typically you will set this to InitialRequest when setting the drive's initial state properties.|
If you set the Generic Differential Drive partners using the Set initial configuration option, you can drag and drop appropriate partner services to the Set Configuration page.
Updated information might be available online in the MSDN Library page:
Generic Differential Drive
VPL Robotics Services: Robotics Services Overview
© 2012 Microsoft Corporation. All Rights Reserved.