Integration of Arduino libraries through Navio

Hello guys,

I have a question that I am not sure how to formulate it, therefore I will try to explain my setup and scenario:

  • Raspberry Pi connected to Navio board
  • Navio connected to IMU (from DF Robot) via I2C port

In my project I am trying to read some information from the IMU in my Qt application developed on Raspberry Pi. The problem is that the libraries the IMU from DF Robot needs for calling specific function ( the .h files) are developed for using them in Arduino IDE, therefore, it depends on many other specific Arduino libraries, which are either different or don’t yet exist for Raspberry Pi.

Now, I have contacted Tech Support form DF Robot in order for solving this issue, and they recommended using an Arduino Shield from Raspberry Pi and connect it to the IMU. But, as other hardware components depend on Navio, I would like to avoid replacing it with and Arduino Shield. Is there any way of doing that?

Could you please give me some suggestions for doing that? Any piece of advice is highly appreciated.

Thank you very much!

First off, I wanted to ask you a question beforehand in order to better grasp what exactly you’re trying to achieve.
From my perspective it looks like you don’t really need DF Robot because you already have all of the necessary sensors on Navio itself. Navio 2 has even two IMUs with magnetometers and all of the drivers in place.

Getting back to the original issue at hand.

You’re right replacing it with an Arduino Shield is not needed because DF Robot is connected via I2C which there’s a connector for on the Navio. You just plug it and verify with i2cdetect -y 1 that new sensors were probed.

There’re project like this one might shed a light on the issue. Even though, the better approach to problem will be to abandon Arduino libraries all together for any serious project. This is what ArduPilot project did a couple of years ago.

I recommend starting looking into our examples which are very similar to the project you linked to. Navio 2 gives you a lot of options such as preinstalled ROS (Robotics Operating System) which at least deserves a look.
It’s better not to swim against the current in this situation. Arduino API is as simple as it’s simplistic. It might bite you in future as it’s done the ArduPilot project (even the name is tied up to the Arduino Project even though it doesn’t work on it at all).

There’re other opportunities to discuss but I need to hear more details about the eventual goal.

Hey George,

Thank you for your comprehensive response. I understood what you meant by swimming against the current, but, given my current setup, I am not sure that I can fully avoid that. Let me clearer about the setup:

  • Raspberry Pi connected with Navio (not 2, therefore not having IMU), Navio connecting other sensors
  • an app developed in QtCreator running on Raspberry Pi that connects everything together
  • need gyroscope data, the DF Robot IMU having a dedicated MEMS gyro for applications where noise is present and needs prefiltering (which is my case, as the system works outside, on water)

I just need to read the data from the IMU, so that I could perform some tasks. I am not sure if I would enhance the complexity of the app using the ROS plugin, as, in the end, I just need to read some values, not to control a serial robot with 6DOFs.

I am not sure if the Arduino framework for RPi will help, as I don’t want to program the whole system through Arduino IDE, but through QtCreator.

The thing that I would want to avoid is adding a small Arduino board to parse the signal and send it to RPi, as space is an issue in my application.

Many thanks again and I am open to your suggestions!

I do not get what you mean. Even the first Navio (not +, not 2) had a 10dof IMU + GPS.
There is no need for additional IMUs.

1 Like

Hey Sebastian,

I did also think that Navio has IMU, as it was written in its Navio documentation, but I gave up after I could not read any data. I tried the demo code from the Navio docs and also embedding it in my Qt program, but I always get 0.000 for any read sensor, in both cases.

Just figured out why I got 0.000 values:

The initalisation of an MPU9250 object, that would let you access the API of the Navio IMU, is faulty when calling it in the setup part.

Solution: After running imuObject.initialize() at the start of each cycle of data reading (e.g. every second) it seems to work flawlessly.

Nevertheless I can’t be sure whether the resets in the registers that the function initialize() does would not alter the expected readings from the IMU. Moreover, I don’t think this is the way it should be used…but I cannot see where does this initialisation error come from. Should I start a new topic and close this one, as the subject has significantly changed?

Could you please post the output of emlidtool?

Using ROS liberates you from writing C++ code for sensors. So I wouldn’t give up on this approach. I suggest you trying it out.

Hey,

Here is the emlidtool output. Seems like The board is not well screwed. But if so, why do all other functions work flawlessly? Shouldn’t it be a voltage supply problem for the electronics then?

emlidtool version: 0.8.8
Traceback (most recent call last):
File “/usr/local/bin/emlidtool”, line 9, in
load_entry_point(‘emlidtool==0.8.8’, ‘console_scripts’, ‘emlidtool’)()
File “/usr/local/lib/python2.7/dist-packages/emlid/emlidtool.py”, line 81, in main
do_info()
File “/usr/local/lib/python2.7/dist-packages/emlid/emlidtool.py”, line 33, in do_info
information = DeviceInformation()
File “/usr/local/lib/python2.7/dist-packages/emlid/deviceinfo.py”, line 18, in init
raise NoHatException(“Seems like you booted without Navio properly screwed!”)
emlid.deviceinfo.NoHatException: Seems like you booted without Navio properly screwed!

This error indicates that /proc/device-tree/hat/product is missing. There’s not too many reasons why it can happen. Namely, it’s loose connection or a failure on factory which is not likely to happen. We don’t ship those boards that don’t have these settings flashed.

Have you modified /boot/config.txt or launched raspi-config?

I have edited /boot/config.txt or launched raspi-config for the same reason: to enable communication protocols such as I2C or enable VNC, no other witchcraft. Is there something overlapping here with the Navio settings?

I really don’t have much knowledge on Arduino, however, I want to know if I can control the speed of my motor using Navio2 and arduino or raspberry pi 3. I want to build a VTOL jet, with a chamber for air intake and outtake. With in this setup, there will be an edf fan, and there will be four other edf connected to the chamber via an air valve. The four smaller edf will be for vertical takeoffs and landings, while the 90mm will be for the jet. My question is how can I control each of these motors individually, in the way, the jet motor will spin at a lower speed just to supply the other four motors with air for vertical takeoff, once the jet reaches its desired altitude, then the four motors will stop spinning, while the 90mm edf will hit full speed. This process will be repeated automatically when the drone is ready to land. I will appreciate anyone who might help me out.

Hi, @gwehfranklin12

To control the speed of your edf, you need to set the correct frequency and duty cycle to the PWM channels. Here you can find the code examples.