Help with the leg coordinate system

I am trying to set up some custom poses for the PiCrawler and having some issues with the coordinate system. There are 2 main things I don’t really understand, how would I do something like have it stick 1 leg straight up? OR curled under the main body? Please see attached photos for examples.

Joint Definitions (using a single leg as an example):

  • Joint 1 (Coxa): Leg rotation “forward/backward” around the body (horizontal plane).
  • Joint 2 (Femur): Leg “up/down swing” (vertical plane, determines leg lift height).
  • Joint 3 (Tibia): Shank “bend/extension” (determines overall leg extension).

Angle Reference:
The “neutral position” (0° or midpoint) for all joints is the robot’s default standing posture.

Key Constraint:
Each servo has a physical rotation limit (typically within ±90°; avoid exceeding to prevent burnout).

Controlling a Single Leg to Extend Straight Upward
Refer to posture control examples in picrawler/examples and write custom code (core involves calling the Leg class angle setting interface):

from picrawler import PiCrawler
import time

# Initialize robot (default uses Robot Hat servo driver)
robot = PiCrawler()

# Define angles for "single leg extended straight up" (using right front leg as example, can be replaced)
# Joint 1 (Coxa): 0° (neutral, no swing)
# Joint 2 (Femur): +60° (swing up to max safe angle, adjust based on calibration)
# Joint 3 (Tibia): -30° (fully extended; test actual sign, core is to straighten shank)
straight_up_angles = [0, 60, -30]  # [Joint1, Joint2, Joint3]

# Control right front leg (leg_id=0; IDs for 6 legs: 0=right front, 1=left front, 2=right middle, 3=left middle, 4=right back, 5=left back)
robot.legs[0].set_angles(straight_up_angles, duration=1.0)  # duration=1 second for transition
time.sleep(2)  # Hold for 2 seconds

# Restore default standing posture
robot.reset()

Steps to Configure “Single Leg Curled Under the Body”:
Make the target leg’s Joint 2 swing down (close to body), Joint 3 bend (shank curls inward), and Joint 1 stay neutral or slightly inward.

from picrawler import PiCrawler
import time

robot = PiCrawler()

# Define angles for "curled under the body" (right front leg example)
# Joint 1: 0° (neutral, or -10° to bring leg inward)
# Joint 2: -45° (swing down, close to body)
# Joint 3: +45° (shank bends, curls inward)
curl_under_angles = [0, -45, 45]

# Control right front leg to curl
robot.legs[0].set_angles(curl_under_angles, duration=1.0)
time.sleep(2)

# Restore default posture
robot.reset()

That isn’t how my crawler is working from EZblock studio, is there a difference in how it is implemented there?

The core difference between them is in the mapping rules for angle parameters and the encapsulation method of the underlying control interface, not the joint logic of the hardware itself.

If you want to use Python code to control the PiCrawler, it is recommended to install the Raspberry Pi system and then install all the library codes on the system.

Link: https://docs.sunfounder.com/projects/pi-crawler/en/latest/python/python_start/install_all_modules.html

Afterward, you can write your custom code to control it and observe the working results.

Understood. I ended up finding that the way to accomplish this with EZBlock is to use individual servo controls.

I also noticed in EZBlock there is a module to control a LED, is there a guide anywhere on how to mount a LED module onto the Robot Hat v4?

Sorry we do not have ready-to-use code for reference; you will need to write the program yourself.

We can provide you with the documentation for the Robot HAT:

Digital IO (Digital Interface)
For single-color LED (on/off or brightness adjustment) and colorful LED modules, refer to the “Pinout” and “Digital IO” sections of the documentation.

PWM Interface
For LEDs requiring brightness gradient or breathing effects, refer to the “PWM” section and “class PWM” in the documentation.

Dedicated RGB LED Class
For onboard or external RGB LED modules, refer to the “class RGB_LED” section of the documentation.