Skip to content

Commit b00d15f

Browse files
committed
Don't make the test implementations nodes
1 parent cf76401 commit b00d15f

14 files changed

+97
-61
lines changed

clearpath_tests/clearpath_tests/all_tests.py

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ def __init__(self, node_name='clearpath_production_test_node'):
7777
self.platform = self.clearpath_config.get_platform_model()
7878

7979
self.common_tests = [
80-
mcu_test.McuTestNode(setup_path=self.setup_path),
81-
diagnostic_test.DiagnosticTestNode(self.setup_path),
82-
wifi_test.WifiTestNode(self.setup_path),
80+
mcu_test.McuTestNode(self, setup_path=self.setup_path),
81+
diagnostic_test.DiagnosticTestNode(self, self.setup_path),
82+
wifi_test.WifiTestNode(self, self.setup_path),
8383
]
8484

8585
self.driving_tests = [
8686
drive_test.DriveTestNode(
87+
self,
8788
setup_path=self.setup_path,
8889
default_speed_x=0.1,
8990
direction='Forwards',
@@ -93,62 +94,71 @@ def __init__(self, node_name='clearpath_production_test_node'):
9394
# Add any platform-specific tests here
9495
self.tests_for_platform = []
9596
if self.platform == Platform.A200:
96-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear', self.setup_path))
97+
self.tests_for_platform.append(estop_test.EstopTestNode(self, 'Rear', self.setup_path))
9798
elif self.platform == Platform.A300:
98-
self.tests_for_platform.append(fan_test.FanTestNode(4, self.setup_path))
99-
self.tests_for_platform.append(light_test.LightTestNode(4, self.setup_path))
99+
self.tests_for_platform.append(fan_test.FanTestNode(self, 4, self.setup_path))
100+
self.tests_for_platform.append(light_test.LightTestNode(self, 4, self.setup_path))
100101

101-
self.tests_for_platform.append(estop_test.EstopTestNode('Front', self.setup_path))
102-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear', self.setup_path))
102+
self.tests_for_platform.append(
103+
estop_test.EstopTestNode(self, 'Front', self.setup_path)
104+
)
105+
self.tests_for_platform.append(
106+
estop_test.EstopTestNode(self, 'Rear', self.setup_path)
107+
)
103108
self.tests_for_platform.append(
104109
# rear access hatch should also act as an e-stop
105-
estop_test.EstopTestNode('Access Panel', self.setup_path)
110+
estop_test.EstopTestNode(self, 'Access Panel', self.setup_path)
106111
)
107112
self.tests_for_platform.append(
108113
# wireless e-stop is optional on A300
109114
estop_test.EstopTestNode('Wireless', self.setup_path, optional=True)
110115
)
111116

112-
self.tests_for_platform.append(imu_test.ImuTestNode(0, self.setup_path))
117+
self.tests_for_platform.append(imu_test.ImuTestNode(self, 0, self.setup_path))
113118

114119
# vcan0 has the 4 motor drivers
115120
# check for status messages, which are length 5 and more numerous
116-
self.tests_for_platform.append(canbus_test.CanbusTestNode('vcan0', 4, 5, self.setup_path)) # noqa: E501
121+
self.tests_for_platform.append(canbus_test.CanbusTestNode(self, 'vcan0', 4, 5, self.setup_path)) # noqa: E501
117122

118123
# vcan1 has batteries, optional e-stop, optional wireless charger
119124
# so just allow anything here
120-
self.tests_for_platform.append(canbus_test.CanbusTestNode('vcan1', 0, 0, self.setup_path)) # noqa: E501
125+
self.tests_for_platform.append(canbus_test.CanbusTestNode(self, 'vcan1', 0, 0, self.setup_path)) # noqa: E501
121126

122127
# Dynamic IMU tests
123128
self.driving_tests.insert(0, rotation_test.RotationTestNode(
129+
self,
124130
setup_path=self.setup_path
125131
))
126132
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
133+
self,
127134
setup_path=self.setup_path
128135
))
129136
elif (
130137
self.platform == Platform.DD100 or
131138
self.platform == Platform.DD150
132139
):
133-
self.tests_for_platform.append(light_test.LightTestNode(4, self.setup_path))
140+
self.tests_for_platform.append(light_test.LightTestNode(self, 4, self.setup_path))
134141

