Skip to content

MiP_Motion

github-actions[bot] edited this page Aug 10, 2026 · 9 revisions

Class MiP_Motion

Manages MiP's drive, turn, posture, and balance systems.

Table of Contents


Public Functions

continuousDrive

Signature: void continuousDrive(int8_t velocity, int8_t turnRate)

Summary: Sends continuous drive command (velocity + turn rate).

Details:

Rate-limited internally to avoid overwhelming MiP's UART interface (~20 Hz max). Fire-and-forget command (no read-back verification possible).

Parameters:

Parameter Description
velocity Speed/direction (-32 to +32; negative = backward, positive = forward).
turnRate Turn rate/direction (-32 to +32; negative = left, positive = right).

distanceDrive

Signature: void distanceDrive(MiPDriveDirection driveDirection, uint8_t cm, MiPTurnDirection turnDirection, uint16_t degrees)

Summary: Drives a specific distance then optionally turns.

Details:

Fire-and-forget command.

Parameters:

Parameter Description
driveDirection Direction to drive (MIP_DRIVE_FORWARD or MIP_DRIVE_BACKWARD).
cm Distance to travel in centimeters (0-255 cm).
turnDirection Turn direction after driving (MIP_TURN_LEFT or MIP_TURN_RIGHT).
degrees Turn angle in degrees (0-360 degrees).

driveForward

Signature: void driveForward(uint8_t speed, uint16_t time)

Summary: Drives forward for a limited time at given speed.

Details:

Fire-and-forget command. Duration parameter is internally converted to 7ms hardware ticks (max duration ~1.78 seconds / 1785 ms).

Parameters:

Parameter Description
speed Drive speed (0-30).
time Duration in milliseconds (max 1785 ms).

driveBackward

Signature: void driveBackward(uint8_t speed, uint16_t time)

Summary: Drives backward for a limited time at given speed.

Details:

Fire-and-forget command. Duration parameter is internally converted to 7ms hardware ticks (max duration ~1.78 seconds / 1785 ms).

Parameters:

Parameter Description
speed Drive speed (0-30).
time Duration in milliseconds (max 1785 ms).

turnLeft

Signature: void turnLeft(uint16_t degrees, uint8_t speed)

Summary: Turns left by the specified angle at given speed.

Details:

Fire-and-forget command. Angle parameter is internally converted to 5° hardware units (max angle 1275°).

Parameters:

Parameter Description
degrees Turn angle in degrees (max 1275°).
speed Turn speed (0-24).

turnRight

Signature: void turnRight(uint16_t degrees, uint8_t speed)

Summary: Turns right by the specified angle at given speed.

Details:

Fire-and-forget command. Angle parameter is internally converted to 5° hardware units (max angle 1275°).

Parameters:

Parameter Description
degrees Turn angle in degrees (max 1275°).
speed Turn speed (0-24).

stop

Signature: void stop()

Summary: Stops all motor motion immediately.

Details:

Fire-and-forget command.


fallForward

Signature: void fallForward()

Summary: Commands MiP to fall forward onto its face.


fallBackward

Signature: void fallBackward()

Summary: Commands MiP to fall backward onto its back.


getUp

Signature: void getUp(MiPGetUp getup=MIP_GETUP_FROM_EITHER)

Summary: Commands MiP to stand up from a fallen position.

Parameters:

Parameter Description
getup Which direction/side to attempt getting up from (default = MIP_GETUP_FROM_EITHER).

Public Variables

MIP_CMD_CONTINUOUS_DRIVE

Signature: constexpr uint8_t MIP_CMD_CONTINUOUS_DRIVE

Summary: MiP protocol command byte for continuous drive (velocity + turn rate).


MIP_CMD_DISTANCE_DRIVE

Signature: constexpr uint8_t MIP_CMD_DISTANCE_DRIVE

Summary: MiP protocol command byte to drive a specific distance and angle.


MIP_CMD_TURN_LEFT

Signature: constexpr uint8_t MIP_CMD_TURN_LEFT

Summary: MiP protocol command byte to turn left by a specific angle and speed.


MIP_CMD_TURN_RIGHT

Signature: constexpr uint8_t MIP_CMD_TURN_RIGHT

Summary: MiP protocol command byte to turn right by a specific angle and speed.


MIP_CMD_DRIVE_FORWARD

Signature: constexpr uint8_t MIP_CMD_DRIVE_FORWARD

Summary: MiP protocol command byte to drive forward for a timed duration.


MIP_CMD_DRIVE_BACKWARD

Signature: constexpr uint8_t MIP_CMD_DRIVE_BACKWARD

Summary: MiP protocol command byte to drive backward for a timed duration.


MIP_CMD_STOP

Signature: constexpr uint8_t MIP_CMD_STOP

Summary: MiP protocol command byte to immediately stop all motor motion.


MIP_CMD_SET_POSITION

Signature: constexpr uint8_t MIP_CMD_SET_POSITION

Summary: MiP protocol command byte to force MiP to fall down in a specified direction.


MIP_CMD_GET_UP

Signature: constexpr uint8_t MIP_CMD_GET_UP

Summary: MiP protocol command byte to command MiP to stand up from a fallen position.


MIP_CONTINUOUS_DRIVE_DELAY

Signature: constexpr uint8_t MIP_CONTINUOUS_DRIVE_DELAY

Summary: Minimum inter-command delay in milliseconds for continuous drive commands (~20 Hz).


Clone this wiki locally