Hello,

I am trying to create a custom ground station that could take off the Quadcopter when a camera detects a predefined target. Basically, there are a camera, a computer and a Quadcopter. The computer sends MAVLink commands to the APM3.1 and no remote control shall be used.

I am running a C++ program that arms the Quadcopter with MAVLink but I can't manage to make it fly.

I first tried to override remote control with RC_CHANNELS_OVERRIDE MAVLink command but the Quadcopter does not answered to my request. I then tried with MAVLink missions. I succeed in sending mission to the Quadcopter (I can see them with Mission Planner) but when I switch to AUTO mode, nothing happened.

I'm probably missing something but I've been looking around for a while and I didn't manage to find anything. If you've done that kind of things and if you've got some time to spend for a newbie, any help would be warmly welcomed.

Thanks.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

                  • Thank you Suresh. I have additional 2 questions... 

                    So the target_component ID for me is also 250, right?

                    Do I need to keep my RC on and switch to AUTO mode when sending commands? Or I can turn off the Radio Controller?
                    I really appreciate your help.
                • The code does technically work. But i had issues with it moving too fast before the APM could register it. After putting sleep() commands in between to give it time to think, it armed. Look at the list of mavlink command structures from pixhawk website to understand how the commands are given. Goodluck. (PS: its horrible trying to control it via code)

                  • Hi Suresh,

                    I have tried your codes but the quad still can not be armed. Does the value in above codes are all correct? Is the value of arm_command_msg.command should be 400? Does different APM have different target_system ID and target_component ID?

                    I really appreciate if you can give me further help. 

                  • Hi Suresh,

                    Thanks for your reply.I did go through the mavlink command structures. But I still have some questions, would you help me?

                    1. Which head files I need to include to compile above codes? Will any sign be given to show that the quad has successfully been armed?

                    2. Have you tried some control algorithm such as PID controller to control the quad? If no, I have some experience to control other companies quad. I would like to help you on this.

          • That is great!

            Can I get bit more help on this? What is the line to send the message? Should i just have write() or some other mavlink command send function? Your help is highly appreciated!

            • I am using APM, and I connected it through serial to my lap and opened the port using open_uart() and then just write the message to that port.

              you might wanna take a loot at uart_example on mavlink's git repository. it clearly shows how to send commands.

              -

              Pushyami

              • Hi, I am working off of that send_quad_commands.cpp. However I am still bit lost as i just started coding with mavlink. This is what i have. I believe, i need to encode the message/command. Then write it to the port.but apparently the inputs to the mavlink_msg_command_long_encode is not right.

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

                • yes,

                        The right most argument in this function mavlink_msg_command_long_encode(1, 1, &message, 1);  is not correct, it is not "1". It has to be the structure representing the command long of type "mavlink_command_long_t".

                  first you have to declare a variable of type "mavlink_command_long_t" and then give values to contents in that structure viz., command, param, target_system, targte_component etc. Then encode it with the encode function and then write it to buf and then write to the port.

                  You can check out the different functions of different messages in the respective header files in "common" folder in mavlink

                  I hope this solves ur problem

                  -Pushyami

                  • Hello Pushyami and Suresh,

                    I am new to coding quadcopters and I need some help starting out.  I just want to know what editor you're using to write the C++ codes, what compiler to compile them and how you send them to the apm.  If you have a link that help you get started that would be great.  I have looked all over and can't find much; all I find are people talking about coding and not how they were able to compile the codes and download them to the copter.

                    Thanks,

                    David

    • Hello Valentin,

      I am very interested in how you finally achieve to override the RC channels with your own custom GCS. I am working in a project to remotely control APM using Mavlink commands. It would be great if you could explain me how you program it in C++.

      P.S.: When you enter in AUTO mode, there is a security function that force you to send a throttle signal to APM to indicate that you are in the right mode. So, if you enter in AUTO mode and send a throttle signal you should be able to make it works.

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…