Hello, I have been trying to control the BlueROV2 through Pymavlinks, but I found something not right when I tried to control ‘raw’.
At the end of my program, I tried to put raw signal continuously, but the thrusters will gradually stopped even there are still raw input signal.
Another case is that if I put signals to channel 1(pitch), the motion that the BlueROV2 does not have, the raw signal after that will stop even faster.
However, this kind of ‘gradually stop’ problem will not happen when I tried to control ‘throttle’ or ‘forward’.
I guess it might be because of some safety issue, but I am not sure.
Could you please help with that?
I really appreciate that!
The following is my code:
from pymavlink import mavutil
import time
# Create the connection
master = mavutil.mavlink_connection('udpin:192.168.2.1:14550')
# Wait a heartbeat before sending commands
master.wait_heartbeat()
######################################################## function to send RC values
def set_rc_channel_pwm(id, pwm=1500):
if id < 1:
print("Channel does not exist.")
return
if id < 9:
print("Signal Sent.")
rc_channel_values = [65535 for _ in range(8)]
rc_channel_values[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.
############################################################## 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 mode :
# Choose a mode
mode = 'ACRO'
# Check if mode is available
if mode not in master.mode_mapping():
print('Unknown mode : {}'.format(mode))
print('Try:', list(master.mode_mapping().keys()))
exit(1)
# Get mode ID: return value should be 1 for acro mode
mode_id = master.mode_mapping()[mode]
master.mav.set_mode_send(
master.target_system,
mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
mode_id)
set_rc_channel_pwm(1, 1600)
time.sleep(0.8)
set_rc_channel_pwm(1, 1500)
time.sleep(0.8)
timeout = time.time() + 5
while True:
if time.time() > timeout:
break
set_rc_channel_pwm(4, 1600)
time.sleep(0.2)
# set_rc_channel_pwm(4, 1600)
# time.sleep(3.8)
quit()