diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5d0204 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +CMakeLists.txt.user* +/build/ +/log/ +/install/ +.txt +*.txt +settings.json +*.pyc \ No newline at end of file diff --git a/install.bash b/install.bash index 45dcba0..48f8eca 100644 --- a/install.bash +++ b/install.bash @@ -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" @@ -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 diff --git a/setup.bash b/setup.bash index 74c5f4c..2fdbe01 100644 --- a/setup.bash +++ b/setup.bash @@ -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" @@ -23,7 +27,7 @@ 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 @@ -31,6 +35,21 @@ 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 @@ -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 @@ -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 mrc@192.168.44.51' - 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 mrc@192.168.44.51' +# 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 diff --git a/setup/emc-update-impl.bash b/setup/emc-update-impl.bash index 1e90738..972eb2c 100755 --- a/setup/emc-update-impl.bash +++ b/setup/emc-update-impl.bash @@ -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 } @@ -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' @@ -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 @@ -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 \ No newline at end of file