ArtusAPI 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ArtusAPI might be problematic. Click here for more details.
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
commands/commands.py,sha256=J-f2owJgD2Pj5o9I7SwFagAFKxZjSuhhYIZydK4cgNc,2867
|
|
3
|
+
ArtusAPI-0.1.0.dist-info/METADATA,sha256=C-y1S2KD0qENYKL6C35dbcdmlBSLX1HHccw-YxuoZZY,100
|
|
4
|
+
ArtusAPI-0.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
5
|
+
ArtusAPI-0.1.0.dist-info/top_level.txt,sha256=6dNUbRvZAy7fLWNbD4YeUosLYwGk-SVew-Swd5CfFkg,9
|
|
6
|
+
ArtusAPI-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
commands
|
commands/__init__.py
ADDED
|
File without changes
|
commands/commands.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
import time
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
# Current file's directory
|
|
8
|
+
current_file_path = Path(__file__).resolve()
|
|
9
|
+
# Add the desired path to the system path
|
|
10
|
+
desired_path = current_file_path.parent.parent
|
|
11
|
+
sys.path.append(str(desired_path))
|
|
12
|
+
print(desired_path)
|
|
13
|
+
|
|
14
|
+
class Commands:
|
|
15
|
+
|
|
16
|
+
def __init__(self):
|
|
17
|
+
|
|
18
|
+
# commands
|
|
19
|
+
with open(os.path.join(desired_path,'commands',"commands.json")) as file:
|
|
20
|
+
self.commands = json.load(file)
|
|
21
|
+
|
|
22
|
+
def get_robot_start_command(self,stream:bool,freq:int) -> list:
|
|
23
|
+
"""
|
|
24
|
+
Creates a message to start the hand
|
|
25
|
+
"""
|
|
26
|
+
# RTC start time from PC
|
|
27
|
+
year = int(time.localtime().tm_year - 2000)
|
|
28
|
+
month = int(time.localtime().tm_mon)
|
|
29
|
+
day = int(time.localtime().tm_mday)
|
|
30
|
+
hour = int(time.localtime().tm_hour)
|
|
31
|
+
minute = int(time.localtime().tm_min)
|
|
32
|
+
second = int(time.localtime().tm_sec)
|
|
33
|
+
|
|
34
|
+
if stream:
|
|
35
|
+
return [self.commands['start_command'],20,year,month,day,hour,minute,second,1,(freq>>16)&0xff,(freq>>8)&0xff,freq&0xff]
|
|
36
|
+
else:
|
|
37
|
+
return [self.commands['start_command'],20,year,month,day,hour,minute,second]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_target_position_command(self,hand_joints:dict) -> list:
|
|
41
|
+
command_list = [0]*32 # create empty buffer
|
|
42
|
+
# fill command list with data
|
|
43
|
+
for name,joint_data in hand_joints.items():
|
|
44
|
+
command_list[joint_data.index] = joint_data.target_angle
|
|
45
|
+
command_list[joint_data.index+16] = joint_data.velocity
|
|
46
|
+
# insert the command
|
|
47
|
+
command_list.insert(0,self.commands['target_command'])
|
|
48
|
+
|
|
49
|
+
return command_list
|
|
50
|
+
|
|
51
|
+
def get_calibration_command(self):
|
|
52
|
+
command_list = [0]*32
|
|
53
|
+
command_list.insert(0,self.commands['calibration_command'])
|
|
54
|
+
return command_list
|
|
55
|
+
|
|
56
|
+
def get_sleep_command(self):
|
|
57
|
+
command_list = [0]*32
|
|
58
|
+
command_list.insert(0,self.commands['sleep_command'])
|
|
59
|
+
return command_list
|
|
60
|
+
|
|
61
|
+
def get_states_command(self):
|
|
62
|
+
command_list = [0]*32
|
|
63
|
+
command_list.insert(0,self.commands['get_feedback_command'])
|
|
64
|
+
return command_list
|
|
65
|
+
|
|
66
|
+
def get_firmware_update_command(self):
|
|
67
|
+
command_list = [0]*32
|
|
68
|
+
command_list.insert(0,self.commands['firmware_update_command'])
|
|
69
|
+
return command_list
|
|
70
|
+
|
|
71
|
+
def get_locked_reset_low_command(self, joint=None, motor=None):
|
|
72
|
+
command_list = [0]*32
|
|
73
|
+
command_list.insert(0,self.commands['reset_command'])
|
|
74
|
+
|
|
75
|
+
# constraint checker
|
|
76
|
+
if 0 <= joint <= 15:
|
|
77
|
+
command_list[0] = joint
|
|
78
|
+
else:
|
|
79
|
+
# TODO logging
|
|
80
|
+
None
|
|
81
|
+
if 0 <= motor <= 2:
|
|
82
|
+
command_list[1] = motor
|
|
83
|
+
else:
|
|
84
|
+
# TODO logging
|
|
85
|
+
None
|
|
86
|
+
|
|
87
|
+
return command_list
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
None
|