|
|
|
@ -6,6 +6,10 @@ import time
@@ -6,6 +6,10 @@ import time
|
|
|
|
|
import logging |
|
|
|
|
import readline |
|
|
|
|
import yaml |
|
|
|
|
try: |
|
|
|
|
from yaml import CLoader as YamlLoader, CDumper as YamlDumper |
|
|
|
|
except ImportError: |
|
|
|
|
from yaml import YamlLoader, YamlDumper |
|
|
|
|
import types |
|
|
|
|
|
|
|
|
|
from ugv import UGVComms |
|
|
|
@ -87,9 +91,9 @@ class UGV_CLI:
@@ -87,9 +91,9 @@ class UGV_CLI:
|
|
|
|
|
log.info("set target to (%f, %f)", lat, long) |
|
|
|
|
|
|
|
|
|
@cli_cmd(names=["set_config", "sc"], description="Load configuration from config.yml and send") |
|
|
|
|
def set_config(self): |
|
|
|
|
with open('./tools/config.yml', 'r') as configfile: |
|
|
|
|
config = yaml.load(configfile) |
|
|
|
|
def set_config(self, config_file_name="./tools/config.yml"): |
|
|
|
|
with open(config_file_name, 'r') as configfile: |
|
|
|
|
config = yaml.load(configfile, Loader=YamlLoader) |
|
|
|
|
|
|
|
|
|
if 'REVISION' in config: |
|
|
|
|
config_rev = config['REVISION'] |
|
|
|
@ -170,12 +174,15 @@ class UGV_CLI:
@@ -170,12 +174,15 @@ class UGV_CLI:
|
|
|
|
|
stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, |
|
|
|
|
timeout=0.5) |
|
|
|
|
|
|
|
|
|
readline.parse_and_bind("tab: complete") |
|
|
|
|
readline.set_completer(self.complete_command) |
|
|
|
|
|
|
|
|
|
self.ugv = UGVComms(ser, self.on_msg_received) |
|
|
|
|
self.ugv.start() |
|
|
|
|
time.sleep(0.2) |
|
|
|
|
|
|
|
|
|
def run_cli(self): |
|
|
|
|
if self.ugv is None: |
|
|
|
|
self.start() |
|
|
|
|
|
|
|
|
|
readline.parse_and_bind("tab: complete") |
|
|
|
|
readline.set_completer(self.complete_command) |
|
|
|
|
last_line = None |
|
|
|
|
try: |
|
|
|
|
print("Run 'help' to find out what commands are available") |
|
|
|
@ -217,4 +224,4 @@ if __name__ == "__main__":
@@ -217,4 +224,4 @@ if __name__ == "__main__":
|
|
|
|
|
logging.basicConfig( |
|
|
|
|
format='%(asctime)s [%(name)s] %(levelname)s: %(message)s', datefmt='%Y-%b-%d %H:%M:%S') |
|
|
|
|
logging.getLogger().setLevel(logging.INFO) |
|
|
|
|
UGV_CLI().start() |
|
|
|
|
UGV_CLI().run_cli() |
|
|
|
|