実際のところ
{
"xarm_ip": "192.168.1.100",
"max_value_x": 500,
"min_value_x": -500,
"max_value_y": 500,
"min_value_y": -500,
"max_value_z": 500,
"min_value_z": -500,
"speed": 100
}
import json
import streamlit as st
from xarm import version
from xarm.wrapper import XArmAPI
with open("config.json") as f:
config = json.load(f)
xarm_ip = config["xarm_ip"]
arm = XArmAPI(xarm_ip)
arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)
_, init_pose = arm.get_position()
init_x, init_y, init_z, init_rx, init_ry, init_rz = init_pose
st.title("xArm Control using Streamlit")
st.header("Position Control")
x = st.slider("X (mm)", min_value=config["min_value_x"], max_value=config["max_value_x"], value=int(init_x), step=1)
y = st.slider("Y (mm)", min_value=config["min_value_y"], max_value=config["max_value_y"], value=int(init_y), step=1)
z = st.slider("Z (mm)", min_value=config["min_value_z"], max_value=config["max_value_z"], value=int(init_z), step=1)
new_pose = [x, y, z, init_rx, init_ry, init_rz]
arm.set_position(*new_pose, speed=config["speed"], wait=True)
if st.button("Reset"):
arm.set_position(*init_pose, speed=config["speed"], wait=True)
arm.set_state(0)