Send commands from raspberry pi to Apm2.6

Hello people!My project is path following quadcopter with voice recognition, using raspberry pi. The voice recognition process is done in the raspberry pi. I want to send that recognized voice to my apm 2.6 which will make quadcopter move accordingly. What will be the best thing to make communication link between them?Moreover i want to track my quadcopter in a room, where gps don't work accurately. What thing can i use to send the qaudcopter to my desired place?Please answer as I am a starter.Thankyou.

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

Join diydrones

Email me when people reply –

Replies

  • Hi Huda

    To communicate with your quad you have to use what is called the Mavlink protocol.

    You will have to research that, and I recommend you also look for existing software implementations of that to use on your raspberry pi to minimise how much work you have to do instead of starting form scratch. If it has not already been done, you may have to tear that part out of some project that has it. For example there will be some open source mobile phone app that sends direction commands using the Mavlink protocol. you would want to hack something like that and replaces the buttons with your voice recognition. You'd have just take out the Mavlink part though as all the app code frame work would match the raspberry pi. I'm sure there is other simple programs in various languages that implement the Mavlink, research a few different implementations and find the one the has the protocol isolated well for easy removal. If you are lucky you may find a full piece of software that takes very little hacking for you to integrate your voice recognition.

    Your project sounds very interesting. It also sound like a few projects in one, all of which are challenging. I hope this is not a small school project?

    Without the use of GPS, you will have to rely on other sensors for position. Such as an inertial measurement unit IMU (exists on the APM2.6 board i think), and other sensors for height and lateral motion detection. On the APM2.6 I believe you can connect an ADNS3080 optical flow sensor for horizontal motion and HC-SR04 sonar module for height measurement.

    The flight controller will have an algorithm that will use these sensors to hold a position (it will take some parameter tuning work).

    If you can hold the quad on a single point, then it can follow a line. But where is the line? The line (path) has to be measured from some other known point, a reference point in the room (coordinate reference frame). So this means the quad must be aware of it's environment and be able to map it. This is typically done with computer vision and other sensors, it is a large area of work unto itself.

    With predefined map, and a know lift-off location, in theory the robot should be able to just measure it's own motion and know where it is in the map. Navigation like this is called dead reckoning. The problem with this method is that there are small errors in all of the sensor that add up very very quickly, and the measurement drifts off. This method does not work at all practically without any measurement of the room to correct the error. This problem of measuring your environment, and your place in it, is called 'localisation'. Lasers, and sonar (if near enough) can help to measure distances to walls, most of the time cameras will be used.

    If you do not have an existing map to start with, then the quad has to build one at the same time as find it's place in the map and measure it's movements within the map. This is call Simultaneous Localisation and Mapping (SLAM).

    The vision, mapping, localisation, and flight stabilisation (pose estimation and control) are all separate large projects people often work on in postgraduate degrees.

    Voice recognition using raspberry pi, and converting the commands into the Mavlink protocol commands/packets, sounds like enough of a project to me! You can get read-to-fly quads made by small companies that are popping up all over the place that can supply you with a quad that is configured and tuned to fly properly. I haven't looked into it as I am building my own from the frame up, but I wouldn't be surprised if there is someone also selling quads that can also map their environment (indoors). If not, I will when I am finished mine (a long time!). Doubt it would be cheap though for the whole package ;(

    In summary, the point I am trying to make to you is, don't bite off more than you can chew right from the start. Keep your goals realistic and manageable. I think you have a cool project idea, I think you should focus on just that part of it. Think like an engineer and keep all the parts of the project in separate boxes. For example, commands driving a robot car may be a better place to start time-wise. Your APM2.6 can drive wheels as well as propellers.

    I just had a look and found quite a few mobile phone apps (thanks for the motivation i totally needed one!).

    Must you use the raspberry? I'm sure you could find an open source app and hack it. Though the pi is a lot cheaper than a smart phone and the pi may be faster for you to prototype on?

    Anyway, with that done, and a cheap ready to fly quad, you are on your way then to mapping/localisation!

    • I just re-arranged , that now i am going connect my pi with mic and the recognition is done and then transmitted then the signal is received at the apm. your links helped me alot, but still there is a hell of work in it, i will update my progress soon. Thanks for your kind words :)
      • Yes there is a lot of work! :D

        But hopefully you enjoy much of it.

        It can be frustrating when you need to build a lot of parts in a system just so that you can do the part that is your idea. I am nowhere near there with my own project, I need a 100% complete autonomous robotic system implemented before I can start to focus on behavior.

        When you are starting out in engineering, you must learn that it is not just about the science. There is project management/organisation considerations along with working with other people (clients/colleges).

        A very important thing to learn is 'scope of work'. You need to be clear on the definition of where your work begins and ends, how your work integrates with other work, and all parties involved must know this. This must always be clear to a client.

        In your case, your client is your instructor. Your instructor and you must agree on what you are responsible for and agree on how much work that will be. Dependencies are very significant. You can't just snap your fingers and have a robot built because you want to work on some computer vision project, that is unless you have the money to throw at the problem.

        I am still a little concerned for you as this is an undergraduate project, you probably have courses to focus on as well. I would recommend you find out how the project will be assessed and scored. You may be surprised to find out how little percentage goes towards the system building. Good documentation, presentation, and time management should together count for more.

        Please make sure you are biting off only as much as you have time for, do not let your grades suffer for it. I have seen plenty of people put little effort into building something impressive, but wrote about the science and came up with a solid project document, proving they understand the subject, and proceeded through the project documenting it in an organised way, and obtained good grades.

        Good grades can get you into grad school, there you can focus on a bigger project everyday all day.

        On the other hand, do not let me talk you out of reaching up high. Do the best you can, do something great. That is the road to top marks. I took that road, believe me time management and focusing on your other courses is very important.

        Once your project is working, you need to test it, measure it, and provide numbers. Your work should reference other work, so you have to do some organised research etc.

        So I would just stick to voice commands if I were you (move: forward, left, right, back and stop) and call it done. 

        I would be impressed if an undergrad did that for a final year project.

        Finding the position in the room as you first mentioned is a whole different problem.

        I suppose I don't really know exactly where you are. Do you have a flying level quad already? It is my only fear that building one will be eating into a lot of your time.

    • I would like to tell you that my raspebeery pi and apm both are mounted on the quad, so is it possible just to connect them with some port and data is transmitted serially? Actually i don't have any knowledge about mavlink protocol so I was trying to make it easy without using mavlink protocol. If its not possible then can you please recommend me some tutorial for it?
      • Hi Huda

        Well you see the point of protocols is that they make life easier. Without one, you have to write one.

        Sure you may better understand one that you wright yourself, but really they are generally straight forward and will not take much time to get a grasp of quickly.

        I am sure you can somehow pass the data in serially if you have a direct connection, but a significant point is that on the receiving end there is already code in the automatic pilot that listens for commands and turns them in to actions. If you did not use the Mavlink protocol, then you would also have to implement a routine to handle the incoming serial data of yours that then converts the information in to the correct actions. Which then leads to you needing to understand the automatic pilot in more depth, write behavior code, and compile your own version of the flight control code.

        I assure you that will all be more work than simply figuring out which Mavlink protocol commands you want to use.

        No you can't take what I say as the word of God, I have not looked at any of this code myself or even the software and hardware architecture. I just know this to be true given it is a robot, in general these issues remain consistent throughout all robots and embedded systems of which this drone is.

        You do want to make your life easier here and do as little as possible so you can focus on your project details.

        Mavlink is your friend. In fact after a couple months of trying to do your own you would be wishing someone else had taken care of such tedious time delaying work.

        For example, you mention just sending the data serially. I assume you do not intend to design a UART or build an entire USB protocol (I think the USB data sheet is ~200 pages). That is a reasonable analogy to what your are proposing, to build a serial comms data transfer scheme because you have never heard of USB. despite there being USB available already for you to use. There is no good argument for that is there?

        And to reiterate, the autopilot is already listening to hear Mavlink command packets on connected port it initializes on detected connections. Again, more code you do not need/want to write.

        As far as tutorials go, you can use google just as well as i can (well maybe ;))

        I did find this though, you may want to check it out:

        http://diydrones.com/profiles/blogs/voice-controlled-drone

        Also, I can't really think of why you have the raspberry mounted on the quad as well as the APM. You just need one micro controller.

        The only thing I can picture is that you plan to do the speech recognition on the pi and then pass the processed data from the pi to the APM. That would mean you plan to put the microphone on the quad. I am pretty confident you would have a serious acoustic noise issue given the proximity of the motors. The noise will be high amplitude and variable in frequency. I could a see masters degree project in simply trying to build an adaptive filter that blocks the motor noise while still passing enough voice information to be able to perform reliable speech conversion aside form any other work.

        All you need is your pi for the speech processing and a telemetry radio link between pi and APM (can easily get cheap ones from China). Research and find the Mavlink library, load it into your control program on the pi and you are good to go. If this is work you plan on getting into, you need to be able to that with your eyes closed anyway, researching existing libraries and being able to integrate them into a system of your own. 

        Oh, i just realized to you will need a driver for a telemetry radio on the pi side as well. But that is more of the same, research the correct libraries, get them, integrate them and then you should be able to send Malvink packets to it as though it were a serial link.

        And again, I am just making this stuff up as I type it.

        good luck!

    • Unfortunately it seems posts can't be edited here.

      I have rethought my advice about ripping the Mavlink protocol out of an existing work. You can do some some research but I would assume it already exists somewhere as a stand alone library written in C.

      What I meant to advice is that you look at existing works in terms of how the Mavlink API is used. There will be some initialisation of the connection, some config work and than mapping keypad input to API calls. All you need to do is replace the buttons with your voice recognition. There is no point in reinventing the wheel with regards to the API interface code.

This reply was deleted.

Activity