Chart
Airsim install
- Install Unreal Engine
1. Download Epic Game Launcher
2. Install Unreal Engine version 4.27
- Build AirSim
1. Install Visual Studio 2022 that has options
1.1 Desktop Development with C++
1.2 Windows 10 SDK 10.0.19041
1.3 latest .NET Framework SDK under the 'Individual Components' tab
2. Start Developer Command Prompt for VS 2022 in Administrator mode
3. Install github-desktop
4.
git clone https://github.com/Microsoft/AirSim.git
cd AirSim
5. make it ready to use plugin bits in the Unreal\Plugins folder by using,
build.cmd
- Build Unreal Basic Project
1. Navigate to folder AirSim\Unreal\Environments\Blocks
2. Double click on Blocks.sln file to Visual Studio
3. Make sure Visual Studio 2022 setting
3.1 'Edit->Editor Preferences->Source Code' inside the Unreal Editor and select 'Visual Studio 2022' for the 'Source Code Editor' setting.
3.2 Make sure Blocks project is the startup project
3.3 Make sure configuration is set to DebugGame_Editor and Win64
4. Hit F5 to run
- Use AirSim
1. Press the Play button
WSL2 setting ( Ubuntu18.04 )
1. Update Windows
2. Enable the Windows Subsystem for Linux & Virtual Machine feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
3. Download the Linux kernel update package
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
4. Set WSL2 as your default version
wsl --set-default-version 2
5. Install Ubuntu-18.04 LTS from Microsoft Store & Set name, password
PX4 SITL install in WSL2 Ubuntu18.04
1. Open WSL2 Ubuntu 18.04
2. Get the PX4 source code and build the posix STIL version
2.1
mkdir -p PX4
cd PX4
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
2.2 As Ubuntu 18.04 has python 3.6 version as a default, upgrade to python 3.8 to prevent 'sympy' version error
python3 -V
sudo apt-get update
sudo apt list | grep python3.8
sudo apt-get install python3.8
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
# select python3.8 manual mode
sudo update-alternatives --config python3
python3 -V
# set environment to python3.8
sudo apt-get remove python3-apt
sudo apt-get install python3-apt
sudo pip install --upgrade pip
sudo pip install --upgrade pip3
2.3 Build
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools
cd PX4-Autopilot
# you can set latest version >=1.12.0
git checkout v1.12.0
git submodule sync --recursive
git submodule update --init --recursive
make px4_sitl_default none_iris
3. TCP & UDP setting
3.1 Widows AirSim
3.1.1 Check localhost IP from cmd
# Copy WSL IPv4 = localhost ip
ipconfig
3.1.2 Open incoming TCP port 4560 and incoming UDP port 14540 using your firewall configuration.
3.1.3 Open Documents\AirSim\setting.json and copy & paste
{
"SettingsVersion": 1.2,
"SimMode": "Multirotor",
"ClockType": "SteppableClock",
"Vehicles": {
"PX4": {
"VehicleType": "PX4Multirotor",
"UseSerial": false,
"LockStep": true,
"UseTcp": true,
"TcpPort": 4560,
"ControlIp": "remote",
"ControlPortLocal": 14540,
"ControlPortRemote": 14580,
"LocalHostIp": "172.27.80.1",
"Sensors": {
"Imu" : {
"SensorType": 2,
"Enabled": true
},
"LidarCustom": {
"SensorType": 6,
"Enabled": true,
"NumberOfChannels": 16,
"PointsPerSecond": 10000,
"X": 0,
"Y": 0,
"Z": -1,
"DrawDebugPoints": true
}
},
"Cameras": {
"front_center_custom": {
"CaptureSettings": [
{
"PublishToRos": 1,
"ImageType": 0,
"Width": 640,
"Height": 480,
"FOV_Degrees": 27,
"DepthOfFieldFstop": 2.8,
"DepthOfFieldFocalDistance": 200.0,
"DepthOfFieldFocalRegion": 200.0,
"TargetGamma": 1.5
}
],
"X": 0.50, "Y": 0, "Z": 0.10,
"Pitch": 0, "Roll": 0, "Yaw": 0
},
"front_left_custom": {
"CaptureSettings": [
{
"PublishToRos": 1,
"ImageType": 0,
"Width": 672,
"Height": 376,
"FOV_Degrees": 90,
"TargetGamma": 1.5
},
{
"PublishToRos": 1,
"ImageType": 1,
"Width": 672,
"Height": 376,
"FOV_Degrees": 90,
"TargetGamma": 1.5
}
],
"X": 0.50, "Y": -0.06, "Z": 0.10,
"Pitch": 0.0, "Roll": 0.0, "Yaw": 0.0
},
"front_right_custom": {
"CaptureSettings": [
{
"PublishToRos": 1,
"ImageType": 0,
"Width": 672,
"Height": 376,
"FOV_Degrees": 90,
"TargetGamma": 1.5
}
],
"X": 0.50, "Y": 0.06, "Z": 0.10,
"Pitch": 0.0, "Roll": 0.0, "Yaw": 0.0
}
},
"X": 2, "Y": 0, "Z": 0,
"Pitch": 0, "Roll": 0, "Yaw": 0
}
},
"SubWindows": [
{"WindowID": 0, "ImageType": 0, "CameraName": "front_left_custom", "Visible": true},
{"WindowID": 1, "ImageType": 0, "CameraName": "front_center_custom", "Visible": false},
{"WindowID": 2, "ImageType": 0, "CameraName": "front_right_custom", "Visible": true}
]
}
3.2 WSL2
3.2.1 PX4 in SITL mode changing request
sudo gedit ~/.bashrc
# copy & paste localhost ip
export PX4_SIM_HOST_ADDR=172.0.0.0
#export PX4_SIM_HOST_ADDR=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
# apply environment settings
source ~/.bashrc
Start PX4 in SITL with Airsim
1. Start AirSim
2. Start PX4 in SITL
# WSL 2 Ubuntu 18.04
cd PX4/PX4-Autopilot
make px4_sitl_default none_iris
3. Play
AirSim ROS Packages
0. Change AirSim setting file(Windows) to example setting.json
1. Install ROS melodic
https://wiki.ros.org/melodic/Installation/Ubuntu
2. Install mavros package and tf2 sensor, catkin_tools
sudo apt-get install ros-melodic-tf2-sensor-msgs ros-melodic-tf2-geometry-msgs ros-melodic-mavros*
sudo apt-get install python-catkin-tools
# pip install catkin_tools
3. Build AirSim in WSL2 Ubuntu 18.04
git clone https://github.com/Microsoft/AirSim.git
cd AirSim
sudo ./setup.sh
sudo ./build.sh
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
# you should make catkin workspace initialized in ~/ros/src folder
cd ros/src
catkin_init_workspace
cd ../
catkin_make
# gcc --version
# if result < 8,
catkin_make -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
echo "source ~/AirSim/ros/devel/setup.bash" >> ~/.bashrc
echo "export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0" >> ~/.bashrc
source ~/.bashrc
roslaunch airsim_ros_pkgs airsim_node.launch output:=screen host:=$WSL_HOST_IP
roslaunch airsim_ros_pkgs rviz.launch
4. AirSim ROS Wrapper Node and tutorials
https://microsoft.github.io/AirSim/airsim_ros_pkgs/#airsim-ros-wrapper-node
https://microsoft.github.io/AirSim/airsim_tutorial_pkgs/
Control with Q Ground Control
0. Install QGC in WSL2 Ubuntu 18.04
https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html#ubuntu
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libqt5gui5 -y
sudo apt install libfuse2 -y
# start new terminal which is not in super user mode
chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage
1. Play
Collecting UAV data from mavros
1. mavros Installation
sudo apt-get install ros-melodic-mavros ros-kinetic-melodic-extras
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo bash ./install_geographiclib_datasets.sh
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src
sudo apt-get install python-catkin-tools python-rosinstall-generator -y
wstool init ~/catkin_ws/src
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
catkin_make
source devel/setup.bash
2. Get mavros rostopic data
https://docs.px4.io/main/en/simulation/ros_interface.html
# ip:windows cmd ipconfig wsl
roslaunch mavros px4.launch fcu_url:="udp://:14550@172.27.80.1"
# export WSL_HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
# roslaunch mavros px4.launch fcu_url:="udp://:14550@"+$WSL_HOST_IP
Check rqt - Plugins - Topics - Topic Monitor
3. Control IRIS drone with mavros
https://docs.px4.io/main/en/ros/mavros_offboard_cpp.html
Reference
https://microsoft.github.io/AirSim/build_windows/
https://microsoft.github.io/AirSim/unreal_proj/
https://learn.microsoft.com/en-us/windows/wsl/install-manual
https://microsoft.github.io/AirSim/px4_sitl/
https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-8-on-ubuntu-18-04-lts/
https://microsoft.github.io/AirSim/px4_sitl_wsl2/
https://microsoft.github.io/AirSim/airsim_ros_pkgs/
https://microsoft.github.io/AirSim/airsim_tutorial_pkgs/
https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html#ubuntu
https://docs.px4.io/main/en/ros/mavros_installation.html
Future work
1. Connect with ROS and QGC ( done )
2. Fly along Given Trajectory ( now working )
3. Collision Avoidance
'TECH > 본업' 카테고리의 다른 글
[Linux] commands (0) | 2023.01.16 |
---|
댓글