fake | Motor Component

fake

Configuring a fake motor can be convenient for testing software without using any hardware. For example, you can use a fake component as a placeholder while waiting on a hardware shipment, so that other components that depend on this motor (for example, a base) won’t fail to initialize, and your control code won’t throw errors when it fails to find a physical motor connected to your machine.

{
  "components": [
    {
      "name": "<your-motor-name>",
      "model": "fake",
      "api": "rdk:component:motor",
      "attributes": {
        <...>
      },
      "depends_on": []
    }
  ]
}
{
  "components": [
    {
      "name": "fake-motor",
      "model": "fake",
      "api": "rdk:component:motor",
      "attributes": {
        "pins": {
          "dir": "",
          "pwm": ""
        },
        "board": "",
        "dir_flip": false
      },
      "depends_on": []
    }
  ]
}

Since a fake motor isn’t a physical piece of hardware, attributes are only representational and not required. However, if you would like to mock up a virtual placeholder for a real, physical motor, you can configure some or all of the following attributes:

Name Type Required? Description
board string Optional name of the board to which the motor driver is wired.
min_power_pct float Optional Sets a limit on minimum power percentage sent to the motor.
Default: 0.0
max_power_pct float Optional Range is 0.06 to 1.0; sets a limit on maximum power percentage sent to the motor.
Default: 1.0
pwm_freq int Optional Sets the PWM pulse frequency in Hz. Many motors operate optimally in the kHz range.
Default: 800
encoder string Optional The name of an encoder attached to this motor. See encoded motor. If an encoder is configured on a fake motor, ticks_per_rotation becomes required.
max_rpm float Optional An estimate of the max revolutions per minute (RPM) the motor will run at with full power under no load. The GoFor method calculates how much power to send to the motor as a percentage of max_rpm. If unknown, you can set it to 100, which will mean that giving 40 as the rpm argument to GoFor or GoTo will set it to 40% speed. For non-encoded fake motors, this is required or a default is assigned.
Default: 100
ticks_per_rotation int Optional* * Required for calculations if an encoder is configured. For a stepper motor, the number of steps in one full rotation (200 is common). For an encoded motor, how many encoder ticks in one full rotation. See data sheet (for a real motor).
dir_flip bool Optional Flips the direction of “forward” versus “backward” rotation.
Default: false
pins object Optional A struct that holds pin configuration information.

Nested within pins:

Name Type Required? Description
a string Optional See Pin Information. Corresponds to “IN1” on many driver data sheets. Pin number of the GPIO pin this is wired to on the board.
b string Optional See Pin Information. Corresponds to “IN2” on many driver data sheets. Pin number of the GPIO pin this is wired to on the board.
dir string Optional See Pin Information. Pin number of the GPIO pin this is wired to on the board.
pwm string Optional See Pin Information. Pin number of the GPIO pin this is wired to on the board.

Pin Information

There are three common ways for the computing device to communicate with a brushed DC motor driver chip. The driver data sheet (for a real, not fake, motor) will specify which one to use.