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)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.
PetoiBittle.Pause — Type
Pause()A PetoiBittle.Command that pauses the robot's current motion. Sending it again typically resumes motion. Serializes to the token "p".
See also: PetoiBittle.Rest (the firmware's lie-down / rest command, token "d").
PetoiBittle.Recover — Type
Recover()A PetoiBittle.Command that toggles the robot's automatic posture-recovery behaviour (getting back up after falling). Serializes to the token "krc".
Gyroscope / IMU
PetoiBittle.SwitchGyro — Type
SwitchGyro()A PetoiBittle.Command that toggles whether the robot uses its IMU (gyroscope) for balance and self-recovery. Serializes to the token "g".
To calibrate the gyroscope instead, use PetoiBittle.GyroCalibrate; to read its current values, use PetoiBittle.GyroStats.
PetoiBittle.Calibrate — Type
Calibrate()A PetoiBittle.Command that puts the robot into calibration mode. Serializes to the token "c". While in calibration mode you can fine-tune the neutral angles of each joint.
See also: PetoiBittle.CalibrationPose for the matching standing pose.
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.
PetoiBittle.GyroStats — Type
GyroStats()A command with no arguments. Returns PetoiBittle.GyroStatsOutput with statistics for the connected gyro.
PetoiBittle.GyroStatsOutput — Type
GyroStatsOutputThis structure is returned after executing PetoiBittle.GyroStats command with the PetoiBittle.send_command.
Has the following fields:
- yaw
- pitch
- roll
- acceleration_x
- acceleration_y
- acceleration_z