Skip to content

Commit

Permalink
ros2 initial setup for emc_system
Browse files Browse the repository at this point in the history
  • Loading branch information
WiktorBocian committed Dec 10, 2024
1 parent 30e0c11 commit 68dc6c0
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CMakeLists.txt.user*
/build/
/log/
/install/
.txt
*.txt
settings.json
*.pyc
9 changes: 9 additions & 0 deletions install.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# set -e
# set -x

export EMC_DIR=~/.emc
export EMC_ENV_DIR=$EMC_DIR/env

# log_file="$EMC_DIR/install.log"
# exec > >(tee -i $log_file)
# exec 2>&1

if ! dpkg -s curl &> /dev/null
then
echo "Going to install curl"
Expand All @@ -23,11 +30,13 @@ fi
if [[ ! -d $EMC_ENV_DIR ]] && [[ -z "$CI" ]]
then
git clone https://github.com/tue-robotics/emc-env $EMC_ENV_DIR
git -C $EMC_ENV_DIR checkout ros2
elif [[ -n "$CI" ]]
then
mkdir -p $EMC_DIR
cp -r . $EMC_ENV_DIR
else
git -C $EMC_ENV_DIR checkout ros2
git -C $EMC_ENV_DIR pull
fi

Expand Down
78 changes: 52 additions & 26 deletions setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ then

# Set ROS version
case $DISTRIB_RELEASE in
"24.04")
EMC_ROS_DISTRO=jazzy
echo "[emc-env] Detected ubuntu 24.04, using ROS2 Jazzy"
;;
"20.04")
EMC_ROS_DISTRO=noetic
echo "[emc-env] Detected ubuntu 20.04, using ROS Noetic"
Expand All @@ -23,14 +27,29 @@ then
echo "[emc-env] Detected ubuntu 18.04, using ROS Melodic"
;;
*)
echo "[emc-env] Ubuntu $DISTRIB_RELEASE is unsupported. Use 20.04, 18.04"
echo "[emc-env] Ubuntu $DISTRIB_RELEASE is unsupported. Use 24.04, 20.04, 18.04"
exit 1
;;
esac
fi

export EMC_ROS_DISTRO

# Source the ROS environment
if [ -f /opt/ros/$EMC_ROS_DISTRO/setup.bash ]
then
source /opt/ros/$EMC_ROS_DISTRO/setup.bash
else
echo "[emc-env] ROS distribution $EMC_ROS_DISTRO is not installed."
exit 1
fi

# Source the workspace
if [ -f $EMC_SYSTEM_DIR/install/setup.bash ]
then
source $EMC_SYSTEM_DIR/install/setup.bash
fi

if [ -f $EMC_SYSTEM_DIR/devel/setup.bash ]
then
source $EMC_SYSTEM_DIR/devel/setup.bash
Expand All @@ -52,8 +71,10 @@ function emc-update
if [[ ! -d $EMC_ENV_DIR ]]
then
git clone https://github.com/tue-robotics/emc-env $EMC_ENV_DIR
git -C $EMC_ENV_DIR checkout ros2
else
git -C $EMC_ENV_DIR pull
git -C $EMC_ENV_DIR checkout ros2
fi
fi

Expand All @@ -67,35 +88,40 @@ function emc-update
# --------------------------------------------------------------------------------
#export ROS_HOSTNAME=$HOSTNAME.local

alias mrc-teleop='rosrun emc_system teleop.py'
# alias mrc-teleop='rosrun emc_system teleop.py'
alias mrc-teleop='python3 $EMC_ENV_DIR/../system/src/emc_system/scripts/teleop.py'
alias mrc-talker='python3 $EMC_ENV_DIR/../system/src/emc_system/scripts/talker.py'

alias mrc-update=emc-update

export BOBO_IP='192.168.6.68'
export COCO_IP='192.168.6.186'

if [ "$ROBOT_REAL" == true ]
then
alias hero-start='rosparam load $EMC_SYSTEM_DIR/src/emc_system/config/hero_mrc_config.yaml'
alias rosbot-start='roslaunch rosbot_bringup start_emc.launch'
alias bobo-start='roslaunch rosbot_bringup start_emc.launch name:=bobo'
alias coco-start='roslaunch rosbot_bringup start_emc.launch name:=coco'

