diff --git a/ansible/inventory/teleop/group_vars/control_machine.yml b/ansible/inventory/teleop/group_vars/control_machine.yml index 4d8fb4c1f..fbd6668bb 100644 --- a/ansible/inventory/teleop/group_vars/control_machine.yml +++ b/ansible/inventory/teleop/group_vars/control_machine.yml @@ -24,6 +24,10 @@ arm_ip_left: "" # Specify the IP address of left arm arm_ip_right: "" # Specify the IP address of right arm ur_robot_type: "ur10e" # Specify ur robot type: ur10, ur10e, ur5, ur5e biotacs: true # Whether the hands will have biotac fingertips +bag_all_data_from: ["shadowrobot_210312", "shadowrobot_210311"] +remote_bag_user: "shadowop" +remote_bag_storage_IP: "10.5.10.59" +remote_bag_storage_location: "/volume1/ros_bags" pr_branches: "" # Space-separated list of PRs (https://github.com/shadow-robot/repo/pull/266) or branches (https://github.com/shadow-robot/repo/tree/custom_branch) to check out on NUC and catkin_make ansible_become_password: !vault | $ANSIBLE_VAULT;1.1;AES256 diff --git a/ansible/inventory/teleop/group_vars/simulation.yml b/ansible/inventory/teleop/group_vars/simulation.yml index a1fcf24b7..aa0151da4 100644 --- a/ansible/inventory/teleop/group_vars/simulation.yml +++ b/ansible/inventory/teleop/group_vars/simulation.yml @@ -19,6 +19,10 @@ remote_teleop: false # Flag to enable/disable remote_teleop software install ur_robot_type: "ur10e" # Specify ur robot type: ur10, ur10e, ur5, ur5e arm_ip_left: "" # Specify the IP address of left arm arm_ip_right: "" # Specify the IP address of right arm +bag_all_data_from: ["shadowrobot_210312", "shadowrobot_210311"] +remote_bag_user: "shadowop" +remote_bag_storage_IP: "10.5.10.59" +remote_bag_storage_location: "/volume1/ros_bags" pr_branches: "" # Space-separated list in double quotes of PRs and branches like this "https://github.com/shadow-robot/repo/pull/266 https://github.com/shadow-robot/repo/tree/custom_branch" to check out on server and catkin_make scene_file: "" # Allows the user to override the scene_file used in GUI launch e.g. scene_file="\$(find sr_description_common)/scenes/custom.scene" (if empty, default in Github will be used) haptx_teleop_readthedocs_token: !vault | diff --git a/ansible/roles/products/common/docker-container/defaults/main.yml b/ansible/roles/products/common/docker-container/defaults/main.yml index aa6866afa..7e1169ab2 100644 --- a/ansible/roles/products/common/docker-container/defaults/main.yml +++ b/ansible/roles/products/common/docker-container/defaults/main.yml @@ -41,3 +41,4 @@ pr_branches: "" product: "" private_github_ssh_key_base64: "" private_ssh_keys_path: "{{ user_folder }}/.ssh/id_rsa_private" +record_hand_data: "disabled" diff --git a/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-no-terminator.yml b/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-no-terminator.yml index baf28a8e5..e9f6d7ce3 100644 --- a/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-no-terminator.yml +++ b/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-no-terminator.yml @@ -8,6 +8,11 @@ set_fact: shared_volumes: "{{ common_shared_volumes + container_type_shared_volumes + custom_shared_volumes }}" +- name: Find out if we should record all data from these hands + set_fact: + record_hand_data: "enabled" + when: config_branch in bag_all_data_from + - name: Creating the container with no terminator and no setup changed_when: false community.docker.docker_container: @@ -26,6 +31,7 @@ ROS_MASTER_URI: "http://{{ ros_master }}:11311" arm_ips: "{{ arm_ip_right }}_{{ arm_ip_left }}" XDG_RUNTIME_DIR: "/run/user/1000" + SR_RECORD_HAND_DATA: "{{ record_hand_data }}" network_mode: "host" pid_mode: "host" privileged: yes diff --git a/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-with-terminator.yml b/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-with-terminator.yml index 301b34e65..1c6acd2dd 100644 --- a/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-with-terminator.yml +++ b/ansible/roles/products/common/docker-container/tasks/create-container/no-setup-with-terminator.yml @@ -21,6 +21,7 @@ ROS_MASTER_URI: "http://{{ ros_master }}:11311" arm_ips: "{{ arm_ip_right }}_{{ arm_ip_left }}" XDG_RUNTIME_DIR: "/run/user/1000" + SR_RECORD_HAND_DATA: "{{ record_hand_data }}" network_mode: "host" pid_mode: "host" privileged: yes diff --git a/ansible/roles/products/common/docker-container/tasks/create-container/nvidia-with-setup-with-terminator.yml b/ansible/roles/products/common/docker-container/tasks/create-container/nvidia-with-setup-with-terminator.yml index 842337ba8..d8c58406a 100644 --- a/ansible/roles/products/common/docker-container/tasks/create-container/nvidia-with-setup-with-terminator.yml +++ b/ansible/roles/products/common/docker-container/tasks/create-container/nvidia-with-setup-with-terminator.yml @@ -22,6 +22,7 @@ NVIDIA_DRIVER_CAPABILITIES: "all" arm_ips: "{{ arm_ip_right }}_{{ arm_ip_left }}" XDG_RUNTIME_DIR: "/run/user/1000" + SR_RECORD_HAND_DATA: "{{ record_hand_data }}" network_mode: "host" pid_mode: "host" privileged: yes diff --git a/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-no-terminator.yml b/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-no-terminator.yml index 93408da24..9898723cd 100644 --- a/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-no-terminator.yml +++ b/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-no-terminator.yml @@ -4,6 +4,11 @@ container_type_shared_volumes: - "{{ user_folder }}/.Xauthority:/home/user/.Xauthority" +- name: Find out if we should record all data from these hands + set_fact: + record_hand_data: "enabled" + when: config_branch in bag_all_data_from + - name: Set shared volumes set_fact: shared_volumes: "{{ common_shared_volumes + container_type_shared_volumes + custom_shared_volumes }}" @@ -26,6 +31,7 @@ ROS_MASTER_URI: "http://{{ ros_master }}:11311" arm_ips: "{{ arm_ip_right }}_{{ arm_ip_left }}" XDG_RUNTIME_DIR: "/run/user/1000" + SR_RECORD_HAND_DATA: "{{ record_hand_data }}" network_mode: "host" pid_mode: "host" privileged: yes diff --git a/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-with-terminator.yml b/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-with-terminator.yml index b1193871b..ce3e88961 100644 --- a/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-with-terminator.yml +++ b/ansible/roles/products/common/docker-container/tasks/create-container/with-setup-with-terminator.yml @@ -21,6 +21,7 @@ ROS_MASTER_URI: "http://{{ ros_master }}:11311" arm_ips: "{{ arm_ip_right }}_{{ arm_ip_left }}" XDG_RUNTIME_DIR: "/run/user/1000" + SR_RECORD_HAND_DATA: "{{ record_hand_data }}" network_mode: "host" pid_mode: "host" privileged: yes @@ -33,3 +34,4 @@ command: "terminator {{ term_args }} -T '{{ container_terminal_title }}' -x bash -c '[[ -e {{ setup_directory }}/{{ setup_script }} ]] && {{ setup_directory }}/{{ setup_script }} && bash || bash'" container_default_behavior: compatibility become: yes + diff --git a/ansible/roles/products/common/record-hand-data/defaults/main.yml b/ansible/roles/products/common/record-hand-data/defaults/main.yml new file mode 100644 index 000000000..27df7c311 --- /dev/null +++ b/ansible/roles/products/common/record-hand-data/defaults/main.yml @@ -0,0 +1,2 @@ +--- +bag_all_data_from: [] diff --git a/ansible/roles/products/common/record-hand-data/tasks/main.yml b/ansible/roles/products/common/record-hand-data/tasks/main.yml new file mode 100644 index 000000000..f53a00462 --- /dev/null +++ b/ansible/roles/products/common/record-hand-data/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- name: Custom shared volume for bag storage + block: + - name: Set shadow_bag_storage folder names + set_fact: + shadow_bag_storage_folder: "{{ user_folder }}/shadow_bag_storage" + shadow_bag_storage_inside_docker: "/home/user/shadow_bag_storage" + + - name: Ensure {{ shadow_bag_storage_folder }} folder exists + file: + path: "{{ shadow_bag_storage_folder }}" + mode: '755' + state: directory + + - name: Set custom shared volumes for docker container + set_fact: + custom_shared_volumes: + - "{{ shadow_bag_storage_folder }}:{{ shadow_bag_storage_inside_docker }}" + +# Creates a cron file under /etc/cron.d +- cron: + name: sync hand data to NAS + hour: "20" + user: user + job: "rsync -azP --remove-source-files --exclude '*active*' {{ shadow_bag_storage_folder }}/ {{ remote_bag_user }}@{{ remote_bag_storage_IP }}:{{ remote_bag_storage_location }} >> /home/user/hand_cron_log 2>&1" + cron_file: sr_sync_hand_data_to_nas + become: true diff --git a/ansible/roles/products/teleop/control_machine/deploy/tasks/main.yml b/ansible/roles/products/teleop/control_machine/deploy/tasks/main.yml index 7c5232044..5b6fb93e1 100644 --- a/ansible/roles/products/teleop/control_machine/deploy/tasks/main.yml +++ b/ansible/roles/products/teleop/control_machine/deploy/tasks/main.yml @@ -14,6 +14,11 @@ include_role: name: installation/chrony-client +- name: Include products/common/record-hand-data role + include_role: + name: products/common/record-hand-data + when: config_branch in bag_all_data_from + - name: Include docker/docker-image role include_role: name: docker/docker-image diff --git a/ansible/roles/products/teleop/server/deploy/defaults/main.yml b/ansible/roles/products/teleop/server/deploy/defaults/main.yml index e392fc1a9..6e1b07957 100644 --- a/ansible/roles/products/teleop/server/deploy/defaults/main.yml +++ b/ansible/roles/products/teleop/server/deploy/defaults/main.yml @@ -57,3 +57,4 @@ haptx_teleop_readthedocs_token: "" shadow_glove_teleop_readthedocs_token: "" pr_branches: "" polhemus_type: "viper" +bag_all_data_from: [] diff --git a/ansible/roles/products/teleop/server/deploy/tasks/main.yml b/ansible/roles/products/teleop/server/deploy/tasks/main.yml index c3c369cb1..2bad20df7 100644 --- a/ansible/roles/products/teleop/server/deploy/tasks/main.yml +++ b/ansible/roles/products/teleop/server/deploy/tasks/main.yml @@ -52,6 +52,11 @@ name: installation/chrony-server when: groups['server'] is defined +- name: Include products/common/record-hand-data role + include_role: + name: products/common/record-hand-data + when: config_branch in bag_all_data_from + - name: Include installation/shadow_glove_driver role include_role: name: installation/shadow_glove_driver