Skip to content

Strroke21/OpenVins-with-ROS2-Ardupilot

Repository files navigation

1. Install Dependencies

sudo apt-get install libeigen3-dev libboost-all-dev libceres-dev

2. Install Opencv

git clone https://github.com/opencv/opencv_contrib/
cd opencv_contrib
git checkout 4.8.0
cd ..
git clone https://github.com/opencv/opencv/
cd opencv
git checkout 4.8.0
mkdir opencv/build/
cd opencv/build/
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
make -j8
sudo make install

3. clone the Openvins Repo:

mkdir -p ~/workspace/catkin_ws_ov/src/
cd ~/workspace/catkin_ws_ov/src/
git clone https://github.com/rpng/open_vins/
cd ..
colcon build #ROS2

echo "source ~/workspace/catkin_ws_ov/install/setup.sh" >> ~/.bashrc
source ~/.bashrc

4. Install ROS2 Humble

follow instructions for ros2 install

https://github.com/Strroke21/V-SLAM-with-RTABMAP-and-Realsense-D4XX

5. edit config file in given as per your sensors and topics (make a custom config folder and add below files in it and keep the folder inside /openvins/config)

    estimator_config.yaml #set use_stereo: false (if mono cam else set true for stereo)
    kalibr_imucam_chain.yaml # add your camera topic in this file 
    kalibr_imu_chain.yaml # add imu topic in this file 

6. Launch the Node: (before launching node make sure IMU noise parameters are correct)

#camera

ros2 launch realsense2_camera rs_launch.py   enable_depth:=true   enable_color:=true   enable_sync:=true   depth_module.depth_profile:=640,480,60   rgb_camera.color_profile:=640,480,60 enable_sync:=true enable_gyro:=true enable_accel:=true unite_imu_method:=2 gyro_fps:=200 accel_fps:=200
#openvins

ros2 run ov_msckf run_subscribe_msckf --ros-args -p config_path:=/home/deathstroke/workspace/catkin_ws_ov/src/open_vins/config/rs_d455/estimator_config.yaml -p verbosity:=DEBUG  -p try_zupt:=true -p init_dyn_use:=true

#replace config_path with your path 
#launch rtabmap to view trajectory
ros2 launch rtabmap_launch rtabmap.launch.py \
    rtabmap_args:="--delete_db_on_start" \
    rgb_topic:=/camera/camera/color/image_raw \
    camera_info_topic:=/camera/camera/color/camera_info \
    odom_topic:=/odomimu \
    approx_sync:=true \
    depth:=false \
    visual_odometry:=false

7. Ardupilot Params setup

SERIAL1_PROTOCOL = 2 (MAVLink2).

SERIAL1_BAUD = 115 (115200 baud)

VISO_TYPE = 1 (mavlink)

EK3_SRC1_POSXY = 6 (ExternalNav)

EK3_SRC1_VELXY = 6 (ExternalNav)

EK3_SRC1_POSZ = 1 (Baro which is safer)

EK3_SRC1_VELZ = 6 (you can set it to 6 if 1st flight test looks good)

EK3_SRC1_YAW = 1 (Compass)

8. Run the script

python3 ov_ros_main.py #in the script camera 1:downward 0: forward