Control & state

These commands manage the robot's overall state rather than a specific motion: resting, pausing, toggling the gyroscope, calibrating, and reading the IMU.

Use case: rest, then calibrate the gyro

using PetoiBittle

connection = PetoiBittle.connect(PetoiBittle.find_bittle_port())

PetoiBittle.send_command(connection, PetoiBittle.Rest())          # lie down and relax the servos
PetoiBittle.send_command(connection, PetoiBittle.GyroCalibrate()) # calibrate from the resting state

stats = PetoiBittle.send_command(connection, PetoiBittle.GyroStats())
@show stats.yaw stats.pitch stats.roll

PetoiBittle.disconnect(connection)
Note

On the Petoi firmware the bare token "d" (PetoiBittle.Rest) is the lie-down / rest-all-servos command. PetoiBittle.Pause instead freezes the current motion and can be toggled to resume.

Resting and pausing

PetoiBittle.Rest — Type
Rest()

A command without arguments. Sends a command to get into resting position.

source

Gyroscope / IMU

PetoiBittle.GyroCalibrate — Type
GyroCalibrate(; wait_before::Float64 = 2.0, wait_after::Float64 = 15.0, verbose = true)

Sends a command to re-calibrate the gyro. The wait_before and wait_after arguments are in seconds. The verbose setting controls whether to print informational messages or not.

Note: This command should be executed from a "resting" state. An example of a resting state might be calibration posture or rest posture. Either use the PetoiBittle.Skill command or PetoiBittle.Rest before calibrating the gyro.

It is advised to wait a little bit before starting the calibration process (especially after executing a PetoiBittle.Skill). By default waits for 2 seconds. The entire process also takes some time, but it is possible to configure it. By default calibrates for 15 seconds. Uses sleep under the hood.

Note: After the calibration finishes, this command automatically persists the new calibration values to the robot by sending a follow-up save command, so the calibration survives a power cycle. This happens inside the after_command callback.

source