Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
speedharm-cli Namespace Reference

Functions

def print_response (resp)
 
def unknown_command (cmd)
 
def process_set_command (parts)
 
def process_get_command (parts)
 
def process_delete_command (parts)
 
def cd (new_url)
 
def process_cd_command (parts)
 
def process_post_command (parts)
 
def process_create_vehicle ()
 
def process_create_experiment ()
 
def process_create_algorithm ()
 
def process_create_command (parts)
 
def select_vehicle ()
 
def process_assign_experiment ()
 
def process_assign_algorithm ()
 
def process_assign_command (parts)
 
def process_list_vehicles ()
 
def process_list_experiments ()
 
def process_list_algorithms ()
 
def process_list_command (parts)
 
def process_fetch_command (parts)
 
def parse_input (cmd)
 
def get_cur_url ()
 
def main ()
 

Variables

string version_id = "v0.1"
 
bool running = True
 
string base_url = "http://35.153.64.44:8081"
 
string rel_url = ""
 
string vehicles_url = "/rest/vehicles"
 
string experiments_url = "/rest/experiments"
 
string algorithms_url = "/rest/algorithms"
 

Function Documentation

◆ cd()

def speedharm-cli.cd (   new_url)

Definition at line 73 of file speedharm-cli.py.

73def cd(new_url):
74 global rel_url
75 rel_url = urlparse.urljoin(rel_url, new_url)
76
def cd(new_url)

Referenced by process_cd_command().

Here is the caller graph for this function:

◆ get_cur_url()

def speedharm-cli.get_cur_url ( )

Definition at line 279 of file speedharm-cli.py.

279def get_cur_url():
280 return urlparse.urljoin(base_url, rel_url)
281

Referenced by main(), process_delete_command(), process_get_command(), and process_post_command().

Here is the caller graph for this function:

◆ main()

def speedharm-cli.main ( )

Definition at line 282 of file speedharm-cli.py.

282def main():
283 print("Speed Harmonization Command Line Configurator " + version_id + ".")
284 while running:
285 parse_input(raw_input(get_cur_url() + ">> "))
286
def parse_input(cmd)

References get_cur_url(), main(), and parse_input().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_input()

def speedharm-cli.parse_input (   cmd)
Parse the command input and execute the appropriate action

Definition at line 232 of file speedharm-cli.py.

232def parse_input(cmd):
233 """
234 Parse the command input and execute the appropriate action
235 """
236
237 parts = cmd.split(' ') # Split on spaces
238
239 args = {"set" : "variable value", "get" : "[url]", "cd" : "rel_url",
240 "post" : "data", "delete" : "[url]", "create" : "(vehicle | experiment | algorithm)",
241 "assign" : "(experiment | algorithm)", "list" : "(vehicle | experiment | algorithm)",
242 "fetch" : "(vehicle | experiment | algorithm) id", "help": "", "exit" : ""}
243
244 try:
245 if parts[0] == "exit":
246 global running
247 running = False
248 exit(0)
249 elif parts[0] == "set":
251 elif parts[0] == "get":
253 elif parts[0] == "cd":
254 process_cd_command(parts)
255 elif parts[0] == "post":
257 elif parts[0] == "delete":
259 elif parts[0] == "create":
261 elif parts[0] == "assign":
263 elif parts[0] == "list":
265 elif parts[0] == "fetch":
267 elif parts[0] == "help":
268 print("Commands: ")
269 for cmd, usage in args.items():
270 print("{} {}".format(cmd, usage))
271 else:
272 unknown_command(cmd)
273 except IndexError:
274 print("Incorrect usage of: " + parts[0])
275 print("Usage: " + parts[0] + " " + args[parts[0]])
276 except requests.exceptions.ConnectionError:
277 print("Unable to connect to " + base_url + ".")
278
def unknown_command(cmd)
def process_delete_command(parts)
def process_get_command(parts)
def process_assign_command(parts)
def process_fetch_command(parts)
def process_create_command(parts)
def process_set_command(parts)
def process_list_command(parts)
def process_cd_command(parts)
def process_post_command(parts)