135142
# Dingo doesn't use CANopen, so the ID counter won't work correctly
136-
self.tests_for_platform.append(canbus_test.CanbusTestNode('vcan0', 0, 4, self.setup_path)) # noqa: E501
143+
self.tests_for_platform.append(canbus_test.CanbusTestNode(self, 'vcan0', 0, 4, self.setup_path)) # noqa: E501
137144

138145
self.tests_for_platform.append(estop_test.EstopTestNode(
146+
self,
139147
'Rear',
140148
setup_path=self.setup_path,
141149
estop_type='Motor Cutoff',
142150
))
143151

144152
# Dingo has an integral IMU
145-
self.tests_for_platform.append(imu_test.ImuTestNode(setup_path=self.setup_path))
153+
self.tests_for_platform.append(imu_test.ImuTestNode(self, setup_path=self.setup_path))
146154

147155
# Dynamic IMU tests
148156
self.driving_tests.insert(0, rotation_test.RotationTestNode(
157+
self,
149158
setup_path=self.setup_path
150159
))
151160
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
161+
self,
152162
setup_path=self.setup_path
153163
))
154164
elif (
@@ -158,27 +168,31 @@ def __init__(self, node_name='clearpath_production_test_node'):
158168
self.tests_for_platform.append(light_test.LightTestNode(4, self.setup_path))
159169

160170
# Dingo doesn't use CANopen, so the ID counter won't work correctly
161-
self.tests_for_platform.append(canbus_test.CanbusTestNode('vcan0', 0, 4, self.setup_path)) # noqa: E501
171+
self.tests_for_platform.append(canbus_test.CanbusTestNode(self, 'vcan0', 0, 4, self.setup_path)) # noqa: E501
162172

163173
self.tests_for_platform.append(estop_test.EstopTestNode(
174+
self,
164175
'Rear',
165176
setup_path=self.setup_path,
166177
estop_type='Motor Cutoff',
167178
))
168179

169180
# Dingo has an integral IMU
170-
self.tests_for_platform.append(imu_test.ImuTestNode(setup_path=self.setup_path))
181+
self.tests_for_platform.append(imu_test.ImuTestNode(self, setup_path=self.setup_path))
171182

172183
# Dynamic IMU tests
173184
self.driving_tests.insert(0, rotation_test.RotationTestNode(
185+
self,
174186
setup_path=self.setup_path
175187
))
176188
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
189+
self,
177190
setup_path=self.setup_path
178191
))
179192

180193
self.driving_tests.append(
181194
drive_test.DriveTestNode(
195+
self,
182196
setup_path=self.setup_path,
183197
default_speed_x=0.0,
184198
default_speed_y=0.2,
@@ -189,42 +203,53 @@ def __init__(self, node_name='clearpath_production_test_node'):
189203
elif self.platform == Platform.GENERIC:
190204
pass
191205
elif self.platform == Platform.J100:
192-
self.tests_for_platform.append(imu_test.ImuTestNode(0, self.setup_path))
206+
self.tests_for_platform.append(imu_test.ImuTestNode(self, 0, self.setup_path))
193207

194208
self.tests_for_platform.append(estop_test.EstopTestNode(
209+
self,
195210
'Rear',
196211
setup_path=self.setup_path,
197212
estop_type='Motor Cutoff',
198213
))
199214

200215
# Dynamic IMU tests
201216
self.driving_tests.insert(0, rotation_test.RotationTestNode(
217+
self,
202218
setup_path=self.setup_path
203219
))
204220
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
221+
self,
205222
setup_path=self.setup_path
206223
))
207224
elif self.platform == Platform.R100:
208-
self.tests_for_platform.append(light_test.LightTestNode(8))
225+
self.tests_for_platform.append(light_test.LightTestNode(self, 8))
209226

210227
# Ridgeback doesn't use CANopen, so the ID counter won't work correctly
211-
self.tests_for_platform.append(canbus_test.CanbusTestNode('vcan0', 0, 4, self.setup_path)) # noqa: E501
228+
self.tests_for_platform.append(
229+
canbus_test.CanbusTestNode(self, 'vcan0', 0, 4, self.setup_path))
212230

213-
self.tests_for_platform.append(estop_test.EstopTestNode('Front Left', self.setup_path))
214-
self.tests_for_platform.append(estop_test.EstopTestNode('Front Right', self.setup_path)) # noqa: E501
215-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear Left', self.setup_path))
216-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear Right', self.setup_path))
231+
self.tests_for_platform.append(
232+
estop_test.EstopTestNode(self, 'Front Left', self.setup_path))
233+
self.tests_for_platform.append(
234+
estop_test.EstopTestNode(self, 'Front Right', self.setup_path))
235+
self.tests_for_platform.append(
236+
estop_test.EstopTestNode(self, 'Rear Left', self.setup_path))
237+
self.tests_for_platform.append(
238+
estop_test.EstopTestNode(self, 'Rear Right', self.setup_path))
217239

