This page covers the sensing side of the SDK:
get_joint_states and callbacksget_motor_states and callbacksget_hand_sensor_image and callbacksHandSensorImage hierarchyJointStatesfrom dexcelbot_apexhand_sdk import DexcelBot
bot = DexcelBot()
# ... connect ...
states = bot.get_joint_states()
print("timestamp:", states.timestamp)
for js in states.joint_states:
print(js.joint_id, js.position, js.velocity, js.acceleration)
JointStates contains:
timestampjoint_states: List[JointState]from dexcelbot_apexhand_sdk import DexcelBot, JointStates, ErrorCode
bot = DexcelBot()
# ... connect ...
def on_joint_states(states: JointStates):
subset = states.joint_states[:3]
for js in subset:
print("[Joint]", js.joint_id, "pos =", js.position)
result = bot.register_joint_states_callback(on_joint_states, freq_hz=100)
if result != ErrorCode.ERROR_CODE_OK:
raise RuntimeError("Failed to register joint states callback")
# ... later ...
bot.unregister_joint_states_callback()
MotorStatesfrom dexcelbot_apexhand_sdk import DexcelBot
bot = DexcelBot()
# ... connect ...
motors = bot.get_motor_states()
print("timestamp:", motors.timestamp)
for ms in motors.motors:
print("[Motor]", ms.motor_id, "T =", ms.temperature, "I =", ms.current)
from dexcelbot_apexhand_sdk import DexcelBot, MotorStates, ErrorCode
bot = DexcelBot()
# ... connect ...
def on_motor_states(states: MotorStates):
overheat = [m for m in states.motors if m.temperature > 60.0]
if overheat:
print("Warning: overheating motors:", [m.motor_id for m in overheat])
result = bot.register_motor_states_callback(on_motor_states, freq_hz=50)
if result != ErrorCode.ERROR_CODE_OK:
raise RuntimeError("Failed to register motor states callback")
# ... later ...
bot.unregister_motor_states_callback()
Motor state callbacks are useful for simple thermal / current monitoring and protective actions (e.g. slow down or stop).
HandSensorImageThe tactile subsystem exposes a hierarchy of structures:
TactileImage:
width, heightgray_image: List[int]tangential_forces: TangentialForceCommonFingerSensorImage / ThumbFingerSensorImage:
TactileImage surfaces such as pip_image, dip_image, tip_imageHandSensorImage:
timestampindex_image, middle_image, ring_image, pinky_imagethumb_imagepalm_imagefrom dexcelbot_apexhand_sdk import DexcelBot
bot = DexcelBot()
# ... connect ...
img = bot.get_hand_sensor_image()
print("timestamp:", img.timestamp)
print("Index PIP size:", img.index_image.pip_image.width, "x", img.index_image.pip_image.height)
print("Palm size:", img.palm_image.width, "x", img.palm_image.height)
You can convert
gray_imageto a NumPy array and visualize or process it using Matplotlib or OpenCV.
from dexcelbot_apexhand_sdk import DexcelBot, ErrorCode
bot = DexcelBot()
# ... connect ...
def on_hand_image(img):
tip = img.thumb_image.tip_image
if tip.width * tip.height == 0:
return
avg_gray = sum(tip.gray_image) / (tip.width * tip.height)
print("Thumb tip avg gray:", avg_gray)
result = bot.register_hand_sensor_image_callback(on_hand_image, freq_hz=30)
if result != ErrorCode.ERROR_CODE_OK:
raise RuntimeError("Failed to register tactile callback")
# ... later ...
bot.unregister_hand_sensor_image_callback()
In practice you can combine callbacks to build a simple monitoring layer:
from dexcelbot_apexhand_sdk import (
DexcelBot,
JointStates,
MotorStates,
ErrorCode,
)
bot = DexcelBot()
# ... connect ...
def on_joint_states(states: JointStates):
if states.joint_states:
js = states.joint_states[0]
print("[Joint]", js.joint_id, "pos =", js.position)
def on_motor_states(states: MotorStates):
for m in states.motors:
if m.temperature > 65.0:
print("!!! Motor overheat:", m.motor_id, m.temperature)
def on_hand_image(img):
palm = img.palm_image
if palm.width * palm.height == 0:
return
avg_gray = sum(palm.gray_image) / (palm.width * palm.height)
if avg_gray > 10:
print("Palm contact detected, avg gray =", avg_gray)
bot.register_joint_states_callback(on_joint_states, freq_hz=100)
bot.register_motor_states_callback(on_motor_states, freq_hz=20)
bot.register_hand_sensor_image_callback(on_hand_image, freq_hz=15)
# ... run your task ...
bot.unregister_joint_states_callback()
bot.unregister_motor_states_callback()
bot.unregister_hand_sensor_image_callback()
With this in place you have full access to kinematic and tactile feedback, which you can then feed into higher‑level control or learning algorithms.