add configure_all_motors.py

This commit is contained in:
apirrone 2025-06-24 13:25:48 +02:00
parent 819a87f7b4
commit 489da82052
2 changed files with 40 additions and 47 deletions

View file

@ -0,0 +1,40 @@
from pypot.feetech import FeetechSTS3215IO
import time
joints = {
"left_hip_yaw": 20,
"left_hip_roll": 21,
"left_hip_pitch": 22,
"left_knee": 23,
"left_ankle": 24,
"neck_pitch": 30,
"head_pitch": 31,
"head_yaw": 32,
"head_roll": 33,
"right_hip_yaw": 10,
"right_hip_roll": 11,
"right_hip_pitch": 12,
"right_knee": 13,
"right_ankle": 14,
}
joints_inv = {v: k for k, v in joints.items()}
ids = list(joints.values())
io = FeetechSTS3215IO("/dev/ttyACM0")
for current_id in ids:
print("Configuring", joints_inv[current_id])
io.set_lock({current_id: 0})
# io.set_mode({current_id: 0})
io.set_maximum_acceleration({current_id: 0})
io.set_acceleration({current_id: 0})
# io.set_maximum_velocity({current_id: 0})
# io.set_goal_speed({current_id: 0})
io.set_P_coefficient({current_id: 32})
io.set_I_coefficient({current_id: 0})
io.set_D_coefficient({current_id: 0})
io.set_lock({current_id: 1})
time.sleep(1)
input("Press any key to set this dof to 0 position ... Or press Ctrl+C to cancel")
io.set_goal_position({current_id: 0})

View file

@ -1,47 +0,0 @@
from openai import OpenAI
import os
import base64
from mini_bdx_runtime.camera import Cam
cam = Cam()
client = OpenAI()
def encode_image(image_path: str):
# check if the image exists
if not os.path.exists(image_path):
raise FileNotFoundError(f"Image file not found: {image_path}")
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")
# response = client.responses.create(
# model="gpt-4o-mini",
# input=[{
# "role": "user",
# "content": [
# {"type": "input_text", "text": "what's in this image?"},
# {
# "type": "input_image",
# "image_url": "http://s-nguyen.net:4444/images/aze.jpg",
# },
# ],
# }],
# )
# image64 = encode_image("/home/antoine/aze.jpg")
image64 = cam.get_encoded_image()
response = client.responses.create(
model="gpt-4o-mini",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": "what's in this image?"},
{
"type": "input_image",
"image_url": "data:image/jpeg;base64,"+image64,
},
],
}],
)
print(response.output_text)