218240
# Dynamic IMU tests
219241
self.driving_tests.insert(0, rotation_test.RotationTestNode(
242+
self,
220243
setup_path=self.setup_path
221244
))
222245
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
246+
self,
223247
setup_path=self.setup_path
224248
))
225249

226250
self.driving_tests.append(
227251
drive_test.DriveTestNode(
252+
self,
228253
setup_path=self.setup_path,
229254
default_speed_x=0.0,
230255
default_speed_y=0.2,
@@ -233,19 +258,25 @@ def __init__(self, node_name='clearpath_production_test_node'):
233258
)
234259
)
235260
elif self.platform == Platform.W200:
236-
self.tests_for_platform.append(light_test.LightTestNode(4))
237-
self.tests_for_platform.append(canbus_test.CanbusTestNode('can0', 4, 0, self.setup_path)) # noqa: E501
261+
self.tests_for_platform.append(light_test.LightTestNode(self, ))
262+
self.tests_for_platform.append(canbus_test.CanbusTestNode(self, 'can0', 4, 0, self.setup_path)) # noqa: E501
238263

239-
self.tests_for_platform.append(estop_test.EstopTestNode('Front Left', self.setup_path))
240-
self.tests_for_platform.append(estop_test.EstopTestNode('Front Right', self.setup_path)) # noqa: E501
241-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear Left', self.setup_path))
242-
self.tests_for_platform.append(estop_test.EstopTestNode('Rear Right', self.setup_path))
264+
self.tests_for_platform.append(
265+
estop_test.EstopTestNode(self, 'Front Left', self.setup_path))
266+
self.tests_for_platform.append(
267+
estop_test.EstopTestNode(self, 'Front Right', self.setup_path))
268+
self.tests_for_platform.append(
269+
estop_test.EstopTestNode(self, 'Rear Left', self.setup_path))
270+
self.tests_for_platform.append(
271+
estop_test.EstopTestNode(self, 'Rear Right', self.setup_path))
243272

244273
# Dynamic IMU tests
245274
self.driving_tests.insert(0, rotation_test.RotationTestNode(
275+
self,
246276
setup_path=self.setup_path
247277
))
248278
self.driving_tests.insert(0, linear_acceleration_test.LinearAccelerationTestNode(
279+
self,
249280
setup_path=self.setup_path
250281
))
251282
else:

clearpath_tests/clearpath_tests/canbus_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ class CanbusTestNode(ClearpathTestNode):
4040

4141
def __init__(
4242
self,
43+
node,
4344
can_interface='',
4445
n_devices=0,
4546
expected_msg_length=0,
4647
setup_path='/etc/clearpath'
4748
):
4849
super().__init__(
49-
'CAN',
50-
f'canbus_test_{can_interface}',
51-
setup_path
50+
node=node,
51+
test_name='CAN',
52+
setup_path=setup_path,
5253
)
5354

5455
self.can_interface = self.get_parameter_or('can_interface', can_interface)

clearpath_tests/clearpath_tests/diagnostic_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@
139139
class DiagnosticTestNode(ClearpathTestNode):
140140
"""Monitors diagnostic topics to make sure there aren't any warnings."""
141141

142-
def __init__(self, setup_path='/etc/clearpath'):
143-
super().__init__('Diagnostics', 'diagnostic_test', setup_path)
142+
def __init__(self, node=None, setup_path='/etc/clearpath'):
143+
super().__init__(node, 'Diagnostics', setup_path)
144144
self.test_in_progress = False
145145
self.warnings = {}
146146
self.errors = {}

clearpath_tests/clearpath_tests/drive_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ class DriveTestNode(MobilityTestNode):
5050

5151
def __init__(
5252
self,
53+
node=None,
5354
setup_path='/etc/clearpath',
5455
direction='Forwards',
5556
default_speed_x=0.1, # 10cm/s; nice and safe
5657
default_speed_y=0.0,
5758
default_distance=5.0,
5859
):
5960
super().__init__(
61+
node,
6062
f'Drive Fixed Distance ({direction})',
61-
f'drive_test_{direction.lower()}',
6263
setup_path,
6364
)
6465

clearpath_tests/clearpath_tests/estop_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ class EstopTestNode(ClearpathTestNode):
4444