alias define-map='rosrun map_server map_server'
else
alias sshbobo='ssh -A -X husarion@$BOBO_IP'
alias sshcoco='ssh -A -X husarion@$COCO_IP'
alias sshhero='ssh -A -X [email protected]'
alias bobo-core='export ROS_MASTER_URI=http://$BOBO_IP:11311'
alias coco-core='export ROS_MASTER_URI=http://$COCO_IP:11311'
alias hero-core='export ROS_MASTER_URI=http://192.168.44.51:11311'
alias mrc-sim='rosrun emc_simulator simulator'
alias sim-rviz='roslaunch emc_simulator viz.launch'
alias mrc-open-door='rostopic pub --once /pyro/open_door std_msgs/Empty "{}"'
alias mrc-speech='rosrun pico_talk speech_server.py'

alias hero-rviz='roslaunch emc_system hero_rviz.launch'
alias rosbot-rviz='roslaunch emc_system rosbot_rviz.launch'
alias bobo-rviz='roslaunch emc_system rosbot_rviz.launch'
alias coco-rviz='roslaunch emc_system rosbot_rviz.launch'
fi
# Change aliases for executables for ros2

# if [ "$ROBOT_REAL" == true ]
# then
# alias hero-start='rosparam load $EMC_SYSTEM_DIR/src/emc_system/config/hero_mrc_config.yaml'
# alias rosbot-start='roslaunch rosbot_bringup start_emc.launch'
# alias bobo-start='roslaunch rosbot_bringup start_emc.launch name:=bobo'
# alias coco-start='roslaunch rosbot_bringup start_emc.launch name:=coco'

# alias define-map='rosrun map_server map_server'
# else
# alias sshbobo='ssh -A -X husarion@$BOBO_IP'
# alias sshcoco='ssh -A -X husarion@$COCO_IP'
# alias sshhero='ssh -A -X [email protected]'
# alias bobo-core='export ROS_MASTER_URI=http://$BOBO_IP:11311'
# alias coco-core='export ROS_MASTER_URI=http://$COCO_IP:11311'
# alias hero-core='export ROS_MASTER_URI=http://192.168.44.51:11311'
# alias mrc-sim='rosrun emc_simulator simulator'
# alias sim-rviz='roslaunch emc_simulator viz.launch'
# alias mrc-open-door='rostopic pub --once /pyro/open_door std_msgs/Empty "{}"'
# alias mrc-speech='rosrun pico_talk speech_server.py'

# alias hero-rviz='roslaunch emc_system hero_rviz.launch'
# alias rosbot-rviz='roslaunch emc_system rosbot_rviz.launch'
# alias bobo-rviz='roslaunch emc_system rosbot_rviz.launch'
# alias coco-rviz='roslaunch emc_system rosbot_rviz.launch'
# fi
32 changes: 24 additions & 8 deletions setup/emc-update-impl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ function _git_clone_or_update
{
local repo_url=$1
local dest=$2
local branch=$3

if [ ! -d "$dest" ]
then
git clone "$repo_url" "$dest"
if [ -n "$branch" ]; then
git -C "$dest" checkout "$branch"
fi
else
git -C "$dest" pull
if [ -n "$branch" ]; then
git -C "$dest" checkout "$branch"
git -C "$dest" pull origin "$branch"
fi
fi
}

Expand All @@ -75,7 +83,7 @@ function _git_clone_or_update
# Install ROS
if [ ! -d /opt/ros/"$EMC_ROS_DISTRO" ]
then
if [ ! -f /etc/apt/sources.list.d/ros-latest.list ]
if [ ! -f /etc/apt/sources.list.d/ros2.list ]
then
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

Expand Down Expand Up @@ -114,7 +122,7 @@ then
fi

