# Navigating an Autonomous Underwater ROV With GPS using ROS2 and Pymavlink

**URL:** <https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699>\
**Category:** ArduSub\
**Tags:** ardusub, pymavlink, sitl\
**Created:** [March 12, 2025, 12:47am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699 "2025-03-12T00:47:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsJayMendoza](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/itsjaymendoza/32/14981_2.png) [@itsJayMendoza](https://discuss.bluerobotics.com/u/itsJayMendoza)\
**Post date:** [March 12, 2025, 12:47am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/1 "2025-03-12T00:47:44Z")

</div>

I am currently working on an autonomous underwater ROV using Ubuntu, ROS2, Pymavlink, and ArduSub. At the moment, I am using SITL for simulation using my laptop with Ubuntu OS.

My goal is to manually set waypoints using QGroundControl on my laptop, upload them to the ROV, and have ROS2 handle the control and execution of flight modes and others.

In SITL, everything works as expected—the ROV follows the waypoints I set. However, I’m unsure how to implement this in a real-world underwater scenario since GPS signals do not work underwater. Without GPS data, how can the ROV accurately navigate to predefined waypoints?

Additionally, I am uncertain about how to integrate this setup with my hardware, which includes a **Pixhawk Holybro CM4** and a **Ublox M8N GPS module with compass**. Since the GPS will be ineffective underwater, what alternative positioning methods can be used?

I would appreciate any guidance or suggestions on how to approach this. Thank you!

 ![482522252_1187430816437118_3277575782999045399_n](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/c/c8b24f7fb4b5c9f0142c4a74e63018961c2dac4a.jpeg)

---

<div class="post-metadata">

**Author:** ![tony-white](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tony-white/32/13297_2.png) [@tony-white](https://discuss.bluerobotics.com/u/tony-white)\
**Post date:** [March 19, 2025, 6:05am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/2 "2025-03-19T06:05:26Z")

</div>

Hi @itsJayMendoza -  
Welcome to the forums!

To operate an ROV in the field, without GPS, you need a position source. This can be a DVL, or another localization system - see the DVL / localization tabs [here](https://docs.google.com/spreadsheets/d/1ajVTSS8elzlrvg-TEKv2Yv8kwd5lNhKTTD6FZZpN4eE/edit?usp=sharing).

Your GPS will work if it is above the water with the vehicle at the surface, but depending on what subsea hardware you’re using for the same purpose, handing off the position may be a bit tricky.

Are you using [BlueOS](https://blueos.cloud/docs/latest/usage/installation/)? It may help significantly with developing things further - typically operating an ROV requires a companion computer for handling video and networking over the tether.

---

<div class="post-metadata">

**Author:** ![itsJayMendoza](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/itsjaymendoza/32/14981_2.png) [@itsJayMendoza](https://discuss.bluerobotics.com/u/itsJayMendoza)\
**Post date:** [March 19, 2025, 7:08am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/3 "2025-03-19T07:08:35Z")

</div>

I’m not currently using BlueOS—can I still connect it with Pymavlink?

My goal is to develop a fully autonomous ROV that follows predefined waypoints. The ROV will navigate on the water’s surface and, upon detecting an obstacle, submerge to avoid it before resurfacing and continuing its path. Additionally, I want the ability to keep it submerged while traveling to a waypoint when necessary.

Can this functionality be implemented using BlueOS? Would it make the process easier? Also, I am using a Raspberry Pi as my main controller.

Thank you!

---

<div class="post-metadata">

**Author:** ![tony-white](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tony-white/32/13297_2.png) [@tony-white](https://discuss.bluerobotics.com/u/tony-white)\
**Post date:** [March 19, 2025, 7:54am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/4 "2025-03-19T07:54:43Z")

</div>

Hi @itsJayMendoza -  
What version Pi are you using? [BlueOS](https://blueos.cloud/docs/latest/integrations/hardware/required/onboard-computer/) supports 3, 4 and 5 but it will take up the lowest percent of resources with a 5 of course.

Using BlueOS would not prevent you from using ROS and Pymavlink - it provides many of the features you would might need to setup anyways. Pymavlink alone should be able to connect and and communicate with your autopilot, but BlueOS and Mavlink2Rest may make aspects of your development easier.

Navigating at the surface with GPS and ArduSub should work without issue. If you’re using a DVL, you can typically set your coordinate system and then maintain approximate positioning when submerged, when in range of the bottom or a surface for the DVL to track. The AUTO mission functionality of ArduSub should “[just work](https://bluerobotics.com/learn/dvl-a50-integration/#auto-mode)”!

Using the LUA script functionality that is a part of ArduSub / Ardupilot since v4.5 may make your entire project radically simpler. By enabling the SCR parameter, and just writing a short script, you can do things like have rangefinder values trigger actions like target depth changes, or jumping to a waypoint. You can see a bit of how that is done with a BlueBoat in this [thread](https://discuss.bluerobotics.com/t/controlling-external-devices-with-lua-scripts-on-ardurover-blueboat-winch/17134), and I’ve been working on this [project](https://github.com/vshie/BlueOS_videorecorder/blob/main/HAUV.lua) (that will become a guide) to further detail just how easy it can be!

 ![|526px;x395px;](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/a/a54b4267fc0feffb2c974ee4c7b833b6c22ab569.png)

---

<div class="post-metadata">

**Author:** ![itsJayMendoza](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/itsjaymendoza/32/14981_2.png) [@itsJayMendoza](https://discuss.bluerobotics.com/u/itsJayMendoza)\
**Post date:** [March 19, 2025, 9:40am UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/5 "2025-03-19T09:40:51Z")

</div>

Do you have any documentation or a step-by-step tutorial on setting up BlueOS with ROS2 and Mavlink2Rest on a Raspberry Pi 4? That would be really helpful.

To be honest, I’m still new to this industry, so I’m not very familiar with these technologies yet. I’ll also need to research DVL and LUA scripting to understand because I’m not familiar with them also. Any guidance or recommended resources would be greatly appreciated.

Thanks again for your insights!

---

<div class="post-metadata">

**Author:** ![tony-white](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tony-white/32/13297_2.png) [@tony-white](https://discuss.bluerobotics.com/u/tony-white)\
**Post date:** [March 19, 2025, 9:11pm UTC](https://discuss.bluerobotics.com/t/navigating-an-autonomous-underwater-rov-with-gps-using-ros2-and-pymavlink/19699/6 "2025-03-19T21:11:37Z")

</div>

Hi @itsJayMendoza -  
We don’t have a tutorial on that, mainly because it is pretty simple and documented adjacently!  
To summarize:

1. [Install](https://blueos.cloud/docs/latest/usage/installation/) BlueOS on your SDcard. This sets up Mavlink2Rest
2. [Connect](https://blueos.cloud/docs/latest/usage/getting-started/) to BlueOS, and setup your vehicle type / connect the Pi to WiFi with internet access. Install the ROS2 extension.

You will need a Pi4, and to use this specific [image](https://github.com/bluerobotics/BlueOS/releases/download/1.4.0-beta.17/BlueOS-raspberry-linux-arm64-v8-bookworm-pi5.zip) that supports 64 bit only extensions like the ROS2 module.

Best of luck!
