Pymavlink Examples

Hi,
I have tried some examples from the guide. But it doesn’t work.
-top side computer connected to raspberry pi via ethernet
-pixhawk connected to raspberry pi via usb
-I changed ip address of top side as “192.168.2.1”
-I’ve tried first example. (rebooting pixhawk)

import time
# Import mavutil
from pymavlink import mavutil
master = mavutil.mavlink_connection('udp:192.168.2.1:14550')
def set_rc_channel_pwm(id, pwm=1500):

    if id < 1:
        print("Channel does not exist.")
        return

    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, 1600)
set_rc_channel_pwm(4, 1600)
set_rc_channel_pwm(8, 1900)

What could be the problem?

Hi,

Mavproxy in the raspberry is using udpbcast as an endpoint, try using udpin:192.168.2.1:14550 instead.

Have you tried the RC Joystick as we wrote it?

1 Like

Hi,
Yes I’ve tried RC Joystick example. But it didn’t work. I also tried Arm/Disarm example and motor turned at maximum value. I guess there is no problem about communication. But I don’t understand why motor don’t run according to given pwm values as in the RC Joystick example.

This topic was automatically closed after 5 days. New replies are no longer allowed.