-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample_01.py
More file actions
279 lines (193 loc) · 8.36 KB
/
sample_01.py
File metadata and controls
279 lines (193 loc) · 8.36 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#####################################################################################
#
# Sample 01 - This sample presents the basic Function of the SDK.
#
# Python 3.5.2
#
# SDK 3dRudder
#
# Copyright (C) 2016-2017 3dRudder
#
#####################################################################################
import sys
import time
import platform
# 32 or 64 bit
val_max=platform.architecture()
print(val_max[0])
if (val_max[0]=='32bit') :
from win32.Python363.ns3DRudder import * #import SDk 3dRudder
else:
from x64.Python363.ns3DRudder import * #import SDk 3dRudder
#define the Status of the 3dRudder
status_3dRudder = [ "None",
"Puts the 3DRudder on the floor",
"The 3dRudder initialize for about 2 seconds",
"Put your first feet on the 3dRudder",
"Put your second Foot on the 3dRudder",
"The user must wait still for half a second for calibration until a last short beep is heard from the device. The 3DRudder is ready to be used.",
"The 3dRudder is in use",
"The 3dRudder is in use and is fully operational with all the features enabled"
]
#####################################################################################
#####################################################################################
def OptionNomalized():
#Get Axis Value NormalizedValue
sdk.GetAxis(0,NormalizedValue,axis)
print ("Axis NormalizedValue Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(axis.m_aX,axis.m_aY,axis.m_aZ,axis.m_rZ))
#####################################################################################
#####################################################################################
def OptionUserRefAngle():
#Get Axis Value UserRefAngle
sdk.GetAxis(0,UserRefAngle,axis)
print ("Axis UserRefAngle Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(axis.m_aX,axis.m_aY,axis.m_aZ,axis.m_rZ))
#####################################################################################
#####################################################################################
def OptionCustomerCurves():
#Get Axis Value ValueWithCurve
curves=CurveArray()
#curves.InitLinear()
#roll
roll=Curve()
roll.SetDeadZone(50.0)
roll.SeXSat(1.0)
roll.SetYMax(1.0)
roll.SetExp(3.0)
curves.SetCurve(CurveRoll,roll)
#pitch
pitch=Curve()
pitch.SetDeadZone(50.0)
pitch.SeXSat(1.0)
pitch.SetYMax(1.0)
pitch.SetExp(3.0)
curves.SetCurve(CurvePitch,pitch)
#upDown
upDown=Curve()
upDown.SetDeadZone(50.0)
upDown.SeXSat(1.0)
upDown.SetYMax(1.0)
upDown.SetExp(3.0)
curves.SetCurve(CurveUpDown,upDown)
#yaw
yaw=Curve()
yaw.SetDeadZone(50.0)
yaw.SeXSat(1.0)
yaw.SetYMax(1.0)
yaw.SetExp(3.0)
curves.SetCurve(CurveYaw,yaw)
sdk.GetAxis(0,ValueWithCurve,axis,curves)
print ("Axis ValueWithCurve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(axis.m_aX,axis.m_aY,axis.m_aZ,axis.m_rZ))
#####################################################################################
#####################################################################################
def OptionSetLinearCurves():
#Get Axis Value ValueWithCurve
curves=CurveArray()
curves.InitLinear()
sdk.GetAxis(0,ValueWithCurve,axis,curves)
print ("Axis ValueWithCurve - Linear Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(axis.m_aX,axis.m_aY,axis.m_aZ,axis.m_rZ))
#####################################################################################
#####################################################################################
def OptionSetFactoryCurves():
#Get Axis Value ValueWithCurve
curves=CurveArray()
curves.InitFactory()
sdk.GetAxis(0,ValueWithCurve,axis,curves)
print ("Axis ValueWithCurve - Factory Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(axis.m_aX,axis.m_aY,axis.m_aZ,axis.m_rZ))
#####################################################################################
#####################################################################################
def OptionGetParamsCurves():
#yaw=Curve()
#pitch=Curve()
#roll=Curve()
#upDown=Curve()
#curves=CurveArray()
sdk.GetAxis(0,NormalizedValue,axis)
curves=CurveArray()
roll = curves.GetCurve(CurveRoll)
yaw = curves.GetCurve(CurveYaw)
pitch = curves.GetCurve(CurvePitch)
upDown = curves.GetCurve(CurveUpDown)
#Get Curve Value Yaw
#print ("Yaw Curve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(yaw.GetDeadZone(),yaw.GeXSat(),yaw.GetYMax(),yaw.GetExp()))
print ("Yaw Curve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(yaw.GetDeadZone(),yaw.GeXSat(),yaw.GetYMax(),yaw.GetExp()))
#Get Curve Value Pitch
print ("Pitch Curve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(pitch.GetDeadZone(),pitch.GeXSat(),pitch.GetYMax(),pitch.GetExp()))
#Get Curve Value Roll
print ("Roll Curve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(roll.GetDeadZone(),roll.GeXSat(),roll.GetYMax(),roll.GetExp()))
#Get Curve Value UpDown
print ("UpDown Curve Value : [{:.2f},{:.2f},{:.2f},{:.2f}]".format(upDown.GetDeadZone(),upDown.GeXSat(),upDown.GetYMax(),upDown.GetExp()))
#####################################################################################
#####################################################################################
def OptionDisplaySensors():
#Get sensor value
print ("Sensor Value : [{:d},{:d},{:d},{:d},{:d},{:d}] ".format(sdk.GetSensor( nPortNumber ,0 ),sdk.GetSensor( nPortNumber , 1 ),sdk.GetSensor( nPortNumber , 2 ),sdk.GetSensor( nPortNumber , 3 ),sdk.GetSensor( nPortNumber , 4 ),sdk.GetSensor( nPortNumber , 5 )))
#####################################################################################
# Main
#####################################################################################
print ("Start Sample.py")
print ("------------------------")
#Init
try:
#Init SDk 3dRudder
sdk=GetSDK()
sdk.Init()
# 3dRudder 1
nPortNumber=0
#Check that the 3dRudder 1 is connected
while not sdk.IsDeviceConnected (nPortNumber):
print("3dRudder is not Connected")
time.sleep(1)
#Get Version of The Firmware
version=sdk.GetVersion(nPortNumber)
print ("Version FirmWare : {:1x}".format(version))
#Get the number of the 3dRudder are connected
print ("Get the Number of the 3dRudder are connected : {:1x}".format(sdk.GetNumberOfConnectedDevice()))
#Play a sound wih the 3dRudder
sdk.PlaySnd(nPortNumber,1000,1000)
# Wait 3dRudder initialized
while(sdk.GetStatus(nPortNumber)<2):
print("3drudder init...")
time.sleep(1)
except KeyboardInterrupt as e:
print ("->Stop by User")
except ValueError as err:
print ("Error : ",err )
icontinue=1
while(icontinue==1):
try:
# Select type curve 3drudder
print("Select type curve 3drudder")
print("1- NormalizedValue")
print("2- UserRefAngle")
print("3- ValueWithCurve (NormalizedValue)")
print("4- ValueWithCurve / Lineaire Curves (NormalizedValue)")
print("5- ValueWithCurve / Factory Curves (NormalizedValue)")
print("6- Get Params Curves")
print("7- Display Sensors Value")
ch = input()
nn = int(ch)
options= { 1:OptionNomalized,
2:OptionUserRefAngle,
3:OptionCustomerCurves,
4:OptionSetLinearCurves,
5:OptionSetFactoryCurves,
6:OptionGetParamsCurves,
7:OptionDisplaySensors
}
axis = Axis()
while True:
#Get Status of the 3dRudder
print ("*****************************************************************")
print ("Status 3dRudder : {:1} ".format(status_3dRudder[sdk.GetStatus(nPortNumber)]))
options[nn]()
time.sleep(1) #second
except KeyboardInterrupt as e:
print ("->Stop by User")
except ValueError as err:
print ("Error : ",err )
finally:
print("Continue Sample ? (1/0)")
ch = input()
icontinue = int(ch)
print ("------------------------")
print ("End Sample.py")