Manually controlling ROV from pymavlink

Hi all,
I am currently trying to control my ROV with pymavlink. I can pull any value i want, but i can’t control it. First of all i didn’t understand how should i send “manual_control_send” and “rc_channels_overwrite_send”. Should i send them once or should i send them continously, if continously what should be my interval. In the examples here: Pymavlink · GitBook. We don’t arm the vehicle but shouldn’t we arm it first ? Both of the codes below doesn’t work. Do you have anny suggestions or could you suggest me any source to learn from it.

from pymavlink import mavutil
import time

master = mavutil.mavlink_connection('udp:192.168.2.1:14550')

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)

time.sleep(2)

while True:
    try:
        msg = master.recv_match()
        if msg.to_dict()["mavpackettype"] == "SCALED_PRESSURE":
            print(msg.to_dict())

        master.mav.manual_control_send(master.target_system, 100, 0, 0, 0, 1)
        time.sleep(0.1)
    except:
        continue

||| I am pulling the pressure value for another reason. Don’t mind that.

    from pymavlink import mavutil

    master = mavutil.mavlink_connection('udp:192.168.2.1:14550')

    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)

    time.sleep(2)

    def set_rc_channel_pwm(id, pwm=1500):
        """ Set RC channel pwm value
        Args:
            id (TYPE): Channel ID
            pwm (int, optional): Channel pwm value 1100-1900
        """
        if id < 1:
            print("Channel does not exist.")
            return

        # We only have 8 channels
        #http://mavlink.org/messages/common#RC_CHANNELS_OVERRIDE
        if id < 9:
            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.

    set_rc_channel_pwm(2, 1900)

Also shouldn’t i see any message after i arm the vehicle. Should i use “master.recv_match()” for that too.

Please try a forum search. These questions have been answered here many times over.

https://discuss.bluerobotics.com/search?q=rc_override

https://discuss.bluerobotics.com/search?q=manual_control

1 Like

Your scripts are missing heartbeats: Pymavlink · GitBook

1 Like