8
$\begingroup$

I have a APM 3DR Quad with a 3DR radio telemetry kit. I would like to send real-time sonar data to my laptop (running Windows 7) in order to manipulate it in an additional Arduino Sketch.

The sonar sensor is connected to an Analog In channel on my Arduino. That data is processed for altitude calculations, and I would like to send this altitude data to some sort of ground station on my computer through the use of a telemetry kit (2 3DR Radios: 1 on the quadcopter and 1 on my computer).

I am not quite sure how to go about this task. Is there a way that I can modify the source code (GCS.h or GCS_Mavlink.pde) in conjunction with Mission Planner Mav 1.0 ground station to do this? Or would I need to write a python module to accomplish this?

$\endgroup$
5
  • $\begingroup$ Hi David, welcome to robotics. We're generally nice and helpful here, so I trimmed out the "thank you" line from your question -- it's understood :). One question I have is whether you are saying sonar when you mean "radio telemetry". $\endgroup$
    – Ian
    Jul 24, 2013 at 1:30
  • $\begingroup$ No, I have a sonar sensor that is connected to an Analog In channel on my Arduino. That data is processed for altitude calculations, and I would like to send this altitude to some sort of ground station on my computer through the use of a telemetry kit (2 3DR Radios: 1 on the quadcopter and 1 on my computer) $\endgroup$
    – user1702
    Jul 24, 2013 at 3:21
  • $\begingroup$ Hi user1702, comments are intended to help make questions and answers better, so it is better to add information requested in comments by editing your question, that way the comments can be tidied up (deleted) and will no longer distract people from the question. $\endgroup$
    – Mark Booth
    Jul 24, 2013 at 8:35
  • $\begingroup$ Do you want to process the sonar data on your laptop, or send it via the laptop to another arduino? $\endgroup$ Aug 1, 2013 at 7:54
  • $\begingroup$ John, I would like to process the data on my laptop. I have been trying to get mavproxy to work, but I have run into a few issues. Hopefully, I can integrate a python module to help with this. $\endgroup$
    – user1702
    Aug 8, 2013 at 6:17

1 Answer 1

2
$\begingroup$

Setting up the software to extract new custom sensor data via MAVLink seems to be harder than it should be.

Step one is to make the quadcopter send off the data.

  • First, you need to define a new MAVLink message type using XML in mavlink/message_definitions. You can just make up a new unused integer for the message_id.
  • Second, you generate the message pack/unpack functions using the MAVLink generator.
  • Then you'll need to add code to ArduCopter/GCS_Mavlink.pde in data_stream_send to build and send off your message. You do need to be a little careful here, because the flight dynamics start to degrade if your sensor reads stop the main loop for more than a few milliseconds, especially for a small quad or flying indoors (that's what the "gcs_out_of_time" business is about). I'd add a new sensor to the STREAM_EXTRA3 trigger.
  • Rebuild and upload the new flight firmware.

The other half of the project is on the PC, where you need to modify the ground station software to read your MAVLink packets out of the telemetry stream. I have no clue where you'd begin to do this to Mission Planner, which seems like a really sophisticated piece of software. But luckily it dumps raw radio telemetry to the "tlog", so you might be able to build a completely separate program that looks for your new MAVLink packet from the tlog. (You certainly don't want an Arduino Sketch for this, since a Sketch runs on the Arduino, not the PC.)

If this sounds intimidating to you, you're not alone! For our indoor quad, we ended up building our own radio communication protocol and "ground station", since we couldn't use GPS or waypoints or the other MAVLink features, and dealing with the complexity of MAVLink wasn't worth it to us.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.