smartpi 0.1.38__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.
- smartpi/__init__.py +8 -0
- smartpi/_gui.py +66 -0
- smartpi/base_driver.py +566 -0
- smartpi/camera.py +84 -0
- smartpi/color_sensor.py +18 -0
- smartpi/cw2015.py +179 -0
- smartpi/flash.py +130 -0
- smartpi/humidity.py +20 -0
- smartpi/led.py +19 -0
- smartpi/light_sensor.py +72 -0
- smartpi/motor.py +177 -0
- smartpi/move.py +218 -0
- smartpi/onnx_hand_workflow.py +201 -0
- smartpi/onnx_image_workflow.py +176 -0
- smartpi/onnx_pose_workflow.py +482 -0
- smartpi/onnx_text_workflow.py +173 -0
- smartpi/onnx_voice_workflow.py +437 -0
- smartpi/posemodel/__init__.py +0 -0
- smartpi/posemodel/posenet.tflite +0 -0
- smartpi/posenet_utils.py +222 -0
- smartpi/rknn_hand_workflow.py +245 -0
- smartpi/rknn_image_workflow.py +405 -0
- smartpi/rknn_pose_workflow.py +592 -0
- smartpi/rknn_text_workflow.py +240 -0
- smartpi/rknn_voice_workflow.py +394 -0
- smartpi/servo.py +178 -0
- smartpi/temperature.py +18 -0
- smartpi/text_gte_model/__init__.py +0 -0
- smartpi/text_gte_model/config/__init__.py +0 -0
- smartpi/text_gte_model/config/config.json +30 -0
- smartpi/text_gte_model/config/quantize_config.json +30 -0
- smartpi/text_gte_model/config/special_tokens_map.json +7 -0
- smartpi/text_gte_model/config/tokenizer.json +14924 -0
- smartpi/text_gte_model/config/tokenizer_config.json +23 -0
- smartpi/text_gte_model/config/vocab.txt +14760 -0
- smartpi/text_gte_model/gte/__init__.py +0 -0
- smartpi/text_gte_model/gte/gte_model.onnx +0 -0
- smartpi/touch_sensor.py +16 -0
- smartpi/trace.py +120 -0
- smartpi/ultrasonic.py +20 -0
- smartpi-0.1.38.dist-info/METADATA +17 -0
- smartpi-0.1.38.dist-info/RECORD +44 -0
- smartpi-0.1.38.dist-info/WHEEL +5 -0
- smartpi-0.1.38.dist-info/top_level.txt +1 -0
smartpi/servo.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
#С������� port:����P�˿ڣ�angle:�Ƕ�0~270��
|
|
7
|
+
def steer_angle(port:bytes,angle:bytes) -> Optional[bytes]:
|
|
8
|
+
servo_str=[0xA0, 0x0E, 0x01, 0x71, 0x00, 0xBE]
|
|
9
|
+
servo_str[0]=0XA0+port
|
|
10
|
+
servo_str[4]=angle
|
|
11
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
12
|
+
time.sleep(0.005)
|
|
13
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
14
|
+
# if response == None:
|
|
15
|
+
# return None
|
|
16
|
+
# else:
|
|
17
|
+
return 0
|
|
18
|
+
|
|
19
|
+
#С�����ʱ���� port:����P�˿ڣ�angle:�Ƕ�0~270��second:1~256
|
|
20
|
+
def steer_angle_delay(port:bytes,angle:bytes,second:bytes) -> Optional[bytes]:
|
|
21
|
+
servo_str=[0xA0, 0x10, 0x01, 0x81, 0x00, 0x00, 0x81, 0x00, 0xBE]
|
|
22
|
+
servo_str[0]=0XA0+port
|
|
23
|
+
servo_str[4]=angle//256
|
|
24
|
+
servo_str[5]=angle%256
|
|
25
|
+
servo_str[7]=second
|
|
26
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
27
|
+
time.sleep(0.005)
|
|
28
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
29
|
+
# if response == None:
|
|
30
|
+
# return None
|
|
31
|
+
# else:
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
#���ֶ������ת������(���ԽǶ�) port:����P�˿ڣ�dir:0:����Խ0��;1:��̾�����ת;2:˳ʱ����ת;3:��ʱ����ת
|
|
35
|
+
def set_dir(port:bytes,dir:bytes) -> Optional[bytes]:
|
|
36
|
+
servo_str=[0xA0, 0x24, 0x01, 0x71, 0x00, 0xBE]
|
|
37
|
+
servo_str[0]=0XA0+port
|
|
38
|
+
servo_str[4]=dir
|
|
39
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
40
|
+
time.sleep(0.005)
|
|
41
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
42
|
+
# if response == None:
|
|
43
|
+
# return None
|
|
44
|
+
# else:
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
#BE-9528���ֶ�����ٶ�ת���Ƕ� port:����P�˿ڣ�angle:�Ƕ�(0~360)��speed:�ٶ�(0~100)��
|
|
48
|
+
def set_angle_speed(port:bytes,angle:bytes,speed:bytes) -> Optional[bytes]:
|
|
49
|
+
servo_str=[0xA0, 0x0D, 0x01, 0x81, 0x00, 0x00, 0x81, 0x00, 0xBE]
|
|
50
|
+
servo_str[0]=0XA0+port
|
|
51
|
+
servo_str[4]=angle//256
|
|
52
|
+
servo_str[5]=angle%256
|
|
53
|
+
servo_str[7]=speed
|
|
54
|
+
#response = base_driver.single_operate_sensor(servo_str,0)
|
|
55
|
+
time.sleep(0.005)
|
|
56
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
57
|
+
# if response == None:
|
|
58
|
+
# return None
|
|
59
|
+
# else:
|
|
60
|
+
return 0
|
|
61
|
+
|
|
62
|
+
#���ֶ��ת�����Ƕ���ʱʱ�� port:����P�˿ڣ�angle:�Ƕ�(0~360)��ms:��ʱʱ��(0~65535)��
|
|
63
|
+
def set_angle_ms(port:bytes,angle:bytes,ms:int) -> Optional[bytes]:
|
|
64
|
+
servo_str=[0xA0, 0x11, 0x01, 0x81, 0x00, 0x00, 0x81, 0x00, 0x00, 0xBE]
|
|
65
|
+
servo_str[0]=0XA0+port
|
|
66
|
+
servo_str[4]=angle//256
|
|
67
|
+
servo_str[5]=angle%256
|
|
68
|
+
servo_str[7]=ms//256
|
|
69
|
+
servo_str[8]=ms%256
|
|
70
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
71
|
+
time.sleep(0.005)
|
|
72
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
73
|
+
# if response == None:
|
|
74
|
+
# return None
|
|
75
|
+
# else:
|
|
76
|
+
return 0
|
|
77
|
+
|
|
78
|
+
#���ֶ����λ port:����P�˿ڣ�
|
|
79
|
+
def set_init(port:bytes) -> Optional[bytes]:
|
|
80
|
+
servo_str=[0xA0, 0x12, 0x01, 0xBE]
|
|
81
|
+
servo_str[0]=0XA0+port
|
|
82
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
83
|
+
time.sleep(0.005)
|
|
84
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
85
|
+
# if response == None:
|
|
86
|
+
# return None
|
|
87
|
+
# else:
|
|
88
|
+
return 0
|
|
89
|
+
|
|
90
|
+
#��ȡ���ֶ���Ƕ� port:����P�˿ڣ�
|
|
91
|
+
def get_angle(port:bytes) -> Optional[bytes]:
|
|
92
|
+
servo_str=[0xA0, 0x13, 0x01, 0xBE]
|
|
93
|
+
servo_str[0]=0XA0+port
|
|
94
|
+
time.sleep(0.005)
|
|
95
|
+
response = base_driver.single_operate_sensor(servo_str,0)
|
|
96
|
+
if response == None:
|
|
97
|
+
return None
|
|
98
|
+
else:
|
|
99
|
+
angle_data=response[4:-1]
|
|
100
|
+
angle_num=int.from_bytes(angle_data, byteorder='big', signed=True)
|
|
101
|
+
return angle_num
|
|
102
|
+
|
|
103
|
+
#���ֶ���ٶ�ת�� port:����P�˿ڣ�
|
|
104
|
+
def set_speed(port:bytes,speed:int) -> Optional[bytes]:
|
|
105
|
+
servo_str=[0xA0, 0x14, 0x01, 0x71, 0x00, 0xBE]
|
|
106
|
+
servo_str[0]=0XA0+port
|
|
107
|
+
if speed>100:
|
|
108
|
+
m_par=100
|
|
109
|
+
elif speed>=0 and speed<=100:
|
|
110
|
+
m_par=speed
|
|
111
|
+
elif speed<-100:
|
|
112
|
+
m_par=156
|
|
113
|
+
elif speed<=0 and speed>=-100:
|
|
114
|
+
m_par=256+speed
|
|
115
|
+
|
|
116
|
+
servo_str[4]=m_par
|
|
117
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
118
|
+
time.sleep(0.005)
|
|
119
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
120
|
+
# if response == None:
|
|
121
|
+
# return None
|
|
122
|
+
# else:
|
|
123
|
+
return 0
|
|
124
|
+
|
|
125
|
+
#���ֶ������ת�� port:����P�˿ڣ�code:����(0~65535)��speed:�ٶ�(-100~100)��
|
|
126
|
+
def set_code_speed(port:bytes,code:int,speed:int) -> Optional[bytes]:
|
|
127
|
+
servo_str=[0xA0, 0x15, 0x01, 0x81, 0x00, 0x00, 0x71, 0x00, 0xBE]
|
|
128
|
+
servo_str[0]=0XA0+port
|
|
129
|
+
|
|
130
|
+
servo_str[4]=code//256
|
|
131
|
+
servo_str[5]=code%256
|
|
132
|
+
|
|
133
|
+
if speed>100:
|
|
134
|
+
m_par=100
|
|
135
|
+
elif speed>=0 and speed<=100:
|
|
136
|
+
m_par=speed
|
|
137
|
+
elif speed<-100:
|
|
138
|
+
m_par=156
|
|
139
|
+
elif speed<=0 and speed>=-100:
|
|
140
|
+
m_par=256+speed
|
|
141
|
+
servo_str[7]=m_par
|
|
142
|
+
|
|
143
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
144
|
+
time.sleep(0.005)
|
|
145
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
146
|
+
# if response == None:
|
|
147
|
+
# return None
|
|
148
|
+
# else:
|
|
149
|
+
return 0
|
|
150
|
+
|
|
151
|
+
#���ֶ������ֵ���� port:����P�˿ڣ�
|
|
152
|
+
def reset_encode(port:bytes) -> Optional[bytes]:
|
|
153
|
+
servo_str=[0xA0, 0x16, 0x01, 0xBE]
|
|
154
|
+
servo_str[0]=0XA0+port
|
|
155
|
+
# response = base_driver.single_operate_sensor(servo_str,0)
|
|
156
|
+
time.sleep(0.005)
|
|
157
|
+
base_driver.write_data(0X01, 0X02, servo_str)
|
|
158
|
+
# if response == None:
|
|
159
|
+
# return None
|
|
160
|
+
# else:
|
|
161
|
+
return 0
|
|
162
|
+
|
|
163
|
+
#��ȡ���ֶ������ֵ port:����P�˿ڣ�
|
|
164
|
+
def get_encoder(port:bytes) -> Optional[bytes]:
|
|
165
|
+
servo_str=[0xA0, 0x17, 0x01, 0xBE]
|
|
166
|
+
servo_str[0]=0XA0+port
|
|
167
|
+
time.sleep(0.005)
|
|
168
|
+
response = base_driver.single_operate_sensor(servo_str,0)
|
|
169
|
+
if response == None:
|
|
170
|
+
return None
|
|
171
|
+
else:
|
|
172
|
+
code_data=response[4:-1]
|
|
173
|
+
code_num=int.from_bytes(code_data, byteorder='big', signed=True)
|
|
174
|
+
return code_num
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
smartpi/temperature.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#�¶ȶ�ȡ port:����P�˿ڣ��������أ��¶�����; ��ȡ����-1
|
|
8
|
+
def get_value(port:bytes) -> Optional[bytes]:
|
|
9
|
+
temp_str=[0XA0, 0X0C, 0X01, 0X71, 0X00, 0XBE]
|
|
10
|
+
temp_str[0]=0XA0+port
|
|
11
|
+
temp_str[4]=0
|
|
12
|
+
time.sleep(0.005)
|
|
13
|
+
response = base_driver.single_operate_sensor(temp_str,0)
|
|
14
|
+
if response == None:
|
|
15
|
+
return None
|
|
16
|
+
else:
|
|
17
|
+
return response[4]
|
|
18
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_name_or_path": "thenlper/gte-small-zh",
|
|
3
|
+
"architectures": [
|
|
4
|
+
"BertModel"
|
|
5
|
+
],
|
|
6
|
+
"attention_probs_dropout_prob": 0.1,
|
|
7
|
+
"classifier_dropout": null,
|
|
8
|
+
"directionality": "bidi",
|
|
9
|
+
"hidden_act": "gelu",
|
|
10
|
+
"hidden_dropout_prob": 0.1,
|
|
11
|
+
"hidden_size": 512,
|
|
12
|
+
"initializer_range": 0.02,
|
|
13
|
+
"intermediate_size": 2048,
|
|
14
|
+
"layer_norm_eps": 1e-12,
|
|
15
|
+
"max_position_embeddings": 512,
|
|
16
|
+
"model_type": "bert",
|
|
17
|
+
"num_attention_heads": 8,
|
|
18
|
+
"num_hidden_layers": 6,
|
|
19
|
+
"pad_token_id": 0,
|
|
20
|
+
"pooler_fc_size": 768,
|
|
21
|
+
"pooler_num_attention_heads": 12,
|
|
22
|
+
"pooler_num_fc_layers": 3,
|
|
23
|
+
"pooler_size_per_head": 128,
|
|
24
|
+
"pooler_type": "first_token_transform",
|
|
25
|
+
"position_embedding_type": "absolute",
|
|
26
|
+
"transformers_version": "4.33.2",
|
|
27
|
+
"type_vocab_size": 2,
|
|
28
|
+
"use_cache": true,
|
|
29
|
+
"vocab_size": 21128
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"per_channel": true,
|
|
3
|
+
"reduce_range": true,
|
|
4
|
+
"per_model_config": {
|
|
5
|
+
"model": {
|
|
6
|
+
"op_types": [
|
|
7
|
+
"Erf",
|
|
8
|
+
"Softmax",
|
|
9
|
+
"Shape",
|
|
10
|
+
"Unsqueeze",
|
|
11
|
+
"ReduceMean",
|
|
12
|
+
"Sub",
|
|
13
|
+
"Transpose",
|
|
14
|
+
"Mul",
|
|
15
|
+
"Pow",
|
|
16
|
+
"Cast",
|
|
17
|
+
"Gather",
|
|
18
|
+
"Reshape",
|
|
19
|
+
"MatMul",
|
|
20
|
+
"Slice",
|
|
21
|
+
"Div",
|
|
22
|
+
"Sqrt",
|
|
23
|
+
"Constant",
|
|
24
|
+
"Add",
|
|
25
|
+
"Concat"
|
|
26
|
+
],
|
|
27
|
+
"weight_type": "QInt8"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|