Skip to content

Commit

Permalink
Merge pull request #241 from usnistgov/release_1.2_staging
Browse files Browse the repository at this point in the history
Release 1.4
  • Loading branch information
jaybrecht committed May 11, 2023
2 parents 9018aba + f9498bd commit 33d54b9
Show file tree
Hide file tree
Showing 22 changed files with 455 additions and 165 deletions.
1 change: 0 additions & 1 deletion automated_evaluation/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions automated_evaluation/autoEval/read_competitor_config.py

This file was deleted.

3 changes: 0 additions & 3 deletions automated_evaluation/autoEval/runAll.sh

This file was deleted.

12 changes: 0 additions & 12 deletions automated_evaluation/autoEval/runLaunch.sh

This file was deleted.

28 changes: 28 additions & 0 deletions automated_evaluation/build_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [[ ! $1 ]] ; then
echo "Team configuration argument not passed"
exit 1
fi

teamName=$(python3 get_team_name.py $1)

if [[ ! $teamName ]] ; then
echo "Team name not found"
exit 1
fi

# Start the container
docker run -d --name $teamName -p 6080:80 --shm-size=512m jfernandez37/ariac:ariac_latest

# Copy scripts directory and yaml file
docker cp ./scripts/ $teamName:/home/ubuntu
docker cp ./competitor_build_scripts/ $teamName:/home/ubuntu
docker cp ./trials/ $teamName:/home/ubuntu
docker cp ./$1.yaml $teamName:/home/ubuntu/scripts


# Run build script
docker exec -it $teamName bash -c ". /home/ubuntu/scripts/build_environment.sh $1"


3 changes: 3 additions & 0 deletions automated_evaluation/competitor_build_scripts/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Competitor Build Scripts

This folder is for any custom build scripts that competitors would like to be run when the docker container is created. Any scripts must be included by name in the yaml file. These script(s) will be run before the workspace is built.
30 changes: 30 additions & 0 deletions automated_evaluation/get_team_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import sys
import yaml

def main():
# Get yaml file name
if len(sys.argv) <= 1:
exit()

yaml_file = sys.argv[1] + '.yaml'

# Parse yaml file
with open(yaml_file, "r") as stream:
try:
data = yaml.safe_load(stream)
except yaml.YAMLError:
exit()

try:
team_name = data["team_name"]
except KeyError:
exit()

print(team_name)


if __name__=="__main__":
main()

17 changes: 11 additions & 6 deletions automated_evaluation/nist_competitor.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# team configuration for automated evaluation

team_name: ""
team_name: "nist_competitor"

github:
repo_link: "" # remove https
public_access_token: ""
repository: "github.com/jaybrecht/nist_competitor.git"
personal_access_token: "****"

build:
debian_packages: []
pip_packages: []
extra_build_scripts: []

competition:
package_name: ""
sensor_file: ""
launch_file: ""
package_name: "nist_competitor"
launch_file: "competitor.launch.py"

5 changes: 0 additions & 5 deletions automated_evaluation/runDockerTest.sh

This file was deleted.

6 changes: 0 additions & 6 deletions automated_evaluation/runTest.sh

This file was deleted.

21 changes: 21 additions & 0 deletions automated_evaluation/run_trial.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [[ ! $1 ]] ; then
echo "Team configuration argument not passed"
exit 1
fi

if [[ ! $2 ]] ; then
echo "Trial name not specified"
exit 1
fi


teamName=$(python3 get_team_name.py $1)

if [[ ! $teamName ]] ; then
echo "Team name not found"
exit 1
fi

docker exec -it $teamName bash -c ". /home/ubuntu/scripts/run_trial.sh $1 $2"
87 changes: 87 additions & 0 deletions automated_evaluation/scripts/build_competitor_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3

import os
import sys
import subprocess
import yaml


def main():
# Get yaml file name
if len(sys.argv) <= 1:
print("Please include an argument for the yaml file to run")
exit()

yaml_file = sys.argv[1] + '.yaml'
print(f'Running {yaml_file}')

if not os.path.isfile(yaml_file):
print(f'{yaml_file} not found')
exit()

# Parse yaml file
with open(yaml_file, "r") as stream:
try:
data = yaml.safe_load(stream)
except yaml.YAMLError:
print("Unable to parse yaml file")
exit()

# Store data from yaml filyaml_path
try:
repository = data["github"]["repository"]
except KeyError:
print("Unable to find repository link")
exit()

