Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup script stuff #8

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM osrf/ros:jazzy-desktop-full

RUN mkdir -p /autonav/autonav_ws/src
# RUN mkdir -p /autonav/setup
RUN mkdir -p /autonav/setup
# RUN mkdir -p /autonav/deps

COPY autonav_ws/src /autonav/autonav_ws/src
# COPY setup /autonav/setup
# COPY vectorsecrets.txt /autonav/setup/vectorsecrets.txt
COPY setup /autonav/setup
COPY vectorsecrets.txt /autonav/setup/vectorsecrets.txt
# COPY deps /autonav/deps

# WORKDIR /autonav/setup
# RUN /bin/bash -c "./setup.sh"
WORKDIR /autonav/setup
RUN /bin/bash -c "./setup.sh"

WORKDIR /autonav/autonav_ws
RUN /bin/bash -c "source /opt/ros/jazzy/setup.bash; colcon build"
14 changes: 14 additions & 0 deletions setup/etc/autonav.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Can
KERNEL=="ttyACM*", ATTRS{idVendor}=="ad50", ATTRS{idProduct}=="60c4", ATTRS{serial}=="002D00254E53511520363936", MODE:="0666", GROUP:="dialout", SYMLINK+="autonav-can-835"
KERNEL=="ttyACM*", ATTRS{idVendor}=="ad50", ATTRS{idProduct}=="60c4", ATTRS{serial}=="0037001E5834570120343833", MODE:="0666", GROUP:="dialout", SYMLINK+="autonav-can-835"

# IMU
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AU057VHW", MODE:="0666", GROUP:="dialout", SYMLINK+="autonav-imu-200"

# Steam Controller
KERNEL=="uinput", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput", MODE="0666"
KERNEL=="hidraw*", KERNELS=="*28DE:*", MODE="0666", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"

# Safety Lights PICO
KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", ATTRS{serial}=="E660D051138A8531", MODE:="0666", GROUP:="dialout", SYMLINK+="autonav-mc-safetylights"
14 changes: 14 additions & 0 deletions setup/etc/autonav.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Autonav 2025 Service

[Service]
Type=simple
User=scr
Restart=always
RestartSec=5s
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/scr/.Xauthority"
ExecStart=/bin/bash /usr/bin/autonav_service.sh

[Install]
WantedBy=multi-user.target
25 changes: 25 additions & 0 deletions setup/etc/autonav_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Get local user
LOCAL_USER = $(whoami)

# Setup ROS2
export DISPLAY=:0
source /opt/ros/jazzy/setup.bash

# Check if build is needed, if so, build
cd /home/$LOCAL_USER/autonav_software_2025/autonav_ws
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")

if [ $LOCAL = $REMOTE ] || [ $REMOTE = $BASE ] || [ $LOCAL != $REMOTE ]; then
echo "No Build Needed"
else
echo "Build Needed"
git pull
colcon build
fi

# Launch
source /home/$LOCAL_USER/autonav_software_2025/autonav_ws/install/setup.bash
ros2 launch autonav_launch competition.xml
41 changes: 41 additions & 0 deletions setup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Check if vectorsecrets.txt exists
if [ ! -f vectorsecrets.txt ]; then
echo "vectorsecrets.txt does not exist. Creating it now:"
echo -n "Please enter your login: "
read username
echo -n "Please enter your password: "
read -s password
echo -n "machine files.dylanzeml.in login $username password $password" > vectorsecrets.txt
fi

sudo apt update
sudo apt install wget unzip -y

# Vectornav Dependencies
bash ./vnav.sh

# Python deps
sudo apt install python3-pip -y
pip3 install python-can[serial]
pip3 install websockets

# Copy the udev rules to the correct location
sudo cp etc/autonav.rules /etc/udev/rules.d/autonav.rules

# Reload udev
sudo service udev reload
sleep 2
sudo service udev restart

# Copy services
sudo cp etc/autonav.service /etc/systemd/system/autonav.service
sudo cp etc/autonav_service.sh /usr/bin/autonav_service.sh

# chmod time :D
sudo chmod +x /usr/bin/autonav_service.sh
sudo chmod 644 /etc/systemd/system/autonav.service

# boot time
echo "Use 'systemctl enable autonav' to enable the service at boot time."
11 changes: 11 additions & 0 deletions setup/vnav.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Download and unzip vectornav files
curl --output vectornav.zip --netrc-file vectorsecrets.txt https://files.dylanzeml.in/protected/vectornav.zip
sudo mkdir /usr/local/vectornav
sudo chown -R "$USER":"$USER" /usr/local/vectornav
unzip -o vectornav.zip -d /usr/local/vectornav
rm vectornav.zip

# Install vectornav
python3 -m pip config set global.break-system-packages true
cd /usr/local/vectornav/python
sudo python3 setup.py install -q --break-system-packages
Loading