Fix up some python to get run working in vs code.

Also allowed running with python -m car
This commit is contained in:
Piv
2020-04-21 19:53:42 +09:30
parent d3c14f1e0a
commit f44877397c
4 changed files with 30 additions and 3 deletions

21
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "car"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}

4
car/src/car/__main__.py Normal file
View File

@@ -0,0 +1,4 @@
from . import controller
if __name__ == '__main__':
controller.main()

View File

@@ -55,10 +55,12 @@ class CarServer():
return grpc.ssl_server_credentials([[pvtKeyBytes, pvtCertBytes]])
if __name__ == '__main__':
def main():
server = CarServer(vehicle_factory.get_vehicle())
# Can't remember why I do this, is it even needed?
service_thread = Thread(target=server.start_server)
service_thread.start()
if __name__ == '__main__':
main()

View File

@@ -14,7 +14,7 @@ def get_lidar(device=None, connection='/dev/ttyUSB0'):
print(
'No lidar device specified and the CAR_LIDAR environment variable is not set.')
if actual_device == MOCK_DEVICE:
return MockLidar(loader.load_scans_bytes_file("car/tracking/out.pickle"))
return MockLidar(loader.load_scans_bytes_file("car/src/car/tracking/out.pickle"))
elif actual_device == RPLIDAR:
try:
from rplidar import RPLidar