11#! /bin/bash
2- # setup_env .sh - Script to set up the ROS2 environment with a specified virtual environment
2+ # activate_workspace .sh - Activate Python virtual environment and ROS2 workspace
33#
4- # Usage:
5- # source setup_env.sh [venv_name]
4+ # DESCRIPTION:
5+ # This script sets up the complete development environment for the Coffee Buddy project.
6+ # It activates the specified Python virtual environment, sources the ROS2 installation,
7+ # and configures the workspace overlay. This provides a one-command setup for development.
68#
7- # Example:
8- # source setup_env.sh coffee_buddy_venv
9+ # The script handles all path resolution automatically and can be run from any directory.
10+ # It uses intelligent workspace detection to source the appropriate ROS2 environment
11+ # and workspace overlay files.
12+ #
13+ # USAGE:
14+ # source activate_workspace.sh [venv_name]
15+ #
16+ # PARAMETERS:
17+ # venv_name Optional. Name of the virtual environment to activate.
18+ # Default: coffee_buddy_venv
19+ #
20+ # EXAMPLES:
21+ # # Use default virtual environment
22+ # source activate_workspace.sh
23+ #
24+ # # Use specific virtual environment
25+ # source activate_workspace.sh my_custom_venv
26+ #
27+ # # Run from any directory
28+ # cd coffee_ws
29+ # source ../scripts/activate_workspace.sh
30+ #
31+ # REQUIREMENTS:
32+ # - Virtual environment must exist in project root directory
33+ # - ROS2 must be installed (/opt/ros/*)
34+ # - Workspace must be built (install/setup.bash exists)
35+ #
36+ # WHAT IT DOES:
37+ # 1. Activates the specified Python virtual environment
38+ # 2. Sources ROS2 base installation
39+ # 3. Sources the workspace overlay (if built)
40+ # 4. Provides confirmation of successful setup
41+ #
42+ # NOTE:
43+ # This script must be SOURCED, not executed, to modify the current shell environment.
944
1045# Check if script is being sourced
1146if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
@@ -29,27 +64,34 @@ COFFEE_WS_PATH="$REPO_ROOT/coffee_ws"
2964# Check if the venv exists
3065if [ ! -d " $VENV_PATH " ]; then
3166 echo " Error: Virtual environment not found at $VENV_PATH "
67+ echo " Please create the virtual environment first:"
68+ echo " python3 -m venv $VENV_PATH "
3269 return 1
3370fi
3471
35- echo " Setting up environment with virtual environment: $VENV_NAME "
72+ echo " Activating workspace environment..."
73+ echo " Virtual environment: $VENV_NAME "
74+ echo " Workspace: $COFFEE_WS_PATH "
3675
3776# Step 1: Activate the virtual environment
38- echo " Activating virtual environment..."
77+ echo " [1/3] Activating virtual environment..."
3978source " $VENV_PATH /bin/activate"
4079
4180# Step 2: Change to coffee_ws directory and source ROS environment
42- echo " Changing to coffee workspace and sourcing ROS ..."
81+ echo " [2/3] Sourcing ROS2 environment ..."
4382pushd " $COFFEE_WS_PATH " > /dev/null
4483source " $SCRIPTS_PATH /ros-source.sh"
4584
4685# Step 3: Run ros-source function to set up ROS2 and workspace
47- echo " Setting up ROS2 and workspace..."
86+ echo " [3/3] Configuring workspace overlay ..."
4887ros-source
4988
5089# Return to original directory
5190popd > /dev/null
5291
53- echo " Environment setup complete!"
54- echo " Virtual environment: $VENV_NAME "
55- echo " ROS2 and workspace are ready to use."
92+ echo " "
93+ echo " ✓ Workspace activation complete!"
94+ echo " Virtual environment: $VENV_NAME "
95+ echo " Python: $( which python) "
96+ echo " ROS2 workspace ready for development"
97+ echo " "
0 commit comments