Skip to content

Commit

Permalink
fix(abr-testing): unify all script compatibility with same ip file (#…
Browse files Browse the repository at this point in the history
…16922)

# Overview

Ensures data collection scripts can all use the same IPs.json file when
connecting to robots

---------

Co-authored-by: rclarke0 <[email protected]>
  • Loading branch information
AnthonyNASC20 and rclarke0 authored Nov 21, 2024
1 parent ead4491 commit da74897
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def run(
ip_json_file = os.path.join(storage_directory, "IPs.json")
try:
ip_file = json.load(open(ip_json_file))
robot_dict = ip_file.get("ip_address_list")
except FileNotFoundError:
print(f"Add .json file with robot IPs to: {storage_directory}.")
sys.exit()
Expand All @@ -294,7 +295,7 @@ def run(
ip_or_all = input("IP Address or ALL: ")
calibration_data = []
if ip_or_all.upper() == "ALL":
ip_address_list = ip_file["ip_address_list"]
ip_address_list = list(robot_dict.keys())
for ip in ip_address_list:
saved_file_path, calibration = read_robot_logs.get_calibration_offsets(
ip, storage_directory
Expand Down
3 changes: 2 additions & 1 deletion abr-testing/abr_testing/data_collection/get_run_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ def get_all_run_logs(
ip_json_file = os.path.join(storage_directory, "IPs.json")
try:
ip_file = json.load(open(ip_json_file))
robot_dict = ip_file.get("ip_address_list")
except FileNotFoundError:
print(f"Add .json file with robot IPs to: {storage_directory}.")
sys.exit()
ip_address_list = ip_file["ip_address_list"]
ip_address_list = list(robot_dict.keys())
runs_from_storage = read_robot_logs.get_run_ids_from_google_drive(google_drive)
for ip in ip_address_list:
runs = get_run_ids_from_robot(ip)
Expand Down
12 changes: 5 additions & 7 deletions hardware-testing/hardware_testing/scripts/ABRAsairScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import paramiko as pmk
import time
import json
import multiprocessing
from typing import Optional, List, Any

Expand Down Expand Up @@ -69,11 +70,10 @@ def run(file_name: str) -> List[Any]:
robot_ips = []
robot_names = []
with open(file_name) as file:
for line in file.readlines():
info = line.split(",")
if "Y" in info[2]:
robot_ips.append(info[0])
robot_names.append(info[1])
file_dict = json.load(file)
robot_dict = file_dict.get("ip_address_list")
robot_ips = list(robot_dict.keys())
robot_names = list(robot_dict.values())
print("Executing Script on All Robots:")
# Launch the processes for each robot.
processes = []
Expand All @@ -89,10 +89,8 @@ def run(file_name: str) -> List[Any]:
# Wait for all processes to finish.
file_name = sys.argv[1]
processes = run(file_name)

for process in processes:
process.start()
time.sleep(20)

for process in processes:
process.join()

0 comments on commit da74897

Please sign in to comment.