-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_container.py
executable file
·41 lines (37 loc) · 1.24 KB
/
run_container.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# NOTE: please use only standard libraries
import os
import argparse
import subprocess
from pathlib import Path
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# parser.add_argument(
# "-c", type=str, help="gripper config file"
# )
parser.add_argument(
"-host", type=str, default="localhost", help="host name or ip-address"
)
parser.add_argument(
"launch_args",
nargs=argparse.REMAINDER,
help="launch args in ros style e.g. foo:=var",
)
args = parser.parse_args()
# assert args.c is not None
docker_run_command = """
docker run \
--gpus all --rm -it --net=host \
-e DISPLAY=${{DISPLAY}} -v /tmp:/tmp \
graspnet_ros:latest \
/bin/bash -i -c \
"source ~/.bashrc; \
roscd graspnet_ros; \
export ROS_IP={ip}; export ROS_MASTER={host}; export ROS_MASTER_URI=http://{host}:11311; \
roslaunch graspnet_ros grasp_server.launch TODO:=todo"
""".format(
ip=os.environ['ROS_IP'] if 'ROS_IP' in os.environ else '127.0.0.1',
host=args.host,
)
print(docker_run_command)
subprocess.call(docker_run_command, shell=True)