-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cabb223
commit ed8078a
Showing
3 changed files
with
61 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Use signal handling to break infinite loops | ||
import signal | ||
import sys | ||
from types import FrameType | ||
from typing import Optional | ||
|
||
import serial | ||
|
||
from pyLIDAR.pyLIDAR import main | ||
|
||
|
||
def signal_handler(signal: int, frame: Optional[FrameType]) -> None: | ||
print("\nprogram exiting gracefully") | ||
sys.exit(0) | ||
|
||
|
||
signal.signal(signal.SIGINT, signal_handler) | ||
|
||
# Set up argument parsing | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description="Collect LIDAR data") | ||
parser.add_argument("-p", "--port", required=True, help="serial port") | ||
parser.add_argument("-g", "--graph", action="store_true", help="graph data") | ||
parser.add_argument("-s", "--save", action="store_true", help="save data") | ||
|
||
args = parser.parse_args() | ||
|
||
port: str = args.port | ||
plot: bool = args.graph | ||
save: bool = args.save | ||
|
||
print("Starting LIDAR data collection") | ||
|
||
if port == "test": # Use local server for testing | ||
with serial.serial_for_url("socket://127.0.0.1:8000", timeout=1) as ser: | ||
print("Entered") | ||
main(ser, plot, save) | ||
print("Exited") | ||
else: | ||
# Open serial port connection to LD06 LIDAR | ||
with serial.Serial(port, 230400, timeout=1) as ser: | ||
print("Entered") | ||
main(ser, plot, save) | ||
print("Exited") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters