Monday, November 26, 2012

Orientation sensing with the Raspberry Pi and MinIMU-9 v2

The Raspberry Pi is an ideal platform for experimenting with inertial measurement units (IMUs). These IMUs are usually I²C devices, so it is straightforward to access them using the Raspberry Pi's I²C bus. The integrated 3D graphics on the Raspberry Pi are useful for visualizing the results.

I have made some software that allows you to connect the MinIMU-9 v2 from Pololu Robotics & Electronics to your Raspberry Pi and calculate the orientation of the IMU. I also wrote a visualization program that shows the results in 3D. Check out the demo in this video:

The software is open source and I have written a tutorial for it. The only items needed besides your Raspberry Pi setup are:

Soldering is required: the male header pins that come with the MinIMU-9 v2 need to be soldered in.

The MinIMU-9 v2 can be conveniently powered from the Raspberry Pi's 3V3 power line. The photos below show how to connect a MinIMU-9 v2 to a Raspberry Pi:

Wiring

The software consists mainly of two programs, both written in C++. The minimu9-ahrs program reads data from the MinIMU-9's sensors via I²C, calculates the orientation of the IMU, and outputs data to the standard output. Internally, it represents the orientation with a quaternion, but several different output options are available: direction cosine matrix, quaternion, euler angles, and raw sensor data. The ahrs-visualizer program reads direction cosine matrix data from its standard input and displays a 3D representation of the MinIMU-9 v2 using OpenGL. I also used libi2c, libpng, the Boost program_options library, and Eigen. There is a Python script that helps calibrate the magnetometer. For easy installation of the software, I have created Debian packages.

For more information, see the tutorial! I would love to see what people build with this, so please post comments below!

