Skip to content

MikaYeghi/aerial_robotics

 
 

Repository files navigation

aerial_robotics

Install requirements

conda create -n aerial_robotics python=3.10
conda activate aerial_robotics

sudo apt-get install \
ros-noetic-libmavconn \
ros-noetic-message-to-tf \
ros-noetic-mavros \
ros-noetic-mavros-msgs \
ros-noetic-apriltag \
ros-noetic-apriltag-ros \
libgstreamer-plugins-base1.0-dev \
python3-numpy \
python3-jinja2 \
python-pexpect

# NOTE: the following line throws an error for me, you can skip it.
sudo apt-get install python-pip

# Install python packages
pip install \
mavproxy==1.8.49 \
monotonic \
empy \
catkin_pkg

# [MAVProxy Version: Verify you have mavproxy version 1.8.49 installed]
pip show mavproxy

# [MAVProxy Version: If you still have a different (higher) version, your pip cache might be the issue]
pip cache purge
pip install --force-reinstall mavproxy==1.8.49
pip show mavproxy

sudo /opt/ros/melodic/lib/mavros/install_geographiclib_datasets.sh

Setup and Build

mkdir -p $HOME/aerial_robotics_ws/src

cd $HOME/aerial_robotics_ws
catkin config -DCMAKE_BUILD_TYPE=Release
catkin build

cd $HOME/aerial_robotics_ws/src
git clone --recursive -b master https://github.com/robowork/aerial_robotics

cd $HOME/aerial_robotics_ws && git clone --recursive [email protected]:Pratiquea/ardupilot.git && cd ardupilot
git checkout remotes/origin/plane-4.2/feature/thrust_attitude_support
./Tools/gittools/submodule-sync.sh
./Tools/environment_install/install-prereqs-ubuntu.sh -y

# The last command will pull the newest mavproxy version, higher than the one that is known to work with the Plane-4.2 stack so we will have to downgrade
pip install mavproxy==1.8.49

# Again, verify you now have mavproxy version 1.8.49 by following the previous section's steps:
# [MAVProxy Version: Verify you have mavproxy version 1.8.49 installed]
# [MAVProxy Version: If you still have a different (higher) version, your pip cache might be the issue]

# Apply some patches and extra files
cd $HOME/aerial_robotics_ws/ardupilot
patch -p0 < ../src/aerial_robotics/deps/vehicleinfo_py.patch 
cp ../src/aerial_robotics/deps/ArduPlane_MiniHawk_Gazebo.parm ./Tools/autotest/default_params

cd $HOME/aerial_robotics_ws && git clone --recursive https://github.com/khancyr/ardupilot_gazebo && cd ardupilot_gazebo
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 12 && sudo make install

# Apply some patches and rebuild
cd $HOME/aerial_robotics_ws/ardupilot_gazebo
patch -p0 < ../src/aerial_robotics/deps/ArduPilotPlugin_hh.patch
patch -p0 < ../src/aerial_robotics/deps/ArduPilotPlugin_cc.patch
cd build && make -j 12 && sudo make install

cd $HOME/aerial_robotics_ws && git clone --recursive https://github.com/PX4/sitl_gazebo.git && cd sitl_gazebo
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ..
pip install Jinja2 numpy
make -j 12 && sudo make install

### NOTES ###
# 1) The sitl_gazebo make install script does not copy libphysics_msgs.so to the install path, do so manually:
sudo cp $HOME/aerial_robotics_ws/sitl_gazebo/build/libphysics_msgs.so /usr/lib/x86_64-linux-gnu/mavlink_sitl_gazebo/plugins/
# 2) The sitl_gazebo package installs its own libLiftDragPlugin.so (breaks flight transition simulation) which can overlap with the version of gazebo-9, as they are both installed under the /usr/lib/x86_64-linux-gnu system path, so we have to hide it:
sudo mv /usr/lib/x86_64-linux-gnu/mavlink_sitl_gazebo/plugins/libLiftDragPlugin.so /usr/lib/x86_64-linux-gnu/mavlink_sitl_gazebo/plugins/libLiftDragPlugin.so.PX4_SITL_VERSION