References process_assign_command(), process_cd_command(), process_create_command(), process_delete_command(), process_fetch_command(), process_get_command(), process_list_command(), process_post_command(), process_set_command(), and unknown_command().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_response()

def speedharm-cli.print_response (   resp)

Definition at line 40 of file speedharm-cli.py.

40def print_response(resp):
41 try:
42 print(resp.status_code)
43 print(resp.headers)
44 print(resp.json())
45 except:
46 print("Unable to decode the rest of the response.")
47
def print_response(resp)

Referenced by process_assign_algorithm(), process_assign_experiment(), process_create_algorithm(), process_create_experiment(), process_create_vehicle(), process_delete_command(), process_fetch_command(), process_get_command(), and process_post_command().

Here is the caller graph for this function:

◆ process_assign_algorithm()

def speedharm-cli.process_assign_algorithm ( )

Definition at line 162 of file speedharm-cli.py.

163 veh_id = select_vehicle()
164
165 r = requests.get(urlparse.urljoin(base_url, algorithms_url), verify=False).json()
166
167 print("Select Algorithm: ")
168 for exp in r:
169 print("{}. Class: {}".format(exp["id"], exp["className"]))
170 algo_id = raw_input("Algorithm ID#? ")
171
172 headers = { "Content-Type" : "application/json" }
173 data = json.dumps({"id": int(veh_id)})
174
175 r = requests.post(urlparse.urljoin(base_url, algorithms_url + "/" + algo_id + "/vehicles"), data=data, headers=headers, verify=False)
177
def process_assign_algorithm()
def select_vehicle()

References print_response(), and select_vehicle().

Referenced by process_assign_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_assign_command()

def speedharm-cli.process_assign_command (   parts)

Definition at line 178 of file speedharm-cli.py.

178def process_assign_command(parts):
179 if parts[1] == "experiment":
181 elif parts[1] == "algorithm":
183 else:
184 print("Unknown relationship to assign: " + parts[1])
185
186
def process_assign_experiment()

References process_assign_algorithm(), and process_assign_experiment().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_assign_experiment()

def speedharm-cli.process_assign_experiment ( )

Definition at line 146 of file speedharm-cli.py.

147 veh_id = select_vehicle()
148
149 r = requests.get(urlparse.urljoin(base_url, experiments_url), verify=False).json()
150
151 print("Select Experiment: ")
152 for exp in r:
153 print("{}. Description: {}; Location: {}".format(exp["id"], exp["description"], exp["location"]))
154 exp_id = raw_input("Experiment ID#? ")
155
156 headers = { "Content-Type" : "application/json" }
157 data = json.dumps({"id": int(veh_id)})
158
159 r = requests.post(urlparse.urljoin(base_url, experiments_url + "/" + exp_id + "/vehicles"), data=data, headers=headers, verify=False)
161

References print_response(), and select_vehicle().

Referenced by process_assign_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_cd_command()

def speedharm-cli.process_cd_command (   parts)

Definition at line 77 of file speedharm-cli.py.

77def process_cd_command(parts):
78 cd(parts[1])
79

References cd().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_create_algorithm()

def speedharm-cli.process_create_algorithm ( )

Definition at line 110 of file speedharm-cli.py.

111 # Get the available algorithms
112 r = requests.get(urlparse.urljoin(base_url, "/rest/"), verify=False)
113 algos = r.json()["availableAlgorithms"]
114 print("Select Algorithm: ")
115 for a in zip(algos, range(len(algos))):
116 print("{}. {}".format(a[1] + 1, a[0]))
117
118 idx = input("Choice #? ") - 1
119
120 full_url = urlparse.urljoin(base_url, algorithms_url)
121 headers = { "Content-Type" : "application/json" }
122 data = json.dumps({"className": algos[idx]})
123
124 r = requests.post(full_url, data=data, headers=headers, verify=False)
126
def process_create_algorithm()

