Sending raw sensor data out on SPI or UART

Hello

I’m pretty new to this platform. I’m using an APM 2.6 variant with Atmega.
Could someone advise how I can achieve the following ?
I need to send raw sensor data at a certain frequency (gyro , acc , barometer and GPS) from the APM out through SPI or Uart or whatever to my main control unit .

I installed the modified arduino IDE and am planning to modify the code to add the specific user functions.

Looking through the code I see here: http://dev.ardupilot.com/wiki/code-overview-scheduling-your-new-code-to-run-intermittently/ that I can do this by putting the code in the userloops or in the task scheduler.

My first question is : How do I access the sensor data? Is the latest sensor data stored statically somewhere in the memory into which I can read out and grab? Or will I need to call the sensor and request the data?

My second question is: How do I use the SPI or UART without risk of screwing up the rest of the system? (is that possible? ) Will I need to import a library and just use a send function to send the data?

My guess is that I’ll put the IMU , compass and barometer data out on the 50 Hz loop and the GPS on the 10Hz loop.

I’ve opened the sensor libraries but there are 30 files in each library and I have no idea where to start and what to use . The whole thing looks like a mess to me so I would appreciate some help here. Please don’t redirect me to yet another wall of text.

So… No one in this community has done something like this?
No one knows how to send raw sensor information in a 50hz loop?

I’ve done things like this before. The way I’d recommend is adding a custom MAVLink message and sending it via the UART. If you haven’t had a chance to look into MAVLink yet I’d recommend it. There really isn’t any great developer level documentation so it’s a ‘learn-as-you-go’ experience. Start at GCS_Mavlink.pde.

Here’s how I would do it. Add a MAVLink message which contains exactly the information you want to send. In the userhook 50hz loop, add some code to send the message. A word of warning though, 50 hz is pretty fast. If your message is too large, there won’t be enough bandwidth on your UART to get everything through. You can do the calculation pretty easy. Take your baud rate (57600, for example), and divide by 10*the number of bytes you plan on sending (yes, a byte is really 8 bits but there’s a start and stop bit so it ends up being 10 bits per byte). This number is the theoretical maximum number of messages you can send in a second.

Just a note on your “wall of text” aversion. Learning this code is like drinking from a fire hose. It takes some patience at first. No one is able to just hand you a working solution. With a little patience I’m sure you can get it.