# Start coding bluerov

**URL:** <https://discuss.bluerobotics.com/t/start-coding-bluerov/18415>\
**Category:** General Discussion\
**Created:** [October 30, 2024, 1:08pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415 "2024-10-30T13:08:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fusari](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fusari](https://discuss.bluerobotics.com/u/fusari)\
**Post date:** [October 30, 2024, 1:08pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415/1 "2024-10-30T13:08:47Z")

</div>

Hi i write this message to ask some advice;  
I have a bluerov drone and i would under stand how to program (with c or python) in such way i can test some Path planning, computer vision, etc… programs, but i don’t under stand where i have to go to write the script and how to access to the data;  
The Ideal thing would be that the Rov Is autonomus so It don’t Need the PC attached to work  
Some One can give me some suggestion or, if the argument was already discuss, link me to the documentation/exaples?

Thx in advance

P.s. there Is some virtual simulator to test the program and how the Rov Will respond without directly test It on the real world?

---

<div class="post-metadata">

**Author:** ![alyssonoliveira](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@alyssonoliveira](https://discuss.bluerobotics.com/u/alyssonoliveira)\
**Post date:** [October 30, 2024, 7:24pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415/2 "2024-10-30T19:24:20Z")

</div>

Hi @fusari !

I’m currently in the process of learning coding for ROV’s and AUV’s and can share with you what I have learned so far!

**MAVLink** is a protocol that you can use to send commands to the drone and collect some temeletry data from it. Check the [documentation](https://mavlink.io/en/) to learn more!

There’s a python library called **pymavlink** that is used to send these MAVLink commands to a GCS (ground control station) and then to the ROV. Learn more about it [here](https://mavlink.io/en/mavgen_python/).

> [@fusari](#):
>
> P.s. there Is some virtual simulator to test the program and how the Rov Will respond without directly test It on the real world?

There’s a simulation from BlueRobotics that you can download and connect it to a GCS like QGroundControl and run python codes to test the MAVLink commands. It’s called [BlueSim, download it here](https://github.com/bluerobotics/bluesim).

I reccomend you to download QGroundControl and the simulator above, and watch these series of youtube videos to take your first steps: [click here](https://www.youtube.com/watch?v=kecnaxlUiTY&list=PLy9nLDKxDN68cwdt5EznyAul6R8mUSNou)!

I’m a begginer but if you have any questions I’ll be glad to help with what I know.

Good luck to us both and have fun!

---

<div class="post-metadata">

**Author:** ![fusari](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fusari](https://discuss.bluerobotics.com/u/fusari)\
**Post date:** [November 5, 2024, 3:22pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415/3 "2024-11-05T15:22:26Z")

</div>

Ok thx for the advice and Sorry of i respond only now;  
So to program using pyMavlink i have to go on the promp on the blueOS web appication right? And in that case the code Will not run on the rasbarry on the drone but in the PC where you are coding right?

And for the simulator you Say that It simulate the behaviour of the drone right? But i don’t under stand if i can simulate the enviroments (like currents and fisical obstacle or target) and of It Will ricreate the behaviour in a 3d mapp

---

<div class="post-metadata">

**Author:** ![alyssonoliveira](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@alyssonoliveira](https://discuss.bluerobotics.com/u/alyssonoliveira)\
**Post date:** [November 7, 2024, 6:29pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415/4 "2024-11-07T18:29:35Z")

</div>

Hi @fusari ! My time to appologize for the delay haha

> [@fusari](#):
>
> So to program using pyMavlink i have to go on the promp on the blueOS web appication right? And in that case the code Will not run on the rasbarry on the drone but in the PC where you are coding right?

With the example that I gave you, you will run the code using your PC. The python code will set a TPC or UDP connection with the vehicle and command it. Check the step by step [tutorial](https://www.youtube.com/watch?v=kecnaxlUiTY&list=PLy9nLDKxDN68cwdt5EznyAul6R8mUSNou) that I recommended.

The only thing different is that you will set a TPC connection instead of UDP **if you use the simmulation.**

Here’s my code that I created following the tutorial and testing it on the simulation. I used BlueSim, QGroundControl and VS Code to run the python code.

```auto
from pymavlink import mavutil

# Start a connection listening on a TCP port
the_connection = mavutil.mavlink_connection('tcp:127.0.0.1:5763')

# Wait for the first heartbeat
# This sets the system and component ID of remote system for the link
the_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component))
while 1:
    msg = the_connection.recv_match(blocking=True)

```

> [@fusari](#):
>
> And for the simulator you Say that It simulate the behaviour of the drone right? But i don’t under stand if i can simulate the enviroments (like currents and fisical obstacle or target) and of It Will ricreate the behaviour in a 3d mapp

To be honest, I don’t know that either. I know that they have two available environments on the link that put up there for you, but I only tested the first one, a simple pool.

Concerning currents, I’m not sure how you could do that, but I’m pretty sure it’s possible to add obstacles using some programs. Try searching for **ROS, Gazebo, Movelt** , but I’m afraid I can’t help you with them.

Good luck!

---

<div class="post-metadata">

**Author:** ![fusari](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fusari](https://discuss.bluerobotics.com/u/fusari)\
**Post date:** [November 12, 2024, 2:42pm UTC](https://discuss.bluerobotics.com/t/start-coding-bluerov/18415/5 "2024-11-12T14:42:39Z")

</div>

Ok thx in case if i find something i Will write It here
