feat(fish): Add initialize script

This commit is contained in:
2025-09-18 13:18:26 +02:00
parent 2620a10011
commit 232afbb059
3 changed files with 39 additions and 1 deletions

36
activate.fish Normal file
View File

@@ -0,0 +1,36 @@
export env_name="ros2-lectures"
# Check if a previous initialization has occurred
if test -n "$__ACTIVATE_INITIALIZED"
exit 1
end
export __ACTIVATE_INITIALIZED="1"
# Check if running inside distrobox
if test -f /run/.containerenv; or test -n "$CONTAINER_ID"
bass source /opt/ros/jazzy/setup.bash
bass source ./install/setup.bash
# Set environment variable for the prompt prefix
set -gx ROS2_LECTURES_ACTIVE 1
# Save the original prompt function if it exists
if not functions -q __ros2_lectures_orig_prompt
if functions -q fish_prompt
functions -c fish_prompt __ros2_lectures_orig_prompt
else
function __ros2_lectures_orig_prompt
echo -n (whoami)'@'(prompt_hostname)' '(set_color $fish_color_cwd)(prompt_pwd)(set_color normal)'> '
end
end
end
# Define new prompt with ros2-lectures prefix
function fish_prompt
echo -n (set_color green)'('$env_name')'(set_color normal)
__ros2_lectures_orig_prompt
end
else
echo "This script should only be run inside a distrobox container"
exit 1
end

View File

@@ -21,6 +21,7 @@ add_executable(les2_service src/les2/service_server.cpp)
add_executable(les2_service_client src/les2/service_client.cpp) add_executable(les2_service_client src/les2/service_client.cpp)
add_executable(les3_action_server src/les3/action_server.cpp) add_executable(les3_action_server src/les3/action_server.cpp)
add_executable(les3_action_client src/les3/action_client.cpp)
ament_target_dependencies(les1_clock rclcpp) ament_target_dependencies(les1_clock rclcpp)
ament_target_dependencies(les1_publisher rclcpp std_msgs geometry_msgs les_interface) ament_target_dependencies(les1_publisher rclcpp std_msgs geometry_msgs les_interface)
@@ -30,6 +31,7 @@ ament_target_dependencies(les2_service rclcpp les_interface)
ament_target_dependencies(les2_service_client rclcpp les_interface) ament_target_dependencies(les2_service_client rclcpp les_interface)
ament_target_dependencies(les3_action_server rclcpp rclcpp_action les_interface) ament_target_dependencies(les3_action_server rclcpp rclcpp_action les_interface)
ament_target_dependencies(les3_action_client rclcpp rclcpp_action les_interface)
install ( install (
TARGETS TARGETS
@@ -39,6 +41,7 @@ install (
les2_service les2_service
les2_service_client les2_service_client
les3_action_server les3_action_server
les3_action_client
DESTINATION lib/${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME}
) )

View File

@@ -29,7 +29,6 @@ public:
NodeActionServer() NodeActionServer()
: Node("node_les3_action_server") : Node("node_les3_action_server")
{ {
// Communication and timer objects:
// Callback groups make thread handling possible // Callback groups make thread handling possible
cb_group_ = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant); cb_group_ = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);