-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathorbbec_femto_bolt_ros1_install.sh
146 lines (126 loc) · 4.21 KB
/
orbbec_femto_bolt_ros1_install.sh
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#
# Copyright 2023 Herman Ye @Auromix
#
# 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.
#
# Description:
# This is a shell script for installing Orbbec Femto Bolt ROS 1 version.
#
# Version: 1.0
# Date: 2023-12-12
# Author: Herman Ye @Auromix
#
# Warning: This script assumes ROS1 Noetic is already installed on Ubuntu20.04.
# set -x
set -e
# Get script directory
SCRIPT_DIR=$(dirname "$0")
# Get the username of the non-root user
USERNAME=$USERNAME
echo "Current user is: $USERNAME"
echo "Script directory is: $SCRIPT_DIR"
# Save logs to files
LOG_FILE="${SCRIPT_DIR}/orbbec_femto_bolt_ros1_install.log"
ERR_FILE="${SCRIPT_DIR}/orbbec_femto_bolt_ros1_install.err"
echo "Cleaning up traces of last installation..."
rm -f ${LOG_FILE}
rm -f ${ERR_FILE}
# Redirect output to console and log files
exec 1> >(tee -a ${LOG_FILE} )
exec 2> >(tee -a ${ERR_FILE} >&2)
# Output log info to console
echo "Installation logs will be saved to ${LOG_FILE}"
echo "Installation errors will be saved to ${ERR_FILE}"
# Waiting to start
echo "Start to install Orbbec Femto Bolt ROS1 Noetic..."
echo "Warning: This script assumes ROS1 Noetic is already installed on Ubuntu20.04."
sleep 3
# Create ROS workspace
echo "Removing old orbbec test workspace..."
rm -rf /home/$USERNAME/orbbec_test_ws
echo "Creating new orbbec test workspace..."
mkdir -p /home/$USERNAME/orbbec_test_ws/src && cd /home/$USERNAME/orbbec_test_ws/src
# Download Camera ROS SDK
echo "Downloading Orbbec ROS1 SDK..."
git clone https://github.com/orbbec/OrbbecSDK_ROS1.git
# Install dependencies
echo "Installing dependencies..."
cd /home/$USERNAME/orbbec_test_ws
rosdep install --from-paths src --ignore-src -r -y
sudo apt install libgflags-dev ros-$ROS_DISTRO-image-geometry ros-$ROS_DISTRO-camera-info-manager -y
sudo apt install ros-$ROS_DISTRO-image-transport ros-$ROS_DISTRO-image-publisher -y
sudo apt install libgoogle-glog-dev libusb-1.0-0-dev libeigen3-dev -y
# Build
echo "Building..."
cd /home/$USERNAME/orbbec_test_ws
catkin_make
# Set workspace environment
echo "Setting workspace environment..."
echo "source /home/$USERNAME/orbbec_test_ws/devel/setup.bash" >> /home/$USERNAME/.bashrc
source /home/$USERNAME/orbbec_test_ws/devel/setup.bash
# Set udev rules for camera
echo "Setting udev rules for camera..."
roscd orbbec_camera
cd script
sudo cp 99-obsensor-libusb.rules /etc/udev/rules.d/99-obsensor-libusb.rules
# Reset udev to activate rules for camera
echo "Resetting udev to activate rules for camera..."
sudo udevadm control --reload && sudo udevadm trigger
# Replug the camera
echo ""
echo "Please replug the camera now and press any key to continue!"
read -n 1
# Verify installation
clear
# Define the colors
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[1;32m'
NC='\033[0m'
# Define the variables to be printed
TEXT1="Orbbec Femto Bolt ROS1 installation completed!"
TEXT2="Please open new terminals and run commands to verify the installation:"
TEXT3="roslaunch orbbec_camera femto_bolt.launch"
TEXT4="rosrun rqt_image_view rqt_image_view /camera/color/image_raw"
# Calculate the center of the terminal window
TERMINAL_WIDTH=$(tput cols)
TEXT1_PADDING=$((($TERMINAL_WIDTH-${#TEXT1})/2))
TEXT2_PADDING=$((($TERMINAL_WIDTH-${#TEXT2})/2))
TEXT3_PADDING=$((($TERMINAL_WIDTH-${#TEXT3})/2))
TEXT4_PADDING=$((($TERMINAL_WIDTH-${#TEXT4})/2))
# Print the text in the center of the screen in the desired colors
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo -e "${GREEN}$(printf '%*s' $TEXT1_PADDING)${TEXT1} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT2} ${NC}"
echo -e "${RED}$(printf '%*s' $TEXT3_PADDING)${TEXT3} ${NC}"
echo -e "${RED}$(printf '%*s' $TEXT4_PADDING)${TEXT4} ${NC}"
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""