This repository was archived by the owner on Nov 26, 2024. It is now read-only.
forked from alexseysua/flight_stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathros2.sh
More file actions
83 lines (69 loc) · 2.79 KB
/
ros2.sh
File metadata and controls
83 lines (69 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# Shell functions and commands for ROS 2 management.
#
# Roberto Masocco <r.masocco@dotxautomation.com>
#
# June 13, 2024
# Copyright 2024 dotX Automation s.r.l.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# shellcheck disable=SC1090,SC2086
# Initialize ROS 2 environment according to the current shell.
ros2init() {
if [[ $# -ne 0 ]]; then
export ROS_DOMAIN_ID=$1
fi
export ROS_VERSION=2
export ROS_PYTHON_VERSION=3
export ROS_DISTRO=humble
CURR_SHELL=$(ps -p $$ | awk 'NR==2 {print $4}')
# Check that the ROS 2 installation is present, and source it
if [[ -f /opt/ros/$ROS_DISTRO/setup.$CURR_SHELL ]]; then
source /opt/ros/$ROS_DISTRO/setup.$CURR_SHELL
elif [[ -f /opt/ros/$ROS_DISTRO/install/setup.$CURR_SHELL ]]; then
source /opt/ros/$ROS_DISTRO/install/setup.$CURR_SHELL
else
echo >&2 "ROS 2 installation not found."
return 1
fi
# Source additional stuff for colcon argcomplete
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.$CURR_SHELL
# Source Ignition Gazebo stuff
if [[ -f /opt/gazebo/fortress/install/setup.$CURR_SHELL ]]; then
source /opt/gazebo/fortress/install/setup.$CURR_SHELL
fi
if [[ -f /opt/ros/ros_gz/install/local_setup.$CURR_SHELL ]]; then
source /opt/ros/ros_gz/install/local_setup.$CURR_SHELL
fi
# Source our fork of rmw_fastrtps
if [[ -f /opt/ros/rmw_fastrtps/install/local_setup.$CURR_SHELL ]]; then
source /opt/ros/rmw_fastrtps/install/local_setup.$CURR_SHELL
fi
# Source additional DUA stuff
if [[ -f /opt/ros/dua-utils/install/local_setup.$CURR_SHELL ]]; then
source /opt/ros/dua-utils/install/local_setup.$CURR_SHELL
fi
# Source workspace if present
if [[ -f /home/neo/workspace/install/local_setup.$CURR_SHELL ]]; then
source /home/neo/workspace/install/local_setup.$CURR_SHELL
fi
}
# Alias for colcon build command with maximum output
alias cbuild='colcon build --event-handlers console_direct+ --symlink-install'
# Aliases for ROS 2 daemon management
alias ros2start='ros2 daemon start'
alias ros2stop='ros2 daemon stop'
alias ros2status='ros2 daemon status'
alias ros2reset='ros2 daemon stop; ros2 daemon start'
# Alias for Gazebo Classic that includes environment variables for HiDPI
alias gazebo='QT_AUTO_SCREEN_SCALE_FACTOR=0 QT_SCREEN_SCALE_FACTORS=[1.0] /usr/bin/gazebo'