liveBook · Manning

Set_throttle

As explained in Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

A robot-control operation that assigns throttle levels to motors using a motor name, direction factor, and speed value.

set_throttle assigns a throttle value to a named motor. It combines a discrete speed setting, a per-motor adjustment, and an optional direction factor, allowing the same operation to drive forward or backward. section 3.7 section 3.6

The operation applies these inputs:

  • name selects the motor through the MOTOR mapping, such as R or L. section 3.7
  • speed selects a throttle level from THROTTLE_SPEED: 0 stops, while 1, 2, and 3 represent progressively higher settings. section 3.6
  • factor controls direction; the default value 1 drives forward, while -1 reverses the motor. section 3.7
  • ADJUST compensates independently for the two motors before the resulting value is assigned to throttle. section 3.6

Driving backward

A backward movement calls set_throttle('R', speed, factor=-1) and set_throttle('L', speed, factor=-1), waits for the requested duration, then calls both motors with speed 0 to stop. section 3.7

Joystick control

A joystick client converts each y-axis position into a level from -3 through 3, derives direction from its sign, uses the absolute level as speed, and sends set_throttle arguments over HTTP. section 7.7.1

def set_throttle(name, speed, factor=1):
    MOTOR[name].throttle = THROTTLE_SPEED[speed] * ADJUST[name] * factor

The compact implementation shows the complete throttle calculation and assignment. section 3.7

How Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi covers it

How deep it goes
Explains the calculation, speed table, direction factor, motor adjustment, stopping behavior, and HTTP invocation, but not motor-control internals.
Examples
Demonstrates calibrated two-motor driving, repeated backward motion, discrete speed levels, and remote joystick commands.
What it assumes
Assumes Python, mapped motors, throttle-capable hardware, and basic function calls; teaches speed and direction parameters incrementally.
What you can do after
Build reusable Python movement functions and apply them locally or through a joystick-driven HTTP client.
How it connects
Connects DC motors with throttle control, forward and backward movement, joystick input, and HTTP requests.

This explainer was generated by Manning's knowledge graph from the text of Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi. The section links point to the parts of the book it draws on.