Arming the APM using MAVLink

368 views
Skip to first unread message

suna...@colorado.edu

unread,
Mar 25, 2014, 2:25:20 PM3/25/14
to mav...@googlegroups.com
Greetings,

I am trying to arm the APM using mavlink via a c++ code. It is a modified version of the send_quad_commands written by Lorenz.

    int fd = serial_fd;
    char buf[300];

    mavlink_command_long_t arm_command_msg;
    mavlink_message_t arm_msg;

    arm_command_msg.command = 40;
    arm_command_msg.target_system = 1;
    arm_command_msg.target_component = 250;
    arm_command_msg.confirmation = 0;
    arm_command_msg.param1 = 1;
    arm_command_msg.param2 = 0;
    arm_command_msg.param3 = 0;
    arm_command_msg.param4 = 0;
    arm_command_msg.param5 = 0;
    arm_command_msg.param6 = 0;
    arm_command_msg.param7 = 0;

    mavlink_msg_command_long_encode(1, 250, &arm_msg, &arm_command_msg);
    unsigned len = mavlink_msg_to_send_buffer((uint8_t*)buf, &arm_msg);
    write(fd, buf, len);

That is the code that i have now. It sends some sort of command to the apm (It beeps everytime i call the code). However it doesnt seem to arm the apm. I am not sure what is going wrong. Any help is highly appreciated

John Mayer

unread,
Apr 13, 2014, 5:52:08 PM4/13/14
to mav...@googlegroups.com
Check the following code:

void ArduPilotMegaMAV::armSystem()
{
    mavlink_message_t msg;
    mavlink_msg_command_long_pack(mavlink->getSystemId(),
                                  mavlink->getComponentId(),
                                  &msg,
                                  getUASID(),                    // uint8_t target_system,
                                  MAV_COMP_ID_SYSTEM_CONTROL,    // uint8_t target_component
                                  MAV_CMD_COMPONENT_ARM_DISARM,    // uint16_t command,
                                  1,                // uint8_t confirmation,
                                  1.0,             // float param1,
                                  0,                // float param2,
                                  0,                // float param3,
                                  0,                // float param4,
                                  0,                // float param5,
                                  0,                // float param6,
                                  0                 // float param7)
                                  );
    sendMessage(msg);
}



void UAS::sendMessage(mavlink_message_t message)
{
    if (!LinkManager::instance()) return;
    // Emit message on all links that are currently connected
    foreach (LinkInterface* link, *links)
    {
        if (LinkManager::instance()->getLinks().contains(link))
        {
            sendMessage(link, message);
        }
        else
        {
            // Remove from list
            links->removeAt(links->indexOf(link));
        }
    }
}

If you are not sure of the type for mavlink_message_t, it should be in mavlink_types.h header file.

Please share your findings.

John

________________________________________________________________________________________________________

mohsein

unread,
Sep 29, 2014, 4:15:33 PM9/29/14
to mav...@googlegroups.com
hello dears

I also want to arm my APM through coding with c in visual basic

I want to ask you for the easiest and performable way you know

it would be of your kindness to help me overcoming this issue

thank you@

Yassine Jmili

unread,
Oct 6, 2014, 4:12:46 PM10/6/14
to mav...@googlegroups.com
hello;


i followed the step in the video of the website   http://pixhawk.org/dev/toolchain_installation_win ; i don't know how i can execute some program using the eclipse in windows , i see that you are did some modification in the program  send_quad_commands  ,   how can you run this program, , you are create  your main program ?

how i can do this using eclipse?

can help me please ;

thnx
Reply all
Reply to author
Forward
0 new messages