diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eb948e194..7ce58df4d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,7 @@ jobs: - name: Install BlueView Sonar SDK run: | cd $GITHUB_WORKSPACE/catkin_ws/src/mil - ./scripts/hardware_installers/install_bvtsdk --pass ${{ secrets.ZOBELISK_PASSWORD }} + ./scripts/hw/install_bvtsdk --pass ${{ secrets.ZOBELISK_PASSWORD }} ls mil_common/drivers/mil_blueview_driver echo $PWD - name: Install system dependencies diff --git a/mil_common/mil_missions/nodes/mission_client b/mil_common/mil_missions/nodes/mission_client index 230547f8e..e793693cf 100755 --- a/mil_common/mil_missions/nodes/mission_client +++ b/mil_common/mil_missions/nodes/mission_client @@ -34,6 +34,7 @@ class MissionClientCli: ) return print("Available Missions:") + missions.sort() for mission in missions: print("- ", mission) diff --git a/scripts/hw/install_8bitdoo_udev b/scripts/hw/install_8bitdoo_udev new file mode 100755 index 000000000..81f544879 --- /dev/null +++ b/scripts/hw/install_8bitdoo_udev @@ -0,0 +1,58 @@ +#!/bin/bash + +# 8bitdoo Ultimate Wireless Controller installation script, by Robert Michael Smith +# Original source: https://gist.github.com/loopyd/a7ccbf37e27580ccbed859c26aa0a167 + +# Block script from running as non-root user +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 +fi +# Blacklist Nintendo Switch Pro Controller Driver +echo blacklist hid_nintendo | tee /etc/modprobe.d/notendo.conf + +# Install xboxdrv +apt-get update +if ! dpkg -s 'xboxdrv' &>/dev/null; then + apt-get install -y xboxdrv +fi + +# Create udev rules +if [ ! -f '/etc/udev/rules.d' ]; then + mkdir -p '/etc/udev/rules.d' +fi +udev_rules='/etc/udev/rules.d/99-8bitdo-ultimate.rules' +if [ -f $udev_rules ]; then + sudo rm $udev_rules +fi +echo 'SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3106", ATTR{manufacturer}=="8BitDo", RUN+="/bin/systemctl start 8bitdo-ultimate-xinput@2dc8:3106"' | tee $udev_rules +echo 'SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3109", ATTR{manufacturer}=="8BitDo", RUN+="/bin/systemctl stop 8bitdo-ultimate-xinput@2dc8:3106"' | tee -a $udev_rules + +# Reload udev rules +udevadm control --reload-rules +udevadm trigger + +# Create systemd service +service_file='/etc/systemd/system/8bitdo-ultimate-xinput@.service' +if [ -f $service_file ]; then + rm $service_file +fi +echo '[Unit]' | tee $service_file +echo 'Description=8BitDo Ultimate Controller XInput mode xboxdrv daemon' | tee -a $service_file +echo '' | tee -a $service_file +echo '[Service]' | tee -a $service_file +echo 'Type=simple' | tee -a $service_file +echo 'ExecStart=/usr/bin/xboxdrv --mimic-xpad --silent --type xbox360 --device-by-id %i --force-feedback --detach-kernel-driver' | tee -a $service_file + +systemctl daemon-reload + +# Now install jstest-gtk to test the controller, which also installs all the joystick dependencies +# This fixes: +# - /dev/input/js0 not found +if ! dpkg -s 'jstest-gtk' &>/dev/null; then + apt-get install -y jstest-gtk +fi + +# Now open jstest-gtk and test the controller, remap the axis / buttons, then exit +# Save the configuration using the command: +# sudo jscal-store /dev/input/js0 diff --git a/scripts/hardware_installers/install_bvtsdk b/scripts/hw/install_bvtsdk similarity index 100% rename from scripts/hardware_installers/install_bvtsdk rename to scripts/hw/install_bvtsdk diff --git a/scripts/hardware_installers/install_flycap b/scripts/hw/install_flycap similarity index 100% rename from scripts/hardware_installers/install_flycap rename to scripts/hw/install_flycap diff --git a/scripts/hardware_installers/install_sylphase_sonar b/scripts/hw/install_sylphase_sonar similarity index 100% rename from scripts/hardware_installers/install_sylphase_sonar rename to scripts/hw/install_sylphase_sonar diff --git a/scripts/hardware_installers/install_udev_rules b/scripts/hw/install_udev_rules similarity index 100% rename from scripts/hardware_installers/install_udev_rules rename to scripts/hw/install_udev_rules diff --git a/scripts/setup.bash b/scripts/setup.bash index 881e6c182..fa3d442af 100755 --- a/scripts/setup.bash +++ b/scripts/setup.bash @@ -148,6 +148,51 @@ dmb() { git diff "$(git merge-base --fork-point "$(git branch -l main master --format '%(refname:short)')" HEAD)" } +subnet_ip() { + ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){2}37\.[0-9]*' | grep -v '127.0.0.1' +} + +rosdisconnect() { + unset ROS_IP + unset ROS_MASTER_URI + echo "Disconnected! New values:" + echo "ROS_IP=$ROS_IP" + echo "ROS_MASTER_URI=$ROS_MASTER_URI" +} + +rosconnect() { + # --no-subnet flag to avoid checking for the subnet + # Usage: rosconnect --no-subnet + if [[ $1 == "--no-subnet" ]]; then + if [[ -z $2 || -z $3 ]]; then + echo "Usage: rosconnect --no-subnet " + return + fi + export ROS_IP=${2} + export ROS_MASTER_URI="http://${3}:11311" + echo "ROS_IP=$ROS_IP" + echo "ROS_MASTER_URI=$ROS_MASTER_URI" + return + fi + if [[ -n $(subnet_ip) ]]; then + my_ip=$(subnet_ip) + export ROS_IP=$my_ip + export ROS_MASTER_URI="http://${1}:11311" + echo "ROS_IP=$ROS_IP" + echo "ROS_MASTER_URI=$ROS_MASTER_URI" + else + echo "No 37 subnet IP found, not setting ROS_IP or ROS_MASTER_URI" + fi +} + +rosnavconnect() { + rosconnect "192.168.37.82" +} + +rossubconnect() { + rosconnect "192.168.37.60" +} + alias xbox=startxbox # PYTHONPATH modifications