I’m a Rookie in coding,and i have project which using QT create a UI to control my rov2.below is my code in qt creator.
mavlink_msg_command_long_pack(255, // System ID
1, // Component ID
&msg, // MAVLink message
0, // Target system ID
0, // Target component ID
MAV_CMD_DO_SET_SERVO, // Command ID
0, // Confirmation
1700, 0, 0, 0, 0,0); // Parameters
qint64 len2 =mavlink_msg_to_send_buffer((uint8_t*)buf,&msg);
I can recieve rov message(like heartbeat) from udp connection,but when sending these codes,rov have no reflect.
by the way I qdebug “(const char*)buf” in outpout,it is “0x74ca19”,is normal and corret?
@EliotBR Thanks for the prompt response！I have tried your advice，the vehicle system ID and target
ID are both 1,and I changed the IP adress to 192.168.2.2,but it doesn’t seem to work .I read a pymavlink code,before I control the servo maybe I should change the MAV_MODE?Another question is should I send heartbeat message to the rov2 Regularly,is necessary for just test a servo?I feel a little confuse about the progress.Looking forward to your response.
I’ve just taken another look at this and it seems like you’re trying to set the PWM of servo 2, which is pretty much always assigned as a motor for use in controlling the vehicle (which generally need to be controlled with MANUAL_CONTROL or RC_CHANNELS_OVERRIDE messages, while the vehicle is armed).
If you want to use the DO_SET_SERVO command you’ll need to ensure the SERVOn_FUNCTION parameter (where n is the servo you’re trying to control) is set to Disabled (-1). This is not recommended for motion control outputs, so normally you would only do this for outputs 7+ in a standard BlueROV2, or 9+ if you’re using the heavy configuration.
If you’re using a Pixhawk note that servos 1-8 are MAIN 1-8, and servos 9-14 are AUX 1-6.