# 2) Download packages
_git_clone_or_update https://github.com/tue-robotics/emc_system "$EMC_SYSTEM_DIR"/src/emc_system
_git_clone_or_update https://github.com/tue-robotics/emc_system "$EMC_SYSTEM_DIR"/src/emc_system ros2
_git_clone_or_update https://github.com/tue-robotics/catkin_lint_cmake "$EMC_SYSTEM_DIR"/src/catkin_lint_cmake
_git_clone_or_update https://github.com/tue-robotics/emc_simulator "$EMC_SYSTEM_DIR"/src/emc_simulator
_git_clone_or_update https://github.com/tue-robotics/geolib2 "$EMC_SYSTEM_DIR"/src/geolib2
Expand All @@ -128,19 +136,27 @@ then
fi

# 3) Install dependencies
_make_sure_installed python3-catkin-tools libassimp-dev ros-"${EMC_ROS_DISTRO}"-cv-bridge ros-"${EMC_ROS_DISTRO}"-image-geometry ros-"${EMC_ROS_DISTRO}"-map-server ros-"${EMC_ROS_DISTRO}"-message-generation ros-"${EMC_ROS_DISTRO}"-message-runtime ros-"${EMC_ROS_DISTRO}"-nav-msgs ros-"${EMC_ROS_DISTRO}"-robot-state-publisher ros-"${EMC_ROS_DISTRO}"-joint-state-publisher ros-"${EMC_ROS_DISTRO}"-roscpp ros-"${EMC_ROS_DISTRO}"-rviz ros-"${EMC_ROS_DISTRO}"-shape-msgs ros-"${EMC_ROS_DISTRO}"-tf2 ros-"${EMC_ROS_DISTRO}"-tf ros-"${EMC_ROS_DISTRO}"-xacro
# _make_sure_installed python3-catkin-tools libassimp-dev ros-"${EMC_ROS_DISTRO}"-cv-bridge ros-"${EMC_ROS_DISTRO}"-image-geometry ros-"${EMC_ROS_DISTRO}"-map-server ros-"${EMC_ROS_DISTRO}"-message-generation ros-"${EMC_ROS_DISTRO}"-message-runtime ros-"${EMC_ROS_DISTRO}"-nav-msgs ros-"${EMC_ROS_DISTRO}"-robot-state-publisher ros-"${EMC_ROS_DISTRO}"-joint-state-publisher ros-"${EMC_ROS_DISTRO}"-roscpp ros-"${EMC_ROS_DISTRO}"-rviz ros-"${EMC_ROS_DISTRO}"-shape-msgs ros-"${EMC_ROS_DISTRO}"-tf2 ros-"${EMC_ROS_DISTRO}"-tf ros-"${EMC_ROS_DISTRO}"-xacro
_make_sure_installed ros-"${EMC_ROS_DISTRO}"-desktop ros-"${EMC_ROS_DISTRO}"-ros-base

# 4) Compile
cd "$EMC_SYSTEM_DIR"
if [[ -n "$CI" ]]
then
# suppress status bar in CI
catkin build --workspace "$EMC_SYSTEM_DIR" -DCATKIN_ENABLE_TESTING=OFF --no-status
# suppress status bar in CI
colcon build --packages-select emc_system --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Release
else
catkin build --workspace "$EMC_SYSTEM_DIR" -DCATKIN_ENABLE_TESTING=OFF
colcon build --packages-select emc_system --cmake-args -DCMAKE_BUILD_TYPE=Release
fi

# Source the workspace
if [ -f "$EMC_SYSTEM_DIR/install/setup.bash" ]
then
source "$EMC_SYSTEM_DIR/install/setup.bash"
fi

# 5) Install the libraries
sudo cp "$EMC_SYSTEM_DIR"/devel/lib/libemc_system.so /usr/lib/libemc-framework.so
sudo cp "$EMC_SYSTEM_DIR"/install/emc_system/lib/emc_system/libemc-framework.so /usr/lib/libemc-framework.so
sudo cp "$EMC_SYSTEM_DIR"/src/emc_system/include/emc /usr/include/ -r

trap - ERR
trap - ERR

0 comments on commit 68dc6c0

Please sign in to comment.