4545
def __init__(
4646
self,
47+
node,
4748
estop_location,
4849
setup_path='/etc/clearpath',
4950
optional=False,
5051
estop_type='E-Stop',
5152
):
5253
super().__init__(
54+
node,
5355
f'{estop_type} ({estop_location})',
54-
f'estop_test_{estop_location.strip().lower().replace(" ", "_").replace("-", "_")}',
5556
setup_path
5657
)
5758
self.optional = optional

clearpath_tests/clearpath_tests/fan_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737

3838
class FanTestNode(ClearpathTestNode):
3939

40-
def __init__(self, n_fans=4, setup_path='/etc/clearpath'):
41-
super().__init__('Fans', 'fan_test', setup_path)
40+
def __init__(self, node, n_fans=4, setup_path='/etc/clearpath'):
41+
super().__init__(node, 'Fans', setup_path)
4242

4343
# Params
4444
self.n_fans = self.get_parameter_or('num_fans', n_fans)

clearpath_tests/clearpath_tests/imu_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class ImuTestNode(ClearpathTestNode):
5252
Will fail of any of the above is not correct
5353
"""
5454

55-
def __init__(self, imu_num=0, setup_path='/etc/clearpath'):
56-
super().__init__(f'IMU (imu_{imu_num})', f'imu_{imu_num}_test', setup_path)
55+
def __init__(self, node, imu_num=0, setup_path='/etc/clearpath'):
56+
super().__init__(node, f'IMU (imu_{imu_num})', setup_path)
5757
self.test_in_progress = False
5858
self.record_data = False
5959
self.accel_samples = []

clearpath_tests/clearpath_tests/light_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
class LightTestNode(ClearpathTestNode):
4141

42-
def __init__(self, light_zones=4, setup_path='/etc/clearpath'):
43-
super().__init__('Lights', 'light_test', setup_path)
42+
def __init__(self, node, light_zones=4, setup_path='/etc/clearpath'):
43+
super().__init__(node, 'Lights', setup_path)
4444

4545
self.light_zones = self.get_parameter_or('n_lights', light_zones)
4646

clearpath_tests/clearpath_tests/linear_acceleration_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class LinearAccelerationTestNode(MobilityTestNode):
4848
The IMU should read X acceleration of +/- 0.2m/s/s
4949
"""
5050

51-
def __init__(self, imu_num=0, setup_path='/etc/clearpath'):
52-
super().__init__('Linear acceleration', 'linear_acceleration_test', setup_path)
51+
def __init__(self, node, imu_num=0, setup_path='/etc/clearpath'):
52+
super().__init__(node, 'Linear acceleration', setup_path)
5353

5454
self.acceleration = self.get_parameter_or('acceleration', 0.2)
5555
self.acceleration_time = self.get_parameter_or('acceleration_time', 5.0)

clearpath_tests/clearpath_tests/mcu_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class McuTestNode(ClearpathTestNode):
5353

5454
def __init__(
5555
self,
56+
node,
5657
mode=None,
5758
address=None,
5859
setup_path='/etc/clearpath'
@@ -68,8 +69,8 @@ def __init__(
6869
or of the specified mode is not from the given list
6970
"""
7071
super().__init__(
72+
node,
7173
'MCU',
72-
'mcu_test',
7374
setup_path
7475
)
7576

clearpath_tests/clearpath_tests/mobility_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
class MobilityTestNode(ClearpathTestNode):
4444
"""Generic class for all tests that involve driving the robot with odometry feedback."""
4545

46-
def __init__(self, test_name, node_name, setup_path='/etc/clearpath'):
47-
super().__init__(test_name, node_name, setup_path)
46+
def __init__(self, node, test_name, setup_path='/etc/clearpath'):
47+
super().__init__(node, test_name, setup_path)
4848

4949
# The velocity command to output
5050
self.cmd_vel = TwistStamped()

clearpath_tests/clearpath_tests/rotation_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class RotationTestNode(MobilityTestNode):
4949
The IMU should read positive angular velocity around the Z axis.
5050
"""
5151

52-
def __init__(self, imu_num=0, setup_path='/etc/clearpath'):
53-
super().__init__('Rotation in place', 'rotation_test', setup_path)
52+
def __init__(self, node, imu_num=0, setup_path='/etc/clearpath'):
53+
super().__init__(node, 'Rotation in place', setup_path)
5454

5555
self.max_speed = self.get_parameter_or(
5656
'max_speed',

0 commit comments

Comments
 (0)