References print_response().

Referenced by process_create_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_create_command()

def speedharm-cli.process_create_command (   parts)

Definition at line 127 of file speedharm-cli.py.

127def process_create_command(parts):
128 if parts[1] == "vehicle":
130 elif parts[1] == "experiment":
132 elif parts[1] == "algorithm":
134 else:
135 print("Unknown entity to create: " + parts[1])
136
def process_create_vehicle()
def process_create_experiment()

References process_create_algorithm(), process_create_experiment(), and process_create_vehicle().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_create_experiment()

def speedharm-cli.process_create_experiment ( )

Definition at line 102 of file speedharm-cli.py.

103 description = raw_input("Experiment Description: ")
104 location = raw_input("Experiment Location: ")
105 full_url = urlparse.urljoin(base_url, experiments_url)
106 headers = { "Content-Type" : "application/json" }
107 r = requests.post(full_url, data=json.dumps({"description": description, "location": location}), headers=headers, verify=False)
109

References print_response().

Referenced by process_create_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_create_vehicle()

def speedharm-cli.process_create_vehicle ( )

Definition at line 94 of file speedharm-cli.py.

95 uniqVehId = raw_input("Unique Vehicle ID: ")
96 description = raw_input("Vehicle Description: ")
97 full_url = urlparse.urljoin(base_url, vehicles_url)
98 headers = { "Content-Type" : "application/json" }
99 r = requests.post(full_url, data=json.dumps({"uniqVehId": uniqVehId, "description": description}), headers=headers, verify=False)
101

References print_response().

Referenced by process_create_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_delete_command()

def speedharm-cli.process_delete_command (   parts)

Definition at line 63 of file speedharm-cli.py.

63def process_delete_command(parts):
64 full_url = get_cur_url()
65 if (len(parts) > 1):
66 full_url = urlparse.urljoin(full_url, parts[1])
67
68 ack = raw_input("Are you sure you want to delete " + full_url +"?\n(y/N): ")
69 if ack.lower() == "y":
70 r = requests.delete(full_url, verify=False)
72

References get_cur_url(), and print_response().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_fetch_command()

def speedharm-cli.process_fetch_command (   parts)

Definition at line 218 of file speedharm-cli.py.

218def process_fetch_command(parts):
219 if parts[1] == "vehicle":
220 full_url = urlparse.urljoin(base_url, vehicles_url)
221 elif parts[1] == "experiment":
222 full_url = urlparse.urljoin(base_url, experiments_url)
223 elif parts[1] == "algorithm":
224 full_url = urlparse.urljoin(base_url, algorithms_url)
225 else:
226 print("Unknown entity to fetch: " + parts[1])
227 return
228
229 r = requests.get(full_url + "/" + parts[2], verify=False)
231

References print_response().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_get_command()

def speedharm-cli.process_get_command (   parts)

Definition at line 54 of file speedharm-cli.py.

54def process_get_command(parts):
55 full_url = get_cur_url()
56 if (len(parts) > 1):
57 # A url has been specified
58 full_url = urlparse.urljoin(full_url, parts[1])
59
60 r = requests.get(full_url, verify=False)
62

References get_cur_url(), and print_response().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_list_algorithms()

def speedharm-cli.process_list_algorithms ( )

Definition at line 201 of file speedharm-cli.py.

202 r = requests.get(urlparse.urljoin(base_url, algorithms_url), verify=False).json()
203
204 print("Algorithms:")
205 for veh in r:
206 print("{}. ClassName: {}".format(veh["id"], veh["className"]))
207
def process_list_algorithms()

Referenced by process_list_command().

Here is the caller graph for this function:

◆ process_list_command()

def speedharm-cli.process_list_command (   parts)

Definition at line 208 of file speedharm-cli.py.

