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 TX2 initialization #356

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9868652
[#275] Create basic rover setup script
RealWilliamWells Mar 5, 2020
c420dee
[#275] Edit startup script files to fix directory names
RealWilliamWells Mar 5, 2020
d2a2869
[#275] Fix rover setup script
RealWilliamWells Mar 5, 2020
c677ecd
[#275] Update rover setup script
RealWilliamWells Mar 5, 2020
650c248
[#275] Add fix for ros file permission
RealWilliamWells Mar 14, 2020
6e5b8b8
[#275] Add append to hosts file to roversetup.sh
RealWilliamWells Mar 14, 2020
8d9e7c0
[#275] Fix directories in service scripts
RealWilliamWells Mar 14, 2020
de4ce5f
[#275] Add execution of emailer and ethernet sync to setup
RealWilliamWells Mar 14, 2020
ec59029
[#275] Remove creation of venu from setup
RealWilliamWells Mar 14, 2020
8df768b
[#275] Edit setup script and readd creation of venv
RealWilliamWells Apr 4, 2020
9e58f8b
[#275] Reenable ip emailer
RealWilliamWells Apr 5, 2020
ce944a5
[#275] Use environment variables to refactor scripts
RealWilliamWells Apr 29, 2020
07bc69f
[#275] Fix roversetup syntax and add missing requirement
RealWilliamWells Apr 30, 2020
ae66953
[#275] Fix directory issue in rover setup script
RealWilliamWells Apr 30, 2020
4ec7df1
[#275] Merge branch 'master' into setup-tx2-initialization-275
PeterGhimself Jun 20, 2020
f2b9ca3
[#275] Merge branch 'master' into setup-tx2-initialization-275
RealWilliamWells Dec 30, 2020
31c7647
[#275] Remove stuff unnecessary stuff from OBC setup script
RealWilliamWells Dec 30, 2020
2287ff0
[#275] Merge branch 'master' into setup-tx2-initialization-275
RealWilliamWells Dec 31, 2020
97a9c36
[#275] Remove useless cd command from rover setup
RealWilliamWells Dec 31, 2020
05cfc43
[#275] Remove repo adding command
RealWilliamWells Dec 31, 2020
384b32d
[#275] Remove ip emailer script setup from rover setup script for now
RealWilliamWells Dec 31, 2020
d0c6e65
[#275] Merge branch 'master' into setup-tx2-initialization-275
RealWilliamWells Dec 31, 2020
17a47ef
[#275] Edit ros install path in ros rover start script
RealWilliamWells Dec 31, 2020
ae60528
[#275] Fix enviroment variable call
RealWilliamWells Dec 31, 2020
8a71c22
[#275] Add path to node installation for runEmailer.sh
OfficialOwlElder Jan 2, 2021
de4641b
[#275] Add line to synEmailer.sh to copy runEmailer.sh to /usr/bin/
OfficialOwlElder Jan 2, 2021
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
28 changes: 28 additions & 0 deletions robot/rover/RoverSetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Script which setups the Space Concordia Robotics Software team's OBC.

REPO="/home/$USER/Programming/robotics-prototype"

FINAL_MESSAGE="The script will now exit, ensure that ros is install correctly and that
all of the rospackages are present. Reboot to run systemd services."

#install prereqs
sudo apt update -y
sudo apt install openssh-server -y
sudo ufw allow ssh

# Setup systemd services
cd $REPO/robot/rover
sudo cp systemd/config-ethernet.service /etc/systemd/system/config-ethernet.service
sudo cp systemd/ros-rover-start.service /etc/systemd/system/ros-rover-start.service
sudo systemctl enable config-ethernet.service
sudo systemctl enable ros-rover-start.service

# Setup ethernet and emailer service scripts
cd $REPO/robot/util
sudo cp configEthernet/runConfigEthernet.sh /usr/bin/runConfigEthernet.sh
cd $REPO/robot/util/configEthernet && bash synchConfigEthernet.sh

# Exit
echo "$FINAL_MESSAGE"
exit 0
6 changes: 3 additions & 3 deletions robot/rover/systemd/ros-rover-start.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ After=ip-emailer.service
Wants=ip-emailer.service

[Service]
#User=odroid
# For some unkown reason this service stopped working when running as user odroid
#User=nvidia
# For some unkown reason this service stopped working when running as user nvidia
User=root
Type=simple
ExecStart=/home/odroid/Programming/robotics-prototype/robot/util/rosRoverStart/runRosRoverStart.sh
ExecStart=/home/nvidia/Programming/robotics-prototype/robot/util/rosRoverStart/runRosRoverStart.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be using $USER

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't work cause the systemd service has to run under root for some reason

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thing is, you can change the service to run as non-root but then certain processes later in the pipeline will fail and need to be worked around. Some more digging can be done as to where specifically it messes up, but seeing as we're not going to be switching OBC super often I'd say it's fine to leave this as it is for now. Maybe we can open an issue to investigate this for after this PR is merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try testing this out again for some investigation 👀 🍷


[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion robot/util/configEthernet/configEthernet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This script checks if the internet can be reached from a regular ethernet connection type
# If the regular ethernet configuration cannot ping google severs, the rocket configuration is loaded

STATUS_FILE="/home/odroid/configEthernet/status_done"
STATUS_FILE="/home/nvidia/configEthernet/status_done"

# "I'm working"
echo 0 > $STATUS_FILE
Expand Down
2 changes: 1 addition & 1 deletion robot/util/configEthernet/runConfigEthernet.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
bash /home/odroid/configEthernet/configEthernet.sh > /home/odroid/configEthernet/configEthernet.log
bash /home/nvidia/configEthernet/configEthernet.sh > /home/nvidia/configEthernet/configEthernet.log
2 changes: 1 addition & 1 deletion robot/util/configEthernet/synchConfigEthernet.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ETHERNET_CONFIG_DIR="/home/odroid/configEthernet"
ETHERNET_CONFIG_DIR="/home/$USER/configEthernet"

if [ ! -d $ETHERNET_CONFIG_DIR ]; then
mkdir $ETHERNET_CONFIG_DIR;
Expand Down
4 changes: 3 additions & 1 deletion robot/util/emailer/emailIPAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const EMAILS_FILE_NAME = 'emails.txt'
// fallback to default emails if there's and issue with the emails file
const DEFAULT_EMAILS = [
'[email protected]',
'[email protected]'
'[email protected]',
'[email protected]',
'[email protected]'
]

let ourIP
Expand Down
11 changes: 5 additions & 6 deletions robot/util/emailer/runEmailer.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

EMAILER_LOG="/home/odroid/emailer/emailer.log"
ETHERNET_CONFIG_STATUS="/home/odroid/configEthernet/status_done"
EMAILER_LOG="/home/nvidia/emailer/emailer.log"
ETHERNET_CONFIG_STATUS="/home/nvidia/configEthernet/status_done"
NODE_PATH="/home/nvidia/.nvm/versions/node/v10.13.0/bin/node"

# wait for connection to configure itself via config-ethernet.service
while [ `cat $ETHERNET_CONFIG_STATUS` == "0" ]
Expand All @@ -19,8 +20,6 @@ if [[ "$activeConnection" =~ "RoverOBC" ]]; then
else
# WARNING: when adding this script to be run on startup whether using cronjob or systemd services
# make sure to replace the beginning "node" with the direct path which you can check with the output of `which node`
# otherwise it will not work. Example: "/home/odroid/.nvm/versions/node/v10.13.0/bin/node"
node /home/odroid/emailer/emailIPAddress.js >> $EMAILER_LOG
# otherwise it will not work. Example: "/home/nvidia/.nvm/versions/node/v10.13.0/bin/node"
$NODE_PATH /home/nvidia/emailer/emailIPAddress.js >> $EMAILER_LOG
fi


3 changes: 2 additions & 1 deletion robot/util/emailer/syncEmailer.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EMAILER_DIR="/home/odroid/emailer"
EMAILER_DIR="/home/$USER/emailer"

if [ ! -d $EMAILER_DIR ]; then
mkdir $EMAILER_DIR;
Expand All @@ -7,5 +7,6 @@ fi
cp ./* $EMAILER_DIR
cd $EMAILER_DIR

cp runEmailer.sh /usr/bin/runEmailer.sh
# install dependencies defined in package.json
npm install
6 changes: 3 additions & 3 deletions robot/util/rosRoverStart/rosRoverStart.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
HOME="/home/odroid"
HOME="/home/nvidia"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it sometimes $USER sometimes nvidia

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this related to what you put in the description?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are apparently issues with using $USER when running it as a systemd service. I'll try to changing it back to see if I can get to work tho

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it isn't related to what I put in the description. The description refers to some weird issue with connecting to ROS over a vpn server which has a workaround.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The systemd service doesn't work if $USER is used anywhere because the service has to run under root for some reason. I haven't find a way to fix this yet

REPO_HOME="$HOME/Programming/robotics-prototype"
ETHERNET_CONFIG_STATUS="$HOME/configEthernet/status_done"
#CATKIN_WS_SETUP="$HOME/catkin_ws/devel/setup.bash" # catkin ws only for isolated prototyping
OPT_KINETIC_SETUP="/opt/ros/kinetic/setup.bash" # ros system default workspace
OPT_MELODIC_SETUP="/opt/ros/melodic/setup.bash" # ros system default workspace
ROS_PACKAGES_SETUP="$REPO_HOME/robot/rospackages/devel/setup.bash"
ROSLAUNCH_FILE="$REPO_HOME/robot/util/rosRoverStart/rover.launch"
# wait for connection to configure itself via config-ethernet.service
Expand All @@ -21,4 +21,4 @@ source "$REPO_HOME/venv/bin/activate"
python3 "$REPO_HOME/setup.py" develop

# source primary catkin_ws setup bash script and execute one launch script to rule them all
source $OPT_KINETIC_SETUP && source $ROS_PACKAGES_SETUP && roslaunch $ROSLAUNCH_FILE
source $OPT_MELODIC_SETUP && source $ROS_PACKAGES_SETUP && roslaunch $ROSLAUNCH_FILE
2 changes: 1 addition & 1 deletion robot/util/rosRoverStart/runRosRoverStart.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
ROS_ROVER_START_DIR="/home/odroid/Programming/robotics-prototype/robot/util/rosRoverStart"
ROS_ROVER_START_DIR="/home/nvidia/Programming/robotics-prototype/robot/util/rosRoverStart"
ROS_ROVER_START_SH="$ROS_ROVER_START_DIR/rosRoverStart.sh"
ROS_ROVER_START_LOG="$ROS_ROVER_START_DIR/rosRoverStart.log"
bash $ROS_ROVER_START_SH > $ROS_ROVER_START_LOG