Control BlueROV2 by PyMavlink

Hello,

I am trying to control BlueROV through Pymavlink in Cygwin windows 10.

I followed the manual https://www.ardusub.com/developers/pymavlink.html .

I typed python code of ‘Send RC (Joystick)’ and found that ‘master.wait_heartbeat()’ will not return anything and keep waiting until I terminate it.

I tried to jump this wait_heartbeat() and directly test ‘def set_rc_channel_pwm’ function.

I tested it with ‘set_rc_channel_pwm(2, 1600)’ but did not see any rotation on the BlueROV.

The connection between BlueROV and the computer is good, I have all functions in QGroundControl and can test each propeller. My goal is the control the BlueROV by program so that the ROV can move with given command.

I am not sure if it is correct to use pymavlink, if it is, could you please help with this issue, is there any step that I missed; if not, please let me know the correct program to control BlueROV through command or script.

Really appreciate your help!

1 Like

Hi @Brandonyxf,

A quick question, why are you using Cygwin ?
I would recommend to use Windows WSL or running python under windows without WSL or Cygwin.

Hello @patrickelectric,

Thanks for your reply. The manual of Pymavlink was under the Linux environment, so I tried Cygwin.

Now I am trying to follow your suggestion by using WSL Ubuntu 18.04 LTS. I also checked other topic to find similar questions.

I found that I need to connect the ROV(pixhawk) to the computer first.

I tried the code from manual ‘Pymavlink · GitBook

# Import mavutil
from pymavlink import mavutil

# Create the connection
# Need to provide the serial port and baudrate
master = mavutil.mavlink_connection(
            '/dev/ttyACM0',
            baud=115200)

and I have
Traceback (most recent call last):
File “”, line 3, in
File “/home/xyi7/.local/lib/python2.7/site-packages/pymavlink/mavutil.py”, line 1689, in mavlink_connection
force_connected=force_connected)
File “/home/xyi7/.local/lib/python2.7/site-packages/pymavlink/mavutil.py”, line 924, in init
raise e
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: ‘/dev/ttyACM0’

Hi,

You’ll need to check how to access hardware peripherals, like the serial-usb adapter, under WSL. The path /dev/ttyACM0 is the pixhawk under Linux operating system.
Have you tested the others examples that use UDP communication ?

Under WSL you can access the serial ports using the COM port numbers assigned by Windows. For example if you want to talk to the accessory on Windows serial port COM4 then in WSL you would use /dev/ttyS4. COM3 would be /dev/ttyS3 and so on.

A word of caution - Microsoft are releasing WSL version 2 soon and it takes away the ability to access USB and serial devices without a custom kernel.

1 Like