# MAVROS + ROS 2 in Docker w/ Navigator

**URL:** <https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855>\
**Category:** ArduSub\
**Created:** [August 10, 2023, 11:34pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855 "2023-08-10T23:34:18Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [August 10, 2023, 11:34pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/1 "2023-08-10T23:34:18Z")

</div>

I have created a Docker image with MAVROS installed, and I am currently attempting to run this image on the BlueROV2 Heavy’s Raspberry Pi 4 (8GB RAM). The Raspberry Pi is running Raspberry Pi OS Lite (Bullseye) with BlueOS `1.1.0-beta.26`.

I am having some issues establishing a connection between MAVROS and ArduSub. Specifically, when launching MAVROS within the container, MAVROS indicates successful connections with the specified devices/endpoints; however, I do not receive any information on the MAVROS side. To confirm this, I echo the `/mavros/state` topic, and have received the following result:

```bash
header:
  stamp:
    sec: 1691709106
    nanosec: 196121083
  frame_id: ''
connected: false
armed: false
guided: false
manual_input: false
mode: ''
system_status: 0
---

```

I have tried a number of MAVROS configurations without any success (receiving MAVLink message) including:

- `fcu_url: "udp://@localhost:5760 | gcs_url: "udp://@localhost:14550"`
- `fcu_url: "udp://@localhost:14550 | gcs_url: "udp://@localhost:14550"`
- `fcu_url: "udp://@0.0.0.0:14550 | gcs_url: "udp://@localhost:14550"`
- `fcu_url: "tcp://localhost | gcs_url: "udp://@localhost:14550"`
- `fcu_url: "udp://@localhost:14550"`

The configuration that I have been able to use successfully in the past for simulation purposes is

`fcu_url: "tcp://localhost | gcs_url: "udp://@localhost:14550"`

I am running the container with host networking privileges, but have also tried setting the relevant devices and ports.

I was wondering if there are any folks that have been able to get this working in the past, or if there may be some configurations that I may have set incorrectly? I have also attached some of the relevant configuration files and logs.

EDIT: I forgot to mention, that I also attempted to create a new endpoint within BlueOS to connect MAVROS to; however, that attempt was unsuccessful.

[mavros.log](https://discuss.bluerobotics.com/uploads/short-url/9eeYhMoL7zME2eZvUULNEpvjNOX.log) (11.2 KB)  
[mavros\_config.txt](https://discuss.bluerobotics.com/uploads/short-url/2O7i5M07vdbZiUI8Q6DhgasJzcQ.txt) (455 Bytes)

Cheers,  
Evan

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [August 11, 2023, 1:31pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/2 "2023-08-11T13:31:56Z")

</div>

Hi Evan,

Can you share your docker container for me to test locally ?  
If possible, please share it on github for me to compile and checkout, I may help you to create an example for a BlueOS ROS extension.

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [August 11, 2023, 3:11pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/3 "2023-08-11T15:11:40Z")

</div>

Hi @evan-palmer ,

Have you set up a a new mavlink endpoint for it? I’d create a new one to 127.0.0.1, on a new port, and try to connect to it udp://@localhost:[your new port]

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [August 11, 2023, 3:58pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/4 "2023-08-11T15:58:38Z")

</div>

> Can you share your docker container for me to test locally ?  
> If possible, please share it on github for me to compile and checkout, I may help you to create an example for a BlueOS ROS extension.

Sure thing! [Here](https://github.com/evan-palmer/angler/tree/18-feature-implement-trajectory-planner/.docker) is the link to the Dockerfile that I am currently testing. The stage that I am building up to is the `robot` stage, the build context is the root project directory (`angler`), which you can see in the [devcontainer configuration](https://github.com/evan-palmer/angler/tree/18-feature-implement-trajectory-planner/.devcontainer). Though if you would prefer to just pull the image, I have made the `arm64` builds available on the GitHub registry [here](https://github.com/evan-palmer/angler/pkgs/container/angler). The version to pull if you choose that route is the `rolling` image. I can follow up with the `docker-compose` script that I am using to start everything once I get to my lab and have access to the BlueROV. With regards to the BlueOS extension, that sounds great! Ironically, I have an issue open [here](https://github.com/evan-palmer/blue/issues/30) for it’s sibling project, though it would be nice to decouple the MAVROS dependency into it’s own extension.

EDIT: Here is the compose script that I am currently testing with [docker-compose.txt](https://discuss.bluerobotics.com/uploads/short-url/tOF5sMAB26DBNtX0WPzg5I3IStz.txt) (373 Bytes)

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [August 11, 2023, 4:09pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/5 "2023-08-11T16:09:55Z")

</div>

> Have you set up a a new mavlink endpoint for it? I’d create a new one to 127.0.0.1, on a new port, and try to connect to it udp://@localhost:[your new port]

Thank you for the response! I did try that, yes. I initially configured it according to the provided `pymavlink` example, but changed the configuration to use localhost as I am not using the topside computer to run my interfaces. I tested out a TCP client and UDP clients at the following addresses, respectively:

- `udp://@localhost:14770`
- `tcp://localhost:14770`

For the sake of exhaustion, I made sure to test out server endpoints as well. Something that I would like to note, however, is that in the case of the UDP endpoints, MAVROS is able to establish a connection, but in the case of the TCP endpoints, MAVROS fails to establish a connection at all with a connection refused error. I am fairly convinced that there is a networking configuration error that I have made on my end that is preventing MAVROS from connecting to the mavlink router, though I am not sure what that could be at this point 🙂

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [August 11, 2023, 6:30pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/6 "2023-08-11T18:30:06Z")

</div>

I have done some additional testing with pymavlink, and was able to establish a connection to ArduSub from both a topside computer using the ArduSub [example script](https://www.ardusub.com/developers/pymavlink.html#run-pymavlink-on-the-surface-computer) and in the container using my custom endpoint `udp://@0.0.0.0:14755` which indicates that there is likely an issue with my MAVROS configuration.

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [August 11, 2023, 8:17pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/7 "2023-08-11T20:17:01Z")

</div>

After some more debugging, I was able to get a solution together. As expected per my last post, the issue was the MAVROS configuration. I am not fully convinced that the GCS connection string is correct, though I will find out as soon as I try to override the RC inputs 😃 I have included the relevant MAVROS configurations below for any folks that stumble across this post in the future. @patrickelectric I would be happy to collaborate on a MAVROS extension in the future as well if you think that would be a useful contribution.

Relevant, working MAVROS configurations

```plaintext
mavros_node:
  ros__parameters:
    fcu_url: "udp://:14755@0.0.0.0:14755"
    gcs_url: "udp://@192.168.2.1:14550"

```

---

<div class="post-metadata">

**Author:** ![legohead259](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@legohead259](https://discuss.bluerobotics.com/u/legohead259)\
**Post date:** [August 31, 2023, 9:09pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/8 "2023-08-31T21:09:54Z")

</div>

Have you noticed any significant lag between BlueOS and MAVROS? When we were experimenting with it a couple of months ago, there was almost a one second delay between when MAVROS issued a command and BlueOS receiving it and acting on it.

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [September 1, 2023, 6:57am UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/9 "2023-09-01T06:57:25Z")

</div>

The response times that I have observed have varied according to the command that I am sending. For example, if I send a service request, the response time is a bit longer, though nothing extraordinary (one second would be a reasonable estimate, but I haven’t measured). This is consistent with what I see in simulation as well, albeit the responses are a little faster due to the increased compute power. However, if I send PWM commands to a thruster (or thrusters) using the RC override interface, the response is quite fast. I have been able to do control using MPC and ISMC with the setup used.

EDIT: Something else that I forgot to mention is that how the messages are sent plays a role. When issuing commands via a node, the response times, even for services, are typically pretty quick. If the CPU usage starts to get too high (85%+), I’ve seen the response times increase a bit though. When issuing commands via the ros2cli, commands take a bit longer to be constructed and delivered (which is expected).

---

<div class="post-metadata">

**Author:** ![legohead259](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@legohead259](https://discuss.bluerobotics.com/u/legohead259)\
**Post date:** [September 1, 2023, 2:56pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/10 "2023-09-01T14:56:05Z")

</div>

Very interesting. We may have to rerun our experiment then.

Just FYI, the link you posted earlier to your GitHub and Docker container no longer seems to work. Would you happen to have another link that’s available?

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [September 2, 2023, 4:16pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/11 "2023-09-02T16:16:50Z")

</div>

Ah, yes. I made that project private again while I get things into an MVP state. I will edit this post to include the project when I make it public. Though most of the BlueROV-specific work that I have been discussing can be seen [here](https://github.com/evan-palmer/blue) (still in a pre-released state). The thing missing from the linked repo at the moment is the Docker image built for arm64, but the Dockerfiles are _mostly_ the same

---

<div class="post-metadata">

**Author:** ![legohead259](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@legohead259](https://discuss.bluerobotics.com/u/legohead259)\
**Post date:** [September 2, 2023, 5:04pm UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/12 "2023-09-02T17:04:56Z")

</div>

Ah gotcha. I’ve pointed one of my undergraduate senior design groups at your project to see if we can deploy it on one of our vehicles. They want to implement basic waypoint and velocity control and eventually a path planner for navigation and obstacle avoidance. Your work so far seems to be an excellent starting point for them - we are really excited to dig into it and appreciate everything we’ve seen so far!

Would you be willing to collaborate on this effort? I seems like you have invaluable experience with ROS and getting it work on the BlueROV. Together, I think some major features could be implemented!

---

<div class="post-metadata">

**Author:** ![evan-palmer](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@evan-palmer](https://discuss.bluerobotics.com/u/evan-palmer)\
**Post date:** [September 3, 2023, 8:20am UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/13 "2023-09-03T08:20:21Z")

</div>

I’d be happy to collaborate! Please feel free to send me a message, and we can continue the conversation offline.

---

<div class="post-metadata">

**Author:** ![gaurangtari](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/gaurangtari/32/16101_2.png) [@gaurangtari](https://discuss.bluerobotics.com/u/gaurangtari)\
**Post date:** [September 16, 2025, 7:00am UTC](https://discuss.bluerobotics.com/t/mavros-ros-2-in-docker-w-navigator/14855/15 "2025-09-16T07:00:22Z")

</div>

Experiencing something similar. There is almost a 2 second delay between ROS command and ROV acting on it. This issue is only there with navigator. works pretty fine with pixhawk
