#!/bin/bash

# Specify the input device (adjust the device path if needed)
DEVICE="/dev/input/js0"

# Specify the exact path to the ROS 2 workspace
ROS2_WS_PATH=~/PycharmProjects/UR_Robotiq

# Source the ROS 2 setup script
source /opt/ros/$ROS_DISTRO/setup.bash
source ~/ros2_ws/install/setup.bash

# Launch the joy_node in a new terminal with the specified input device
gnome-terminal -- bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; source $ROS2_WS_PATH/install/setup.bash; ros2 run joy joy_node --ros-args --param dev:=$DEVICE; exec bash"

# Wait for the joy_node to initialize
sleep 2

# Launch the ps5_mapping_script in another new terminal
gnome-terminal -- bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; source $ROS2_WS_PATH/install/setup.bash; ros2 run ur_robotiq_servo ps5_mapping; exec bash"