208def process_list_command(parts):
209 if parts[1] == "vehicles":
211 elif parts[1] == "experiments":
213 elif parts[1] == "algorithms":
215 else:
216 print("Unknown entity to list: " + parts[1])
217
def process_list_vehicles()
def process_list_experiments()

References process_list_algorithms(), process_list_experiments(), and process_list_vehicles().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_list_experiments()

def speedharm-cli.process_list_experiments ( )

Definition at line 194 of file speedharm-cli.py.

195 r = requests.get(urlparse.urljoin(base_url, experiments_url), verify=False).json()
196
197 print("Experiments:")
198 for veh in r:
199 print("{}. Description: {}; Location: {}".format(veh["id"], veh["description"], veh["location"]))
200

Referenced by process_list_command().

Here is the caller graph for this function:

◆ process_list_vehicles()

def speedharm-cli.process_list_vehicles ( )

Definition at line 187 of file speedharm-cli.py.

188 r = requests.get(urlparse.urljoin(base_url, vehicles_url), verify=False).json()
189
190 print("Vehicles:")
191 for veh in r:
192 print("{}. Description: {}; Unique ID: {}".format(veh["id"], veh["description"], veh["uniqVehId"]))
193

Referenced by process_list_command().

Here is the caller graph for this function:

◆ process_post_command()

def speedharm-cli.process_post_command (   parts)

Definition at line 80 of file speedharm-cli.py.

80def process_post_command(parts):
81 data_start = 1
82 full_url = get_cur_url()
83 # if len(parts) > 2:
84 # data_start = 2
85 # full_url = urlparse.urljoin(full_url, parts[1])
86
87 data = eval(" ".join(parts[data_start:]))
88
89 headers = { "Content-Type" : "application/json" }
90
91 r = requests.post(full_url, data=json.dumps(data), headers=headers, verify=False)
93

References get_cur_url(), and print_response().

Referenced by parse_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_set_command()

def speedharm-cli.process_set_command (   parts)

Definition at line 51 of file speedharm-cli.py.

51def process_set_command(parts):
52 exec("global " + parts[1] + ";" + parts[1] + " = " + parts[2])
53

Referenced by parse_input().

Here is the caller graph for this function:

◆ select_vehicle()

def speedharm-cli.select_vehicle ( )

Definition at line 137 of file speedharm-cli.py.

137def select_vehicle():
138 r = requests.get(urlparse.urljoin(base_url, vehicles_url), verify=False).json()
139
140 print("Select Vehicle:")
141 for veh in r:
142 print("{}. Description: {}; Unique ID: {}".format(veh["id"], veh["description"], veh["uniqVehId"]))
143
144 return raw_input("Vehicle ID#? ")
145

Referenced by process_assign_algorithm(), and process_assign_experiment().

Here is the caller graph for this function:

◆ unknown_command()

def speedharm-cli.unknown_command (   cmd)

Definition at line 48 of file speedharm-cli.py.

48def unknown_command(cmd):
49 print(cmd + " is not a recognized command. Try \"help\" for help.")
50

Referenced by parse_input().

Here is the caller graph for this function:

Variable Documentation

◆ algorithms_url

string speedharm-cli.algorithms_url = "/rest/algorithms"

Definition at line 37 of file speedharm-cli.py.

◆ base_url

string speedharm-cli.base_url = "http://35.153.64.44:8081"

Definition at line 30 of file speedharm-cli.py.

◆ experiments_url

string speedharm-cli.experiments_url = "/rest/experiments"

Definition at line 36 of file speedharm-cli.py.

◆ rel_url

string speedharm-cli.rel_url = ""

Definition at line 32 of file speedharm-cli.py.

◆ running

bool speedharm-cli.running = True

Definition at line 29 of file speedharm-cli.py.

◆ vehicles_url

string speedharm-cli.vehicles_url = "/rest/vehicles"

Definition at line 35 of file speedharm-cli.py.

◆ version_id

string speedharm-cli.version_id = "v0.1"

Definition at line 28 of file speedharm-cli.py.