Accessing pitch and roll data

Hi,

Two questions regarding the BlueROV2,

  • How can I access pitch and roll data from the BlueROV2? I want to input this into my own control algorithm.
  • How can I pass a control signal to an external device connected via USB to the onboard Raspberry Pi?

I am completing a research project using the BlueROV2 and haven’t done anything like this before, I would greatly appreciate some guidance on where to begin.

Thanks,
Jack

1 Like

Hi @jack7 -
This thread discusses how you might send the data you’re after.

This guide covers using Node-RED with BlueOS, and while it is focused mostly on inputs, you could focus on the serial output to a USB device - what sort of payload are you planning to control?

Hi @tony-white,
Thanks for the quick reply!

I want to control two stepper motors via an Arduino UNO.

I’ll check out the threads you shared.

Hi @tony-white,

Thanks for your guidance, I have achieved step 1 but am having some trouble with step 2.

To avoid learning Node-RED, I am trying to send a Serial message directly from a Python script to the Arduino plugged into the onboard Pi.

However, I’m having trouble with the port, I have tried both options in the code below and neither work.

arudino_port = '/dev/serial/by-id/usb-Arduino__www.arduino.cc__Arduino_Uno_12150511101151623465-if00'
# arudino_port = '/dev/ttyACM0'
arduino = serial.Serial(port=arudino_port, baudrate=19200, timeout=.1)

Is there a quick fix for the correct port or should I go and get my head around Node-RED?

Cheers,
Jack

Hi @jack7 -
NodeRed is a lot easier than dealing with the code, at least for most people! I’m not sure you can reference the device by the ID in python as you can in Node-RED.

That said, asking chatGPT or google Gemini may help you get python talking to the port at the serial/by-id address - a good sanity check would be using the /dev/ttyACM0 or /dev/ttyUSB#, although this may change when the system is restarted or device plugged into a different port.

Ended up finding a solution using the socket library:

import socket

udp_ip = "0.0.0.0" # Replace with UDP server IP
#udp_ip = "192.168.2.2"
udp_port = 15000    # Replace with UDP server port

# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((udp_ip, udp_port))

udp_ip = "192.168.2.2"
sock.sendto(motor_speed, (udp_ip,udp_port))

Where motor_speed is a byte and also involves forming a serial link in Blue-os using the port noted above.

1 Like

Hi @csargent -
Very interesting - so you are sending the UDP message motor speed to the vehicle, and then using a BlueOS Serial Bridge to route the message to your desired serial port?
Cool!