82 comments:

  1. Dear Mr.David, I did all the steps accordingly but I am still encountering a problem when I tried to install the package referring to 'dpkg -i minimu9-ahrs_VERSION_armel.deb' and I cannot find out what the problem is. Do you know where did I do wrong?

    ReplyDelete
  2. Shahirah: Please create a new github issue here and give me all of the details about what you are doing what you are seeing: https://github.com/DavidEGrayson/minimu9-ahrs/issues?state=open

    ReplyDelete
  3. Dear Mr. I want to try this code with a microcontroller PIC, but I can´t written correctly can you help to write this code in C. for CCS ??? thank you.

    ReplyDelete
    Replies
    1. Sorry, this code is not well-suited for a PIC because it uses the Eigen library and lots of fancy features of C++. You would be better off looking at this code, which is similar: https://github.com/pololu/MinIMU-9-Arduino-AHRS

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Just wanted to say thanks for this, it's been very helpful :)

    ReplyDelete
  6. Noobie here. Think I've got everything installed but when running minimu9-ahrs it fails to open ic2 device. I have the MinIMU-9 v2. and the latest pi. i2cdetect -y 1 shows the 3 addresses 19 1e and 6b for the MinIMU-9 v2.. also having trouble installing ahrs-visualizer. Suspect I'm having trouble with the basics. Just got started with the PI and all this about a week ago. Any help would be appreciated.

    ReplyDelete
    Replies
    1. You probably have a newer Raspberry Pi that exposes the pins for /dev/i2c-1 instead of /dev/i2c-0. You will have to provide the right options to my programs to use the correct I2C bus.

      Delete
    2. I kinda figured my device wasn't the 0 but was 1 so I tried to tell it otherwise but this is probably where I have a big hole in my understanding and I'm probably entering the wrong thing. I put sudo minimu9-ahrs -b, /dev/12c-1 after the -b, I've tried many thinks like --12c-1 --/dev/i2c-1 /dev/i2c-1 i2c-1 but I really don't understand the syntax and/or may be using the wrong command all together. I get errors like no such option, no such file or directory etc. Thanks for your come back. This old guy appreciates it!

      Delete
    3. My memory is foggy too. Did you try "--help"? What did it say?

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. I've been looking at "man minimu9-ahrs" for help. Just now looked at minimu9-ahrs --help and get similar stuff. I've tried the following but even after looking at the help I'm not really sure of the syntax. like single - or double dash or commas -b or arg just not really sure of what I should use. for example if I type the following:
    "sudo minimu9-ahrs -b, --/dev/i2c-1" gives me
    "Error: unknown option /dev/i2c-1" If I try
    "sudo minimu9-ahrs -b, /dev/i2c-1" gives me
    "Error: Failed to open I2C device.: No such file or directory No such file or directory (system:2)" and the help is similar to the man stuff
    "sudo minimu9-ahrs --help" gives me
    "Allowed options:
    -h [ --help ] produce help message
    -v [ --version ] print version number
    -b [ --i2c-bus ] arg (=/dev/i2c-0) i2c-bus the IMU is connected to
    --mode arg (=normal) specifies what algorithm to use.
    normal: Fuse compass and gyro.
    gyro-only: Use only gyro (drifts).
    compass-only: Use only compass (noisy).
    raw: Just print raw values from sensors.
    --output arg (=matrix) specifies how to output the orientation.
    matrix: Direction Cosine Matrix.
    quaternion: Quaternion.
    euler: Euler angles (yaw, pitch, roll).


    For more information, run: man minimu9-ahrs"
    So am I typing stuff in wrong or just don't have a clue?

    ReplyDelete
    Replies
    1. Except for the --help, the stuff you tried simply doesn't look valid. Why did you put a comma after b? What about "-b /dev/i2c-1" ?

      Delete
    2. This comment has been removed by the author.

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I am facing the same problem here, Is there any known solution?

      Delete
  9. This comment has been removed by the author.

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Hello David,
    I am using a Raspberry Pi and the MinIMU-9 v2 module for controlling an autonomously flying model airplane.
    I have compiled the program from source code and everything seems to work fine but there is one problem I have: The MinIMU module is mounted into the airplane rotated 180° about the X-axis (X=X, Y=-Y, Z=-Z). What can I do to get the right output? Change the source code? Where?

    I would appreciate your help.
    Best regards
    Wolfgang from Germany




    ReplyDelete
  13. Hi Dave, I'm pretty new to Raspberry Pi. I'm a software engineer by profession and have tinkered with electronics from time to time as well. I'm looking at reverse engineering the Technomancer Hoodie that ThinkGeek sells into a custom Halloween costume with a bit more control and functionality. I haven't sourced or picked up any components yet since I'm still in the research phase. This project looks like a great place to start. I was wondering though if it's possible to connect TWO IMUs to the Raspberry Pi? It looks like GPIO pins 0 and 1 are the only pins suited but I could be wrong.

    The idea is to attach one IMU to each wrist with a wrist band and track the movements of each arm.

    ReplyDelete
    Replies
    1. The Raspberry Pi actually has two I2C busses (/dev/i2c-0 and /dev/i2c-1) but I think one of them is on a different connector or maybe no connector at all. And one annoying thing is that they switched the I2C interfaces between revisions. If you can figure out a physical solution to getting access to the other I2C bus, then you should be able to use two instances of my software running on two different busses.

      Since you and I are a software guys though, maybe it would better to find some library for the Raspberry Pi that does software I2C on two of the other GPIOs. When you are the master in an I2C bus, timing is not very important and you could implement a bit-banging I2C thing from user space in any language. Someone must have done this already.

      Delete
    2. A few Google searches led me to this: http://lwn.net/Articles/230571/

      Delete
  14. I am using two minimu-9 v2 sensor.I use 4052 multiplexer but it didnt work.I didnt solve problem.I controlled two servos with two pot that using multiplexer.Can you any sugesstion?

    ReplyDelete
  15. Hi Mr.David,
    I am an experienced Italian helicopters, Raspberry use to interface the weather station and webcam present in an oil rig.
    I would like to add the ability to display also the pitch and roll and heading of the platform and then access the data via the web in my site .... is it possible using its software generating a web page?
    Thank you for your attention ...

    Christian D.
    Italy
    cris412@libero.it

    ReplyDelete
  16. David,

    Awesome project page! I just got my minimu9 v2 last week from Pololu. I used a 256MB RPi running Raspian and although it took a few hours of compiling source files (I was using armhf EABI), I finally got everything running. I was taking notes along the way so that I could document my steps as they were fairly different from the tutorial. The tutorial was awesome and very helpful! I'll post a page in the next couple days to help others who may be trying with a similar setup.

    Cheers,
    Mike

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Hello David great work!
    how bout a device that i would wear on my wrist or ankle and detect motion for a pedometer?
    my roomate is a mathemetician, so im thinking that perhaps the data from the minimu be crunched to interpret motion.
    also, if i have the ahrs program record raw sensor data to a file, can i run the program later and have it take it's input from the file?

    thanx, mike
    spillikinaerospace@yahoo.com

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Hi David,

    As promised, I've put up a companion tutorial for anybody who might have a slightly different Pi setup.

    http://www.nacionale.com/pololu-minimu9-step-by-step/

    Thanks again for your tutorial!
    Mike

    ReplyDelete
    Replies
    1. Had to update the link since the old link was no longer valid.

      Delete
    2. Hey mike, thanks for writing your tutorial! Hey, I noticed you called me "David Gray" a few times and you have a random "br />" hanging out in the middle of the post. I added a link to your tutorial on https://github.com/DavidEGrayson/minimu9-ahrs/wiki

      Delete
  21. Dear David,

    I am trying to create an AHRS box. I have tested two boards Arduino Uno and Netduino Plus 1 with PololuIMU-9-v2 using Madgwick's algorithm (http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/). Une update of the quaternion took around 20 milliseconds (50Hz) on Arduino and around 30 ms (33 Hz) on Netduino. Do you know what is the frequency of updates in your case?

    ReplyDelete
    Replies
    1. Hello, Tomaz. It's important to make the distinction between the actual CPU time it takes to do the update computations, and the time the program waits between computations. I haven't measured the CPU time carefully, but the minimu9-ahrs software I wrote is designed to do the computations every 20 ms, and this is controlled by the "ahrs" function you can find in minimu9-ahrs.cpp. That source code is here:

      https://github.com/DavidEGrayson/minimu9-ahrs/

      I really doubt that the Netduino would be slower at doing a computation than the Arduino, though I guess it depends what type of Arduino you are talking about; were you talking about one of the newer 32-bit ones? It's more likely that the code you were looking at is just spending some time waiting in a loop before doing the next calculation.

      Delete
    2. Hi! Thank you for quick reply.

      Well, I have been playing around measuring time and I am pretty sure that the calculation itself takes around 15ms on Netduino, but readings and the basic program structure add allmost 15ms. It seems that fancy C# .NET Micro Framework environment has a lot of overhead which makes it even slower than Arduino Uno. I am talking about these two boards:

      http://arduino.cc/en/pmwiki.php?n=Main/arduinoBoardUno
      http://www.netduino.com/netduinoplus/specs.htm

      Delete
  22. Hi david!
    I have a problem, when I put this command for install minimu9-ahrs "wget http://www.davidegrayson.com/minimu9-ahrs/debian/minimu9-ahrs_2.0.0-1_armhf.deb
    dpkg -i minimu9-ahrs_2.0.0-1_armhf.deb" gives me "not urls found in minimu9-ahrs" so when I continue with the next step I type "minimu9-ahrs --mode raw" gives me "bash: minimu9-ahrs: command not found"
    Do you know where did I do wrong please?

    ReplyDelete
    Replies
    1. That error message doesn't even sound like correct English. Could you tell me which of the two commands is causing the error and then copy and paste the full output of that command here?

      Delete
  23. Hi David,

    Thank you for sharing your code.
    I have a problem and maybe you can assist me.

    I bought the MinIMU-9 v3 and wrote a display based on the minimu9-ahrs readings, the display suppose to show the roll, pitch and heading of an airplane.

    The display works great on the ground, but it seems that I don't get the expected readings of roll and pitch while flying an Ultralight airplane.

    I used the Euler output mode and read the first 3 numbers.
    what am I missing? what is different while flying as opposed to using it on the ground?

    Thanks,
    Ohad

    ReplyDelete
    Replies
    1. Hello, Ohad. This is a known issue we have been discussing on Github: https://github.com/DavidEGrayson/minimu9-ahrs/issues/9

      I think the main difference between flying and being on the ground is that you might be in the middle of a banked turn or something like that where there is a long-lived bias to the acceleration felt by the MinIMU-9, and the acceleration doesn't represent gravity.

      Delete
    2. Thanks you for the reply, I appreciate your support.

      As you were saying, I was testing the MinIMU-9 while flying in around of 60 degrees turn when I saw it doesn't shows what I expected.

      If you will have any ideas/suggestions on how to solve it or how to identify those difficult situations while flying in the future please contact me and maybe we can test it together.

      Thanks again,
      Ohad

      Delete
  24. This comment has been removed by the author.

    ReplyDelete
  25. Hi David,

    For a project I am working on, I would like to use the information from the IMU to create a visualisation of the movement, similar to what is in the video above. However, instead of showing the IMU, it would show a simple cantilever beam oscillating. I am not entirely sure where to begin though, could you give some pointers to get me started?

    Thanks,
    Calum

    ReplyDelete
    Replies
    1. Hello, Calum. The first step would be to compile your own version of my ahrs-visualizer program from source by following the instructions in the readme: https://github.com/DavidEGrayson/ahrs-visualizer.

      Delete
  26. David,

    Thanks for the great tutorial and sample source code. With it, I've been able to turn a Pi into an airplane attitude indicator (see https://www.youtube.com/watch?v=YbeCf9uedL8 ).

    Now I've been looking for a way to extract a magnetic compass heading without much success. I thought I could simply use the angle of the "north" vector from the rotationFromCompass function on the x-y plane, but the angle doesn't match anything like a heading.

    I would welcome your suggestion on how to tackle this.

    Thanks,

    Charles

    ReplyDelete
    Replies
    1. Hey Charles. Nice work! It sounds like you are editing the source code of minimu9-ahrs to do something custom. Instead, you could just run "minimu9-ahrs --output euler" to get all three numbers you are interested in: pitch, yaw, and roll. The yaw is the compass heading.

      Delete
    2. That is what I had initially thought but it wasn't working, the heading almost never changed regardless of orientation. I went back and did a little more investigation and got it to work. The first Euler angle (as produced by eulerAngles(2, 1, 0) ) does correspond to a heading but only if the board is nearly horizontal with the chips facing down! I would have expected the opposite based on the LM303 datasheet. Any ideas?

      Delete
  27. This comment has been removed by a blog administrator.

    ReplyDelete
  28. This is stunning, so much appreciation from here!! I'm learning enough C++ to edit it so I can add support for the AltIMU10v3 (the code works fine with this sensor, it's just I also want to use the Altitude sensing that the AltIMU has) The ultimate aim is to integrate it with a stepper motor to develop an automatic kite controller.

    ReplyDelete
  29. Program runs good in --mode raw. Problem arises when I run "minimu9-ahrs-calibrate -b /dev/i2c-1"
    (I am running Raspberry Pi 2 B). Gathering the raw data is fine but when it goes to optimize the data
    I get:
    $ minimu9-ahrs-calibrate -b /dev/i2c-1
    To calibrate the magnetometer, start rotating the IMU through
    as many different orientations as possible.
    Reading data... done.
    Optimizing calibration...Traceback (most recent call last):
    File "/usr/bin/minimu9-ahrs-calibrator", line 147, in
    run()
    File "/usr/bin/minimu9-ahrs-calibrator", line 101, in run
    full_output=False, disp=verbose, retall=False)
    File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 373, in fmin
    res = _minimize_neldermead(func, x0, args, callback=callback, **opts)
    File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 438, in _minimize_neldermead
    fsim[0] = func(x0)
    File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 281, in function_wrapper
    return function(*(wrapper_args + args))
    TypeError: can only concatenate tuple (not "list") to tuple

    I don't know python well enough (hardly at all) to know if your script is at fault or do I have another
    problem.

    I have your program running on an older RPi B but want to use the newer RPi 2 B. I am running minimu9 v3 hardware with a kernel version 4.1.0-v7. If you believe my kernel is the problem then could you tell me what version number you have tested yours on.

    Thank you

    ReplyDelete
    Replies
    1. I remedied the problem by replacing your new calibrate script with your older script. The calibrate routine now optimizes the raw data. The other modes and outputs are working now.
      I haven't a clue as to why the new script won't work.

      Delete
    2. Hey i am getting the same problem as defined above. How did you replace the new script with older script?

      Delete
    3. You need to alter line 100
      with the call to scipy.optimize.fmin
      args=[raw_readings],
      Should read
      args=(raw_readings,)
      Note the comma should be there


      I don't know why more people are't having this problem.

      Delete
    4. I am having the same problem stated above and I saw your answer. I am not sure how to alter the line in the scipy.optimize.fmin. Can you please help?

      Delete
    5. Eldorado Space Progam Eagles: You're not supposed to edit scipy.optimize.fmin, you're just supposed to edit line 100 of the minimu9-ahrs-calibrator script. You should be able to find that script in /usr/bin/ or something like that depending on exactly how you installed the software. You can use "sudo nano /usr/bin/minimu9-ahrs-calibrator" to start the nano editor. If you continue to have trouble, you should try to be more specific about what you tried and why it isn't working.

      I am sorry that my Python code hasn't been updated in a while; even if you do get it to run, there is no guarantee it will come up with a good answer, but it will at least warn you if it comes up with a bad answer. I intend to replace it with a more robust script some day.

      Delete
  30. Hi David,
    Thank you for your efforts. I have cloned your github site successfully and made sure my wheezy is up to date. When I run sudo make install I get the following error:

    sudo make install
    g++ -I. -Wall --std=c++0x -O3 -Wno-psabi -MD -MP -c -o minimu9-ahrs.o minimu9-ahrs.cpp
    minimu9-ahrs.cpp:11:37: fatal error: boost/program_options.hpp: No such file or directory
    compilation terminated.
    : recipe for target 'minimu9-ahrs.o' failed
    make: *** [minimu9-ahrs.o] Error 1

    I have been to the Boost site, but cannot find the missing header file. do you have any suggestions?
    Thank you for any assistance you are able to provide.

    Regards,
    Geof

    ReplyDelete
    Replies
    1. Geof: if you want to compile minimu9-ahrs from source instead of using the packages I have prepared, you will need to carefully follow the instructions here: https://github.com/DavidEGrayson/minimu9-ahrs

      Delete
    2. My apologies, David. I did not realize that you had packages already compiled for the R Pi. I will download those and give it a shot. I had failed to install the boost libraries, which gave me the above error. Having installed those got me to issues in I2Cbus.cpp.
      g++ -I. -I/home/pi/boost_1_59_0 -Wall --std=c++0x -O3 -Wno-psabi -MD -MP -c -o I2CBus.o I2CBus.cpp
      I2CBus.cpp: In member function ‘void I2CBus::writeByte(uint8_t, uint8_t)’:
      I2CBus.cpp:31:61: error: ‘i2c_smbus_write_byte_data’ was not declared in this scope

      I also had an IOCtl error which I fixed by adding #include to I2CBus.cpp.

      I will give the packages a try. Thanks for your prompt response. It was appreciated.
      Regards,
      Geof

      Delete
    3. Thank you, David,
      I am confused as to which packages I should download. I have downloaded the source, but would prefer not to have to build from scratch. Specifically I would like to know which package to download. I must be missing something obvious here.
      Regards,
      Geof

      Delete
    4. David,
      Please put my last posts on hold. I downloaded the .deb pkg and it installed. I will now try this and report back my results. I had a lot of dependencies to resolve!
      Regards,
      Geof

      Delete
    5. David,
      All is up and running with the magnetometer calibrated. Thank you for your efforts on this project. Nice job. Now to try and integrate it into something useful!
      Regards,
      Geof

      Delete
  31. I wish to use minimu9-ahrs to estimate position at regular time intervals. To do that Each sample should have a time associated with it. Is there any code that already does this? If not, How can you get a time interval for each sample?

    ReplyDelete
  32. David,
    As you probably already know the minimu-9 v3 is being phased out and replaced by the V5. Will you be looking at this new module and/or anticipate any code changes for the upgrades in the V5?

    Thanks.
    Bill

    ReplyDelete
  33. Hello, Bill.

    Thanks for your interest in the software. Yes, I intend to update it to work with the latest MinIMU-9 at some point, but I won't promise a specific time.

    It looks like there are still dozens of MinIMU-9 v3 and AltIMU-9 v4 boards available, which are compatible with this software.

    ReplyDelete
  34. Hi David, I've been using parts of your software for some time with an AltIMU-10 and it's fantastic. In fact I expanded the library to include the code needed to interface with the altimeter and do altitude calculations (would love to contribute it to your repository).

    I recently upgraded my Pi to GCC 6.1 and the compilation doesn't work anymore and fails with the errors below. Any idea of a quick fix for this?

    g++ -lboost_program_options minimu9-ahrs.o I2CBus.o MinIMU9.o LSM303.o L3G.o -o minimu9-ahrs
    minimu9-ahrs.o: In function `boost::program_options::typed_value, std::allocator >, char>::xparse(boost::any&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&) const':
    minimu9-ahrs.cpp:(.text._ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE6xparseERNS_3anyERKSt6vectorIS7_SaIS7_EE[_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE6xparseERNS_3anyERKSt6vectorIS7_SaIS7_EE]+0x2c): undefined reference to `boost::program_options::validate(boost::any&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, std::__cxx11::basic_string, std::allocator >*, int)'
    minimu9-ahrs.o: In function `boost::program_options::basic_command_line_parser::basic_command_line_parser(int, char const* const*)':
    minimu9-ahrs.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0xd8): undefined reference to `boost::program_options::to_internal(std::__cxx11::basic_string, std::allocator > const&)'
    minimu9-ahrs.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x124): undefined reference to `boost::program_options::detail::cmdline::cmdline(std::vector, std::allocator >, std::allocator, std::allocator > > > const&)'
    minimu9-ahrs.o: In function `boost::program_options::typed_value, std::allocator >, char>::name[abi:cxx11]() const':
    minimu9-ahrs.cpp:(.text._ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameB5cxx11Ev]+0x14): undefined reference to `boost::program_options::arg[abi:cxx11]'
    minimu9-ahrs.cpp:(.text._ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameB5cxx11Ev]+0x18): undefined reference to `boost::program_options::arg[abi:cxx11]'
    minimu9-ahrs.o: In function `main':
    minimu9-ahrs.cpp:(.text.startup+0x70): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string, std::allocator > const&, unsigned int, unsigned int)'
    minimu9-ahrs.cpp:(.text.startup+0x7e0): undefined reference to `boost::program_options::error_with_option_name::get_canonical_option_name[abi:cxx11]() const'
    minimu9-ahrs.o:(.rodata._ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE[_ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE]+0x1c): undefined reference to `boost::program_options::value_semantic_codecvt_helper::parse(boost::any&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, bool) const'
    collect2: error: ld returned 1 exit status
    : recipe for target 'minimu9-ahrs' failed
    make: *** [minimu9-ahrs] Error 1

    ReplyDelete
    Replies
    1. Charles, I have a hunch it might be an ABI change between GCC versions. Could you run "make clean" and try again?

      Delete
    2. If that doesn't work, make sure you have upgraded all your packages, because you might have a version of boost compiled with the old version of GCC.

      Delete
    3. Hi David, make clean and retrying produces the same result. I'll try recompiling boost from source with the new compiler.

      Delete
    4. Huh, you really shouldn't have to do that, just use apt-get to update the boost package. Like "apt-get update" "apt-get upgrade" or something like that.

      Delete
    5. Hi David, my Pi is running Wheezy but Wheezy comes with GCC 4.9 as its default compiler. Qt 5.8 cannot be compiled with GCC 4.9 so I decided to upgrade GCC to 6.1 by compiling it from source on the Pi. After this GCC upgrade, some modules that have close dependencies with libstdc++ or libc sometimes don't work, as is the case with Boost. Recompiling Boost with GCC 6.1 fixed the problem.

      Can't wait for Jessie to be released. Anyhow, thanks for your quick responses.

      Delete
    6. I guess I'm not out of the woods yet. The program compiles fine but I get this when running the calibration routine:

      ./minimu9-ahrs-calibrate -b /dev/i2c-1
      To calibrate the magnetometer, start rotating the IMU through
      as many different orientations as possible.
      Reading data... done.
      Optimizing calibration...Traceback (most recent call last):
      File "./minimu9-ahrs-calibrator", line 147, in
      run()
      File "./minimu9-ahrs-calibrator", line 101, in run
      full_output=False, disp=verbose, retall=False)
      File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 373, in fmin
      res = _minimize_neldermead(func, x0, args, callback=callback, **opts)
      File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 438, in _minimize_neldermead
      fsim[0] = func(x0)
      File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 281, in function_wrapper
      return function(*(wrapper_args + args))
      TypeError: can only concatenate tuple (not "list") to tuple

      Delete
    7. The Python library I was using made a breaking change. See this issue:

      https://github.com/DavidEGrayson/minimu9-ahrs/issues/21

      I think I'll steer clear of Python soon and just do a much simpler calibration algorithm.

      Delete
    8. You're going to have lot of trouble with the two different C++ ABIs coexisting on one system. None of the C++ programs you compile can use the C++ libraries from Raspbian.

      Delete
  35. This comment has been removed by the author.

    ReplyDelete
  36. It sounds like you are very new to Linux. Once you learn how to open a command-line terminal, you should read about the "cd" command, which lets you change directories. Make sure you also know "ls" and "pwd" too. There are lots of resources if you search for something like "cd command linux" online, or just type "man cd" in your terminal.

    ReplyDelete
  37. This comment has been removed by the author.

    ReplyDelete
  38. This comment has been removed by the author.

    ReplyDelete
  39. Did you try searching Google for "how to navigate to directory in linux"?

    ReplyDelete
  40. If your compiler isn't recognizing that option, it might be really old. What Linux distribution are you using, and what version? Can you please post the output of "which g++" and "g++ -v"?

    ReplyDelete
  41. No, there is no reason why some source files sitting around on your Pi would cause G++ to forget how to interpret standard, normal command-line options. You still haven't told me what version of g++ you have, is there some good reason why you can't run "g++ -v" and post the output here? Why didn't you do that already?

    ReplyDelete
  42. You also forgot to tell me what Linux distribution and version you are using. For reference, I am using Raspbian 8 (Jessie) and I have g++ 4.9.2 and it recognizes "--std=gnu++11" just fine.

    After you figure out what version of g++ you have and what kind of Linux you are running, you should run "man g++" so you can read about what command-line options your compiler accepts and figure out how to change my Makefile. I have a hunch about what the problem is, but you should learn how to read the documentation and figure this stuff out yourself if you are going to get in the habit of building software from source. Of course, let me know if you get stuck, but please answer by questions first before asking more questions of your own.

    ReplyDelete

Note: Only a member of this blog may post a comment.