Uh oh!
There was an error while loading. Please reload this page.
forked from bluerobotics/ping-python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping360AutoScan.py
More file actions
Latest commit
65 lines (54 loc) · 1.85 KB
/
Copy pathping360AutoScan.py
File metadata and controls
65 lines (54 loc) · 1.85 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
frombrpingimportdefinitions
frombrpingimportPing360
importtime
importargparse
frombuiltinsimportinput
## Parse Command line options
############################
parser=argparse.ArgumentParser(description="Ping360 auto scan example")
parser.add_argument('--device', action="store", required=False, type=str, help="Ping device port. E.g: /dev/ttyUSB0")
parser.add_argument('--baudrate', action="store", type=int, default=2000000, help="Ping device baudrate. E.g: 115200")
parser.add_argument('--udp', action="store", required=False, type=str, help="Ping UDP server. E.g: 192.168.2.2:9090")
args=parser.parse_args()
ifargs.deviceisNoneandargs.udpisNone:
parser.print_help()
exit(1)
# Make a new Ping360
myPing360=Ping360()
ifargs.deviceisnotNone:
myPing360.connect_serial(args.device, args.baudrate)
elifargs.udpisnotNone:
(host, port) =args.udp.split(':')
myPing360.connect_udp(host, int(port))
ifmyPing360.initialize() isFalse:
print("Failed to initialize Ping!")
exit(1)
print("------------------------------------")
print("Ping360 auto scan..")
print("Press CTRL+C to exit")
print("------------------------------------")
input("Press Enter to continue...")
myPing360.control_auto_transmit(
mode=1,
gain_setting=0,
transmit_duration=80,
sample_period=80,
transmit_frequency=750,
number_of_samples=1024,
start_angle=0,
stop_angle=399,
num_steps=1,
delay=0
)
# Print the scanning head angle
forninrange(400):
m=myPing360.wait_message([definitions.PING360_AUTO_DEVICE_DATA])
ifm:
print(m.angle)
time.sleep(0.001)
# if it is a serial device, reconnect to send a line break
# and stop auto-transmitting
ifargs.deviceisnotNone:
myPing360.connect_serial(args.device, args.baudrate)
# turn the motor off
myPing360.control_motor_off()