Hello,
I cannot control any thruster through the code from the example from the BlueROV webside.
Here is my code, I have stop the heartbeat check from QgroundControl, and marked some of my adjustment. The code is now the same as the example
# Import mavutil
from pymavlink import mavutil
# Create the connection
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
# master = mavutil.mavlink_connection('/dev/ttyS1', baud=115200)
# Wait a heartbeat before sending commands
master.wait_heartbeat()
# Create a function to send RC values
# More information about Joystick channels
# here: https://www.ardusub.com/operators-manual/rc-input-and-output.html#rc-inputs
def set_rc_channel_pwm(channel_id, pwm=1500):
""" Set RC channel pwm value
Args:
channel_id (TYPE): Channel ID
pwm (int, optional): Channel pwm value 1100-1900
"""
if channel_id < 1 or channel_id > 18:
print("Channel does not exist.")
return
# Mavlink 2 supports up to 18 channels:
# https://mavlink.io/en/messages/common.html#RC_CHANNELS_OVERRIDE
rc_channel_values = [65535 for _ in range(18)]
rc_channel_values[channel_id - 1] = pwm
master.mav.rc_channels_override_send(
master.target_system, # target_system
master.target_component, # target_component
*rc_channel_values) # RC channel list, in microseconds.
print("signal sent")
# master.mav.mount_configure_send(
# master.target_system,
# master.target_component,
# mavutil.mavlink.MAV_MOUNT_MODE_RC_TARGETING,
# 0, 0, 0)
# ############################################################# Arm
# master.mav.command_long_send(
# master.target_system,
# master.target_component,
# mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
# 0,
# 1, 0, 0, 0, 0, 0, 0)
# Set some roll
set_rc_channel_pwm(5, 1600)
I can read the message āsignal sentā from the terminal. however, the propeller does not move at all. Since I have removed the heartbeat check, it should keep moving.
I have done some tests by revising the code, just hope they will help you to investigate the problem:
-
If I tried
set_rc_channel_pwm(9, 1600)
, the light shows up, which means the light works properly. -
If I armed the ROV(uncommented the arm code in above code), some propellers (not all of them, I believe they should be 3, 4, 6) will move at a max speed, which caused the ROV drive crazily in the water.
-
I could be able to control the ROV propeller properly before, with the same code above. At that time, my Ardusub was 4.2.0(development version). Now I downgraded it to 4.0.3 (stable version) and had this problem. My Companion is 0.0.26, and I did not change it.
I was wondering if you could deal me with this problem.
I really appreciate your help!