Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Control Protocol

jrvanwhy edited this page Jul 12, 2015 · 27 revisions

Miscellaneous

  • Mailboxes: Mailbox 0 is used for Host -> NXT communication and mailbox 1 is used for NXT -> Host communication.
  • Program name: The name of the program is nerf.rxe
  • Multiple commands: Both incoming and outgoing commands may be concatenated together into a single mailbox message (for efficiency). For example, both the Set Yaw and Set Pitch commands may be sent in a single message by concatenating them.
  • Bounds checking: If a position command is sent which commands an out-of-range position, the position target will be clamped between the minimum and maximum bounds.
  • Yaw gear ratio: The yaw gear ratio is (36/12) * (56/8) = 21. Thus the yaw commands are in units of 1/21 degrees.
  • Ignoring commands: The NXT will ignore all commands during calibration (which occurs at startup). Additionally, it will ignore all commands after an EStop has occurred.

Host -> NXT Commands

The message IDs intentionally start at 1; for safety reasons, ID 0 is invalid and will result in an EStop.

Set Yaw

  • ID: 1
  • Description: Sets the position target for the yaw controller.
  • Format: 3 byte message: "0x01 LSB MSB". The position is a two's-complement 16 bit integer (with a little endian byte order).

Set Pitch

  • ID: 2
  • Description/Format/Information: Identical to the Set Yaw command, ID 1, except it applies to the pitch controller and has a different ID.

Set Relative Yaw

  • ID: 3
  • Description: Sets the yaw controller's setpoint relative to the current position of the yaw motors.
  • Format/Additional Information: Same as for the Set Yaw command.

Set Relative Pitch

  • ID: 4
  • Description/Format/Information: Identical to the Set Relative Yaw command, ID 3, except for pitch.

Zero Yaw

  • ID: 5
  • Description: This will set the zero point for the yaw controller to its current position
  • Format: Just one byte: 0x05
  • Additional Information: This will update the bounds on yaw position so they represent the same physical position (but have different numerical values).

Shoot Begin

  • ID: 7
  • Description: This will begin continuously shooting darts from the Nerf gun.
  • Format: Single byte: 0x07

Shoot End

  • ID: 8
  • Description: This will stop shooting darts from the Nerf gun
  • Format: Single byte: 0x08

Intimidate

  • ID: 9
  • Description: This will cause the Nerf blaster's flywheel to spin up without firing darts.
  • Format: Single byte: 0x09
  • Additional Information: This will override a Shoot Begin command, preventing firing while still spinning up the flywheel.

Query Yaw

  • ID: 12
  • Description: This will cause the NXT to transmit message 0 (Current Yaw Position) back to the host PC
  • Format: Single byte: 0x0C

Query Pitch

  • ID: 13
  • Description/Format: See the Query Yaw command, ID 12

Abort

  • ID: 14
  • Description: This will terminate the NXT program, powering off the motors.
  • Format: Single byte: 0x0E
  • Additional Information: This will cause it to forget its calibration. Yaw will need to be re-calibrated before the next startup!

NXT -> Host Messages

Current Yaw Position

  • ID: 1
  • Description: This reports the current yaw position to the host.
  • Format: Variable length. Consists of a 0x01 byte followed by a length byte, then the current yaw position encoded in base-10 in ASCII. The length describes the length of the encoded position.
  • Additional Information: This is a response to the Query Yaw command.

Current Pitch Position

  • ID: 2
  • Description/Format/Information: See the Current Yaw Position command, ID 1, but for the pitch axis.

Emergency Stopped

  • ID: 3
  • Description: Indicates that an emergency stop has occurred.
  • Format: One byte: 0x03
  • Additional Information: The EStop cause will be displayed on the NXT screen. An EStop will cease all further communications with the host computer.