try:
token = data["github"]["personal_access_token"]
except KeyError:
print("Unable to find personal_access_token")
exit()

try:
package_name = data["competition"]["package_name"]
except KeyError:
print("Unable to find package_name")
exit()

try:
launch_file = data["competition"]["launch_file"]
except KeyError:
print("Unable to find launch_file")
exit()

# Clone the repository
clone_cmd = f"git clone https://{token}@{repository} ~/ariac_ws/src/{package_name}"
subprocess.run(clone_cmd, shell=True)

# Install extra packages
for package in data["build"]["debian_packages"]:
install_cmd = f"apt-get install {package} -y"
subprocess.run(install_cmd, shell=True)

if data["build"]["pip_packages"]:
subprocess.run('apt install python3-pip -y' ,shell=True)

for package in data["build"]["pip_packages"]:
pip_command=f"yes | pip3 install {package}"
subprocess.run(pip_command,shell=True)

# Run custom build scripts
os.chdir('/home/ubuntu/competitor_build_scripts')
for script in data["build"]["extra_build_scripts"]:
subprocess.run(f"chmod +x {script}", shell=True)
subprocess.run(f"./{script}", shell=True)

# Install rosdep packages
os.chdir('/home/ubuntu/ariac_ws')
rosdep_cmd = "rosdep install --from-paths src -y --ignore-src"
subprocess.run(rosdep_cmd, shell=True)

# Build the workspace
subprocess.run("colcon build", shell=True)


if __name__=="__main__":
main()
11 changes: 11 additions & 0 deletions automated_evaluation/scripts/build_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd ../home/ubuntu/scripts/

chmod +x build_competitor_code.py

rm -r /home/ubuntu/ariac_ws/src/ariac/ariac_gazebo/config/trials
mv /home/ubuntu/trials /home/ubuntu/ariac_ws/src/ariac/ariac_gazebo/config/

source /opt/ros/galactic/setup.bash
python3 build_competitor_code.py $1
49 changes: 49 additions & 0 deletions automated_evaluation/scripts/run_trial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3

import os
import sys
import subprocess
import yaml


def main():
# Get yaml file name
if len(sys.argv) <= 1:
print("Please include an argument for the yaml file to run")
exit()

yaml_file = sys.argv[1] + '.yaml'
print(f'Running {yaml_file}')

if not os.path.isfile(yaml_file):
print(f'{yaml_file} not found')
exit()

# Parse yaml file
with open(yaml_file, "r") as stream:
try:
data = yaml.safe_load(stream)
except yaml.YAMLError:
print("Unable to parse yaml file")
exit()

# Store data from yaml filyaml_path
try:
package_name = data["competition"]["package_name"]
except KeyError:
print("Unable to find package_name")
exit()

try:
launch_file = data["competition"]["launch_file"]
except KeyError:
print("Unable to find launch_file")
exit()

# Run
launch_cmd = f"ros2 launch {package_name} {launch_file} trial_name:={sys.argv[2]}"
subprocess.run(launch_cmd, shell=True, env=dict(os.environ, DISPLAY=":1.0"))


if __name__=="__main__":
main()
10 changes: 10 additions & 0 deletions automated_evaluation/scripts/run_trial.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

cd ../home/ubuntu/scripts/

chmod +x run_trial.py

source /opt/ros/galactic/setup.bash
source /home/ubuntu/ariac_ws/install/setup.bash

python3 run_trial.py $1 $2
39 changes: 39 additions & 0 deletions automated_evaluation/trials/kitting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Trial Name: qc.yaml
# ARIAC2023

# ENVIRONMENT SETUP

time_limit: -1 # options: -1 (no time limit) or number of seconds (max 500)

kitting_trays: # Which kitting trays will be spawn
tray_ids: [3, 8]
slots: [1, 4]

parts:
bins: # bin params - 8 total bins each bin has nine total slots (1-9)
bin2:
- type: 'pump'
color: 'purple'
slots: [1, 3, 7, 9]
bin6:
- type: 'battery'
color: 'blue'
slots: [1, 3, 7, 9]

orders:
- id: 'MMB30H56'
type: 'kitting'
announcement:
time_condition: 0
priority: false
kitting_task:
agv_number: 4
tray_id: 3
destination: 'warehouse'
products:
- type: 'battery'
color: 'blue'
quadrant: 3
- type: 'pump'
color: 'purple'
quadrant: 1

0 comments on commit 33d54b9

Please sign in to comment.