Byte uses a Proportional-Integral-Derivative (PID) controller for body orientation stabilization:
u(t) = Kₚ·e(t) + Kᵢ·∫₀ᵗ e(τ)dτ + Kd·(de(t)/dt)
Where:
u(t): Control output (servo offset in radians)e(t): Error signal =target_rpy - measured_rpy(degrees)Kₚ: Proportional gain = 0.033Kᵢ: Integral gain = 0.0 (disabled)Kd: Derivative gain = 0.0 (disabled)
Byte currently uses proportional-only control (P-controller):
u(t) = Kₚ·e(t)
Rationale:
- Integral term disabled: Prevents integral windup during transient disturbances
- Derivative term disabled: Avoids amplification of sensor noise from IMU
- Proportional gain: Empirically tuned for stable balance during locomotion
The proportional gain Kₚ = 0.033 was determined through:
- Initial estimate: Based on system dynamics and servo response time
- Empirical tuning: Tested values from 0.01 to 0.1 in increments of 0.01
- Stability criteria:
- No oscillations during steady-state walking
- Adequate response to pitch/roll disturbances
- Smooth recovery from external perturbations
┌─────────┐ ┌──────────┐ ┌─────────┐ ┌─────────┐
│ Target │────▶│ Error │────▶│ PID │────▶│ Servos │
│ RPY │ │ e(t) │ │Controller│ │ Offset │
└─────────┘ └──────────┘ └─────────┘ └─────────┘
▲ │ │
│ │ │
└────────────────────────────────┴──────────────────┘
│
▼
┌─────────┐
│ IMU │
│ (SH3001)│
└─────────┘
The error signal is computed as:
e_roll(t) = target_roll - measured_roll
e_pitch(t) = target_pitch - measured_pitch
Where:
target_roll, target_pitch: Desired body orientation (typically 0°)measured_roll, measured_pitch: IMU-measured orientation
The control output is applied as a servo offset:
servo_offset_roll = Kₚ · e_roll(t) · (π/180) # Convert deg to rad
servo_offset_pitch = Kₚ · e_pitch(t) · (π/180)
This offset is added to the nominal leg angles to maintain balance.
The walking gait uses a sequential leg lifting pattern with 8 sections per cycle:
Time: 0 1 2 3 4 5 6 7 8
│ │ │ │ │ │ │ │ │
FL: ↑ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬
RL: ▬ ▬ ▬ ↑ ▬ ▬ ▬ ▬ ▬
FR: ▬ ▬ ▬ ▬ ▬ ↑ ▬ ▬ ▬
RR: ▬ ▬ ↑ ▬ ▬ ▬ ▬ ▬ ▬
│ │ │ │ │ │ │ │ │
└────┴────┴────┴────┴────┴────┴────┴────┘
Complete Gait Cycle
Characteristics:
- Duty factor: 0.75 (75% contact, 25% swing)
- Stability: 3-point support during swing phase
- Speed: Slower but more stable than trotting
The trotting gait uses diagonal leg pairs with 2 sections per cycle:
Time: 0 1 2
│ │ │
FL: ↑ ▬ ▬
RL: ▬ ↑ ▬
FR: ▬ ↑ ▬
RR: ↑ ▬ ▬
│ │ │
└────┴────┘
Complete Cycle
Characteristics:
- Duty factor: 0.5 (50% contact, 50% swing)
- Stability: 2-point support during swing phase
- Speed: Faster but less stable than walking
For smooth horizontal leg motion during swing phase:
y(step) = y_origin + (step_width/2) · (cos(θ) - direction) · direction
Where:
θ = step · π / (STEP_COUNT - 1)(normalized phase [0, π])direction: +1 for forward, -1 for backward
Properties:
- Zero velocity at endpoints (smooth start/stop)
- Maximum velocity at midpoint
- Continuous acceleration profile
- Minimizes mechanical stress
For vertical leg lift:
z(step) = Z_ORIGIN - STEP_HEIGHT · (step / (STEP_COUNT - 1))
Properties:
- Constant velocity vertical motion
- Simple computation
- Adequate for small vertical displacements (20 mm)
Static stability requires the center of mass projection to remain within the support polygon.
Support Polygon: Convex hull of all feet in contact with ground.
Stability Margin:
margin = min(distance(CoM_projection, support_polygon_edge))
For stable walking:
- Walking gait: margin > 0 (3-point support)
- Trotting gait: margin > 0 (2-point support, more critical)
Dynamic stability is maintained through:
- Gait selection: Choose gait based on speed/stability tradeoff
- Center of gravity offset: Adjusted based on movement direction
- Forward: CoG offset = -15 to -17 mm
- Backward: CoG offset = +8 mm
- IMU feedback: PID control for roll/pitch compensation
For dynamic stability, the Zero Moment Point should remain within the support polygon:
ZMP = CoM - (CoM_height / g) · CoM_acceleration
Where:
CoM: Center of mass positiong: Gravitational acceleration (9.81 m/s²)CoM_acceleration: Acceleration of center of mass
- Franklin, G. F., Powell, J. D., & Workman, M. L. (1998). Digital Control of Dynamic Systems (3rd ed.). Addison-Wesley. Chapter 4: PID Control.
- Siciliano, B., et al. (2009). Robotics: Modelling, Planning and Control. Springer. Chapter 8: Motion Control.
- Vukobratović, M., & Borovac, B. (2004). Zero-moment point—thirty five years of its life. International Journal of Humanoid Robotics, 1(1), 157-173.