1
1
from XRPLib .defaults import *
2
- from .drive_examples import *
3
- from .misc_examples import *
4
2
import time
5
3
6
4
# Installation Verification Program
7
5
def ivp ():
6
+ # Print welcome message
7
+ print ("------------------------------------------" )
8
+ print ("Running Installation Verification Program!" )
9
+ print ("------------------------------------------" )
10
+ print ()
11
+ print ("Welcome to the XRP! This example code will help" )
12
+ print ("you verify that everything is working on your robot." )
13
+ print ("After each test, press the user button to continue." )
14
+ print ()
15
+
16
+ # Flash LED at 5Hz
17
+ print ("Flashing LED" )
18
+ board .led_blink (5 )
19
+
20
+ # Wait for user to press button
21
+ print ("Press user button to test reflectance sensor" )
22
+ board .wait_for_button ()
23
+
24
+ # Stop blinking LED
25
+ board .led_off ()
26
+
27
+ # Print reflectance values until button is pressed
8
28
while not board .is_button_pressed ():
9
- print (f"Left Reflectance: { reflectance .get_left ()} , Right Reflectance : { reflectance .get_right ()} " )
29
+ print (f"Reflectance Left : { reflectance .get_left ():.3f } Right : { reflectance .get_right ():.3f } Press user button to test range sensor " )
10
30
time .sleep (0.1 )
31
+
32
+ # Wait until button is released
11
33
while board .is_button_pressed ():
12
- time .sleep (.01 )
34
+ time .sleep (0.1 )
35
+
36
+ # Print range values until button is pressed
13
37
while not board .is_button_pressed ():
14
- print (f"Ultrasonic Distance: { rangefinder .distance ()} " )
38
+ print (f"Range Distance: { rangefinder .distance ():.1f } Press user button to test servo " )
15
39
time .sleep (0.1 )
40
+
41
+ # Wait until button is released
16
42
while board .is_button_pressed ():
17
- time .sleep (.01 )
18
- print ("Testing Servo" )
19
- test_servo ()
20
- print ("Testing LEDs" )
43
+ time .sleep (0.1 )
44
+
45
+ # Print warning and wait for button press
46
+ print ()
47
+ print ("The next test will move the servo, so keep your hands clear!" )
48
+ print ("Also please make sure the power switch is turned on!" )
49
+ print ("Press user button to test servo" )
21
50
board .wait_for_button ()
22
- test_leds ()
23
- print ("Testing Drivetrain:" )
51
+
52
+ # Test servo
53
+ print ("Testing servo" )
54
+ time .sleep (1 )
55
+ servo_one .set_angle (90 )
56
+ time .sleep (1 )
57
+ servo_one .set_angle (0 )
58
+ time .sleep (1 )
59
+ servo_one .set_angle (180 )
60
+
61
+ # Print warning and wait for button press
62
+ print ()
63
+ print ("The next test will drive the motors, so place the robot on a flat surface!" )
64
+ print ("Also please make sure the power switch is turned on!" )
65
+ print ("Press user button to test drivetrain" )
24
66
board .wait_for_button ()
25
- test_drive ()
67
+
68
+ # Test drivetrain
69
+ print ("Testing drivetrain" )
70
+ time .sleep (1 )
71
+ drivetrain .straight (25 , 0.8 )
72
+ time .sleep (1 )
73
+ drivetrain .turn (90 ,0.8 )
74
+ time .sleep (1 )
75
+ drivetrain .turn (90 , - 0.8 )
76
+ time .sleep (1 )
77
+ drivetrain .straight (- 25 ,0.8 )
78
+
79
+ print ()
80
+ print ("-----------------------------------" )
81
+ print ("All tests complete! Happy roboting!" )
82
+ print ("-----------------------------------" )
26
83
27
84
ivp ()
0 commit comments