Hi there,
I’m trying to move my camera servo via pymavlink. I tried two methods:
- one is to control by virtually pushing button. Here is my button configuration:
Here is my code snippet:
def mount_down():
send_button_control(MOUNT_DOWN_BUTTON) #11 12 or whatever
def send_button_control(btn):
buttons=1<<btn
print(buttons)
master.mav.manual_control_send(
master.target_system,
0,
0,
500,
0,
buttons)
master.mav.manual_control_send(
master.target_system,
0,
0,
500,
0,
0)
- The other method that I`m using is to control camera servo channel:
Here is my camera channel config:
if(event.axis==7): #light2 #camera control #this part is to handle joystick
if(abs(abs(event.value)-0.06)<0.06): #this part is to handle joystick
event.value=0 #this part is to handle joystick
throttlein=1500+event.value*600 #this part is to handle joystick
tested_functions.set_rc_channel_pwm(10,int(throttlein)) #sending channel input by mavlink
def set_rc_channel_pwm(channel_id, pwm=1500): #in library
""" 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.
Is there anything that I am doing wrong?
Thanks for the answers in advance.