Last active
May 23, 2024 02:33
-
-
Save sandyUni/6380bbaaa3306446ab10e499016b2093 to your computer and use it in GitHub Desktop.
setup_xtdron_workstation.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# setup XTDRONE with gitee connection | |
# this script assumes you already have ros and gazebo installed | |
# for more infomation, please refers to https://www.yuque.com/xtdrone/manual_cn/basic_config_1.11 and https://github.com/robin-shaun/XTDrone | |
set -x | |
sudo apt-get install -y ninja-build exiftool python-argparse python-empy python-toml python-numpy python-yaml python-dev python-pip ninja-build protobuf-compiler libeigen3-dev genromfs xmlstarlet libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev | |
pip2 install pandas jinja2 pyserial cerberus pyulog numpy toml pyquaternion | |
pip3 install packaging numpy empy toml pyyaml jinja2 | |
sudo apt-get install git build-essential | |
WORK_DIR=$(pwd) | |
ROS_DIST=`ls /opt/ros` || echo "ros not installed in the default folder: /opt/ros, please make sure you have sourced it" | |
if [ -n $ROS_DIST ] | |
then | |
source /opt/ros/$ROS_DIST/setup.sh || echo "soure error, do you use bash shell? or have your ros correctly installed?" | |
fi | |
echo "Your ros version is $(rosversion -d)" | |
ROS_DIST=$(rosversion -d) | |
ROS_PATH=$(which -a roscore) | |
if [ -z $ROS_PATH ] | |
then | |
echo "can not find roscore, exit" | |
exit 3 | |
fi | |
ROS_PATH_BIN="$(dirname "$ROS_PATH")" | |
ROS_PATH_DIST="$(dirname "$ROS_PATH_BIN")" | |
# setup mavros and mavros-extras in ./ | |
echo "install mavros and mavros-extras" | |
sudo apt-get install ros-$ROS_DIST-mavros ros-$ROS_DIST-extras | |
wget -N https://gitee.com/antoi/mavros/raw/master/mavros/scripts/install_geographiclib_datasets.sh || (echo "can not download file, exit" && exit 4 ) | |
sudo ./install_geographiclib_datasets.sh | |
# steup px4 | |
if [ -d PX4_Firmware ] | |
then | |
echo "PX4_Firmware fodler already exists, we will use it insead of git a new one" | |
cd PX4_Firmware | |
else | |
git clone https://gitee.com/robin_shaun/PX4_Firmware | |
cd PX4_Firmware | |
git checkout -b xtdrone/dev v1.11.0-beta1 || ( echo "checkout faied, exit." && exit 2 ) | |
fi | |
cat > ../submodule.tmp << EOF | |
[submodule "mavlink/include/mavlink/v2.0"] | |
path = mavlink/include/mavlink/v2.0 | |
url = https://gitee.com/robin_shaun/c_library_v2.git | |
branch = master | |
[submodule "src/drivers/uavcan/libuavcan"] | |
path = src/drivers/uavcan/libuavcan | |
url = https://gitee.com/robin_shaun/uavcan.git | |
branch = px4 | |
[submodule "Tools/jMAVSim"] | |
path = Tools/jMAVSim | |
url = https://gitee.com/robin_shaun/jMAVSim.git | |
branch = master | |
[submodule "Tools/sitl_gazebo"] | |
path = Tools/sitl_gazebo | |
url = https://gitee.com/robin_shaun/sitl_gazebo.git | |
branch = master | |
[submodule "src/lib/matrix"] | |
path = src/lib/matrix | |
url = https://gitee.com/robin_shaun/Matrix.git | |
branch = master | |
[submodule "src/lib/ecl"] | |
path = src/lib/ecl | |
url = https://gitee.com/robin_shaun/ecl.git | |
branch = master | |
[submodule "boards/atlflight/cmake_hexagon"] | |
path = boards/atlflight/cmake_hexagon | |
url = https://gitee.com/robin_shaun/cmake_hexagon.git | |
branch = px4 | |
[submodule "src/drivers/gps/devices"] | |
path = src/drivers/gps/devices | |
url = https://gitee.com/robin_shaun/GpsDrivers.git | |
branch = master | |
[submodule "src/modules/micrortps_bridge/micro-CDR"] | |
path = src/modules/micrortps_bridge/micro-CDR | |
url = https://gitee.com/robin_shaun/micro-CDR.git | |
branch = px4 | |
[submodule "platforms/nuttx/NuttX/nuttx"] | |
path = platforms/nuttx/NuttX/nuttx | |
url = https://gitee.com/robin_shaun/NuttX.git | |
branch = px4_firmware_nuttx-9.1.0+ | |
[submodule "platforms/nuttx/NuttX/apps"] | |
path = platforms/nuttx/NuttX/apps | |
url = https://gitee.com/robin_shaun/NuttX-apps.git | |
branch = px4_firmware_nuttx-9.1.0+ | |
[submodule "platforms/qurt/dspal"] | |
path = platforms/qurt/dspal | |
url = https://gitee.com/robin_shaun/dspal.git | |
[submodule "Tools/flightgear_bridge"] | |
path = Tools/flightgear_bridge | |
url = https://gitee.com/robin_shaun/PX4-FlightGear-Bridge.git | |
branch = master | |
[submodule "Tools/jsbsim_bridge"] | |
path = Tools/jsbsim_bridge | |
url = https://gitee.com/robin_shaun/px4-jsbsim-bridge.git | |
[submodule "src/examples/gyro_fft/CMSIS_5"] | |
path = src/examples/gyro_fft/CMSIS_5 | |
url = https://gitee.com/mirrors/CMSIS_5 | |
EOF | |
mv .gitmodules .gitmodules.swp | |
mv -f ../submodule.tmp .gitmodules | |
# cat > ../submodule.tmp.PX4_Firmware << EOF | |
# [submodule "jMAVlib"] | |
# path = jMAVlib | |
# url = https://gitee.com/mfary/jMAVlib | |
# branch = master | |
# EOF | |
# mv Tools/jMAVSim/.gitmodules Tools/jMAVSim/.gitmodules.swp | |
# mv -f ../submodule.tmp.PX4_Firmware Tools/jMAVSim/.gitmodules Tools/jMAVSim/.gitmodules | |
DONT_RUN=1 make px4_sitl_default gazebo | |
cd .. | |
# download XTDrone source | |
echo "download XTDrone source" | |
echo "current folder: $(pwd)" | |
if [ -d XTDrone ] | |
then | |
echo "Directory XTDrone already exists, use it insead of git cloning" | |
cd XTDrone | |
else | |
git clone https://gitee.com/robin_shaun/XTDrone.git | |
cd XTDrone | |
git submodule update --init --recursive | |
fi | |
cp sensing/gimbal/gazebo_gimbal_controller_plugin.cpp $WORK_DIR/PX4_Firmware/Tools/sitl_gazebo/src/ | |
cp sitl_config/init.d-posix/rcS $WORK_DIR/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/ | |
cp sitl_config/worlds/* $WORK_DIR/PX4_Firmware/Tools/sitl_gazebo/worlds/ | |
cp -r sitl_config/models/* $WORK_DIR/PX4_Firmware/Tools/sitl_gazebo/models/ | |
# this following command will not run because the setupfile will | |
# cp -r sitl_config/models/{3d_gpu_lidar,3d_lidar,hokuyo_lidar,kinect,stereo_camera} $WORK_DIR/.gazebo/models/ | |
cp sitl_config/launch/* $WORK_DIR/PX4_Firmware/launch/ | |
cd ../ | |
# generate source file | |
echo "Generating source file.. " | |
SOURCE_STR="#THIS file is auto-generated by steup_xtdron_env.sh"$'\n' | |
#ros related | |
SOURCE_STR=$SOURCE_STR"source $ROS_PATH_DIST/setup.bash"$'\n' | |
SOURCE_STR=$SOURCE_STR"source $WORK_DIR/PX4_Firmware/Tools/setup_gazebo.bash $WORK_DIR/PX4_Firmware $WORK_DIR/PX4_Firmware/build/px4_sitl_default" | |
SOURCE_STR="$SOURCE_STR"$'\n' | |
SOURCE_STR=$SOURCE_STR"export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:$WORK_DIR/PX4_Firmware"$'\n' | |
SOURCE_STR=$SOURCE_STR"export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:$WORK_DIR/PX4_Firmware/Tools/sitl_gazebo"$'\n' | |
# gazebo related | |
SOURCE_STR=$SOURCE_STR"if [ -n \$GAZEBO_MODEL_PATH ]"$'\n'"then"$'\n'"export GAZEBO_MODEL_PATH=\$GAZEBO_MODEL_PATH:$WORK_DIR/XTDrone/sitl_config/models/"$'\n'"else"$'\n'"export GAZEBO_MODEL_PATH=$WORK_DIR/XTDrone/sitl_config/models/"$'\n'"fi"$'\n' | |
SOUCE_NAME=source_setup_xt_env.bash | |
echo "$SOURCE_STR" > $SOUCE_NAME | |
echo "$SOUCE_NAME"' is ready, to setup your XTDrone environment, run the command' "\"source $SOUCE_NAME\"" | |
echo 'NOTE: if you want to use gazebo to open world file in XTDrone/sitl_config/worlds, RUN' "\"source $SOUCE_NAME\" firstly." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment