File size: 579 Bytes
d1d8217
 
 
407b410
d1d8217
 
 
 
 
 
 
407b410
d1d8217
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import re

def parse_action(command: str):
    # Normalize and extract 7 float values (joint angles)
    angle_match = re.findall(r'-?\d+\.\d+', command)
    if len(angle_match) == 7:
        return {
            "type": "move",
            "angles": [float(x) for x in angle_match]
        }

    # Handle specific keywords
    cmd = command.lower()
    if "pick" in cmd:
        return {"type": "pick"}
    if "place" in cmd:
        return {"type": "place"}

    return {"type": "unknown", "message": "Command not recognized. Try 'pick', 'place', or provide 7 joint angles."}