Hello dear forumers,
We are working on an AUV system and currently we are facing with a problem. I’ll get into the point quickly.
I have two videos that showing what is the problem and i’ll leave the running codes in the shown videos below the links.
The problem in summary is: Whether we drive the vehicle on STABILIZE
or DEPTH_HOLD
modes, when we send PWM to the channel 5 [FORWARD] the vehicle randomly rotating left and right.
Video1:
The Code Running on Video1:
import mylib
master = mylib.essentials.connect()
boot_time = mylib.tools.set_boot_time()
mylib.essentials.arm_vehicle(master)
mylib.drive.set_vehicle_mode(master, 2) #Depth hold mode.
mylib.drive.set_target_depth(master, -0.5, boot_time) #Supposed to go 0.5 meters depth.
current_time = mylib.tools.set_timer()
while True:
timer = mylib.tools.set_timer() - current_time
if timer < 5:
mylib.drive.override_motor_channels(master) #Sends 1500pwm to all channels to keep motors alive while setting the depth.
if timer >= 5 and timer < 10:
mylib.drive.override_motor_channels(master, ch5= 1600) #For the next 5 secs, sends 1600pwm to channel 5, which is forward.
if timer >= 10:
break
mylib.essentials.disarm_vehicle(master)
Video2:
The Code Running on Video2:
import mylib
master = mylib.essentials.connect()
mylib.essentials.arm_vehicle(master)
mylib.drive.set_vehicle_mode(master, 1) #Stabilize mode.
current_time = mylib.tools.set_timer()
while True:
timer = mylib.tools.set_timer() - current_time
if timer < 5:
mylib.drive.override_motor_channels(master, ch3= 1625) #Sends 1625pwm to Channel3 (THROTTLE).
if timer >= 5 and timer < 10:
mylib.drive.override_motor_channels(master, ch3= 1625, ch5= 1575) #For the next 5 secs, sends 1625pmw to channel 3 and 1575pwm to channel 5.
if timer >= 10:
break
mylib.essentials.disarm_vehicle(master)
The function used for overriding channels:
def override_motor_channels(master, ch1= 1500, ch2= 1500, ch3= 1500, ch4= 1500, ch5= 1500, ch6= 1500, ch7= 1500, ch8= 1500):
master.mav.rc_channels_override_send(
master.target_system,
master.target_component,
ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8)
Thanks for your time reading this, any help will appreciated. Have a nice day