# Add the following lines at the end of your ~/.bashrc file
export GAZEBO_MODEL_PATH=/usr/share/gazebo-11/models:${GAZEBO_MODEL_PATH}
export GAZEBO_RESOURCE_PATH=/usr/share/gazebo-11:${GAZEBO_RESOURCE_PATH}
export GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:${GAZEBO_PLUGIN_PATH}
export GAZEBO_MODEL_PATH=/usr/share/mavlink_sitl_gazebo/models:${GAZEBO_MODEL_PATH}
export GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/mavlink_sitl_gazebo/plugins:${GAZEBO_PLUGIN_PATH}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GAZEBO_PLUGIN_PATH}

# Copy gazebo models to gazebo resources user folder
cp -r $HOME/aerial_robotics_ws/src/aerial_robotics/robowork_minihawk_gazebo/models/* $HOME/.gazebo/models/

cd $HOME/aerial_robotics_ws
export PYTHONPATH="$PYTHONPATH:/usr/lib/python3/dist-packages"
catkin build

# Install additional python packages
pip install pexpect \
rospkg \
defusedxml

Simulation

[Launch ROS Gazebo SIM in new terminal]:
roslaunch robowork_minihawk_gazebo minihawk_playpen.launch

[Launch Ardupilot Gazebo SITL in new terminal]:
cd $HOME/aerial_robotics_ws/ardupilot
./Tools/autotest/sim_vehicle.py -v ArduPlane -f gazebo-minihawk --model gazebo-quadplane-tilttri --console  # --map

[Launch Rviz in new terminal]:
rviz -d $HOME/aerial_robotics_ws/src/aerial_robotics/robowork_minihawk_launch/config/minihawk_SIM.rviz

### MAVProxy-based commanding ###

[Load sample mission waypoints in Gazebo SITL terminal]
wp load ../src/aerial_robotics/robowork_minihawk_gazebo/resources/waypoints.txt

### MAVROS-based commanding ###

[Launch ROS node in new terminal 1]:
ROS_NAMESPACE="minihawk_SIM" roslaunch robowork_minihawk_launch vehicle1_apm_SIM.launch

[Invoke ROS services in new terminal 2]:
rosservice call /minihawk_SIM/mavros/set_mode "custom_mode: 'GUIDED'"
rosservice call /minihawk_SIM/mavros/cmd/arming True
rosservice call /minihawk_SIM/mavros/cmd/takeoff "{min_pitch: 0.0, yaw: 0.0, latitude: 0.0, longitude: 0.0, altitude: 10.0}"

[Alternatively, invoke ROS services in new terminal 2 to run auto (waypoint) mission]:
rosservice call /minihawk_SIM/mavros/set_mode "custom_mode: 'AUTO'"
rosservice call /minihawk_SIM/mavros/cmd/arming True   ###Required if the mission hasn't started yet### 

### Once the vehicle reaches its final waypoint (over the building) the camera will be looking at an apriltag marker  ###

[Observe ROS topic output of apriltag_ros node in new terminal 3 (relative pose in camera frame coordinates with respect to detected apriltag marker)]:
rostopic echo /minihawk_SIM/MH_usb_camera_link_optical/tag_detections

### Try switching between some Quadplane modes and control the aircraft motion ###

# https://ardupilot.org/plane/docs/qloiter-mode.html#qloiter-mode
[Publish ROS topic in new terminal 3 (this is required to virtually center the rc sticks, 4 first channels are 0:roll(-left,+right), 1:pitch(-up,+down), 2:throttle(-down,+up), 3:yaw(-left,+right))]:
rostopic pub -r 10 /minihawk_SIM/mavros/rc/override  mavros_msgs/OverrideRCIn "channels: [1500, 1500, 1500, 1500, 1800, 1000, 1000, 1800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
[Invoke ROS service in terminal 2]:
rosservice call /minihawk_SIM/mavros/set_mode "custom_mode: 'QLOITER'"

# https://ardupilot.org/plane/docs/qhover-mode.html
[Publish ROS topic in new terminal 3 (this is required to virtually trim the rc sticks)]:
rostopic pub -r 10 /minihawk_SIM/mavros/override  mavros_msgs/OverrideRCIn "channels: [1464, 1598, 1466, 1500, 1800, 1000, 1000, 1800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
[Invoke ROS service in terminal 2]:
rosservice call /minihawk_SIM/mavros/set_mode "custom_mode: 'QHOVER'"

# https://ardupilot.org/plane/docs/qland-mode.html
[Invoke ROS service in terminal 2]:
rosservice call /minihawk_SIM/mavros/set_mode "custom_mode: 'QLAND'"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 68.8%
  • Python 31.2%