Skip to content

Commit

Permalink
Added 'wait_until_finished' command for MIR; UR does not activate unt…
Browse files Browse the repository at this point in the history
…il all missions executed
  • Loading branch information
AileenCleary committed Sep 5, 2024
1 parent 98e7041 commit 771ed99
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 53 deletions.
10 changes: 5 additions & 5 deletions applications/example_app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[project]
[isotope_workcell]
name = "example_app"
version = "1.0.0"
description = "A simple example WEI application that waits for a set amount of time, then takes a picture with a webcam."
authors = [{name = "Ryan D. Lewis", email="ryan.lewis@anl.gov"}]
version = "1.1.0"
description = "A sample WEI application for the isotope workcell to test mir, UR, and camera communications."
authors = [{name = "Aileen Cleary", email="acleary@anl.gov"}]
dependencies = [
"ad_sdl.wei",
"requests"
Expand All @@ -12,4 +12,4 @@ readme = "README.md"
license = {text = "MIT"}

[project.urls]
homepage = "https://github.com/AD-SDL/wei_template_workcell"
homepage = "https://github.com/AD-SDL/isotope_workcell"
64 changes: 37 additions & 27 deletions applications/example_app/src/example_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,57 @@

from wei import ExperimentClient

def run_camera(database, camera, verbose):
start = time.time()
url = "http://146.137.240.84:8001/execute-script/"
payload = {
"database": database,
"camera": camera,
"verbose": verbose
}
# def run_camera(database, camera, verbose):
# start = time.time()
# url = "http://146.137.240.84:8001/execute-script/"
# payload = {
# "database": database,
# "camera": camera,
# "verbose": verbose
# }

response = requests.post(url, json=payload).json().get("text")
end = time.time()
time_taken = end - start
print(response)
# response = requests.post(url, json=payload).json().get("text")
# end = time.time()
# time_taken = end - start
# #print(response)

return response, time_taken
# return response, time_taken

def main() -> None:

time_avg = 0
stored_data = []
# time_avg = 0
# stored_data = []

exp = ExperimentClient("localhost", "8000", "mir_test")
exp._register_experiment()
wf_path = Path(__file__).parent.parent / "workflows" / "test_workflow.yaml"
mir_path = Path(__file__).parent.parent / "workflows" / "test_workflow.yaml"
ur_path = Path(__file__).parent.parent / "workflows" / "ur_joint_disconnect_workflow.yaml"
payload = {
"waypoint_1" : "[-4.88745, -1.42041, 2.08027, -0.63891, 1.4028, -0.02912]",
"waypoint_2" : "[-5.40313, -1.48324, 2.38776, -0.88424, 1.89998, -0.00733]",
"waypoint_3" : "[-5.3892, -1.01121, 2.48123, -1.45123, 1.91534, -0.01163]",
"waypoint_4" : "[-5.38928, -0.97805, 2.47837, -1.48201, 1.91513, -0.01191]"
}

for _ in range(1):
run_info = exp.start_run(
wf_path.resolve(),
mir_path.resolve(),
)
run_info = exp.start_run(
ur_path.resolve(), payload=payload
)

data, time_taken = run_camera(
database="mir.db",
camera="CALIB_Logi_RPL_20240508/",
verbose=True
)
stored_data.append(data)
time_avg += time_taken
time.sleep(150)
# data, time_taken = run_camera(
# database="mir.db",
# camera="CALIB_Logi_RPL_20240508/",
# verbose=True
# )
# stored_data.append(data)
# time_avg += time_taken


print("Base timeline for un-optimized camera communication: ", time_avg/10)
print(json.dumps(run_info, indent=2))
#print("Base timeline for un-optimized camera communication: ", time_avg/10)
#print(json.dumps(run_info, indent=2))

if __name__ == "__main__":
main()
8 changes: 3 additions & 5 deletions applications/example_app/workflows/test_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ flowdef:
target_location: "charger1"
comment: Dock to charger.

- name: Wait
- name: Wait until Done.
module: mir_base
action: add_wait
args:
delay_seconds : 60
comment: Wait at charger for 60 seconds to allow images to be captured.
action: wait_until_finished
comment: Waits for previous mission to be done executing before continuing.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: ur_joint_disconnect_workflow
metadata:
author: Aileen Cleary
info: Workflow for disconnecting sample joint using UR.
version: 0.1

modules:
- name: ur

flowdef:
- name: Move to home position.
module: ur
action: movej
args:
joints: payload.waypoint_1
comment: Move to home position.

- name: Open gripper.
module: ur
action: toggle_gripper
args:
open: True
comment: Opens gripper.

- name: Center above joint.
module: ur
action: movej
args:
joints: payload.waypoint_2
comment: Center above joint.

- name: Go to joint.
module: ur
action: movej
args:
joints: payload.waypoint_3
comment: Position gripper around joint shaft.

- name: Grab joint.
module: ur
action: toggle_gripper
args:
close: True
comment: Close gripper around joint.

- name: Disconnect joint.
module: ur
action: movej
args:
joints: payload.waypoint_4
comment: Pull joint shaft down to disconnect.

- name: Open gripper.
module: ur
action: toggle_gripper
args:
open: True
comment: Opens gripper.

- name: Center above joint.
module: ur
action: movej
args:
joints: payload.waypoint_2
comment: Center above joint.

- name: Move to home position.
module: ur
action: movej
args:
joints: payload.waypoint_1
comment: Move to home position.

20 changes: 10 additions & 10 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ include:

services:
mir_node:
image: ghcr.io/ad-sdl/mir_module:dev
image: ghcr.io/ad-sdl/mir_module:aileen_dev
container_name: mir_node
privileged : true
command: python -m mir_rest_node --port 2000
ports:
- 2000:2000
env_file:
- .env
# ur_node:
# image: ghcr.io/ad-sdl/ur_module
# container_name: ur_node
# privileged: true
# ports:
# - 2001:2001
# command: python -m camera_rest_node --port 2001
# env_file:
# - .env
ur_node:
image: ghcr.io/ad-sdl/ur_module:latest
container_name: ur_node
privileged: true
ports:
- 2001:2001
command: python -m ur_rest_node --port 2001 --ur_ip ${UR_IP}
env_file:
- .env
2 changes: 1 addition & 1 deletion docker/wei.compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
environment:
- USER_ID=${USER_ID:-1000}
- GROUP_ID=${GROUP_ID:-1000}
command: python3 -m wei.server --workcell /workcell_defs/${WORKCELL_FILENAME}
command: python3 -m wei.server --workcell /workcell_defs/${WORKCELL_FILENAME} --autostart_engine True
depends_on:
- wei_redis

Expand Down
10 changes: 5 additions & 5 deletions workcell_defs/isotope_workcell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ modules:
interface: wei_rest_node
config:
rest_node_address: "http://mir_node:2000"
# - name: ur
# model: ur
# interface: wei_rest_node
# config:
# rest_node_address: "http://ur_node:2001"
- name: ur
model: ur
interface: wei_rest_node
config:
rest_node_address: "http://ur_node:2001"

0 comments on commit 771ed99

Please sign in to comment.