File size: 1,613 Bytes
5eb1bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
 * SO-100 specific configuration for web calibration
 * Matches Node.js SO-100 config structure and Python lerobot exactly
 */

/**
 * STS3215 Protocol Configuration for SO-100 devices
 */
export const WEB_STS3215_PROTOCOL = {
  resolution: 4096, // 12-bit resolution (0-4095)
  homingOffsetAddress: 31, // Address for Homing_Offset register
  homingOffsetLength: 2, // 2 bytes for Homing_Offset
  presentPositionAddress: 56, // Address for Present_Position register
  presentPositionLength: 2, // 2 bytes for Present_Position
  minPositionLimitAddress: 9, // Address for Min_Position_Limit register
  minPositionLimitLength: 2, // 2 bytes for Min_Position_Limit
  maxPositionLimitAddress: 11, // Address for Max_Position_Limit register
  maxPositionLimitLength: 2, // 2 bytes for Max_Position_Limit
  signMagnitudeBit: 11, // Bit 11 is sign bit for Homing_Offset encoding
} as const;

/**
 * SO-100 Device Configuration
 * Motor names, IDs, and drive modes for both follower and leader
 */
export const SO100_CONFIG = {
  motorNames: [
    "shoulder_pan",
    "shoulder_lift",
    "elbow_flex",
    "wrist_flex",
    "wrist_roll",
    "gripper",
  ],
  motorIds: [1, 2, 3, 4, 5, 6],
  // Python lerobot uses drive_mode=0 for all SO-100 motors
  driveModes: [0, 0, 0, 0, 0, 0],
};

/**
 * Create SO-100 calibration configuration
 */
export function createSO100Config(
  deviceType: "so100_follower" | "so100_leader"
) {
  return {
    deviceType,
    motorNames: SO100_CONFIG.motorNames,
    motorIds: SO100_CONFIG.motorIds,
    driveModes: SO100_CONFIG.driveModes,
    protocol: WEB_STS3215_PROTOCOL,
  };
}