0
votes

UPDATE: got the final error fixed by just actually replacing operator[] with this->operator[].

UPDATE 2: logic_error fixed! _P error is all that's left! (which only shows up in DUE, not UNO or other boards...)

UPDATE 3: Changing the name of the temp matrix to _Pt worked, might have been a reserved macro?

NEW ERROR:

Arduino: 1.6.1 (Mac OS X), Board: "Arduino Due (Programming Port)"

/Users/zackbright/Documents/Arduino/libraries/StandardCplusplus-master/func_exception.cpp: In function 'void std::__throw_bad_alloc()':
/Users/zackbright/Documents/Arduino/libraries/StandardCplusplus-master/func_exception.cpp:30:18: error: exception handling disabled, use -fexceptions to enable
        throw bad_alloc();
                       ^
Error compiling.

Looks like I need to use -fexceptions...

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

There's a lot here, but I'm hoping that giving everything is what I ought to do to get a good answer to this.

using Arduino 1.6.1 for arduino DUE on OSX.

using this library to get std namespace 'https://github.com/maniacbug/StandardCplusplus/'

And this is the library I am having trouble compiling: 'http://kalman.sourceforge.net/index.php'

I have moved around the filter library into this format to be able to use it fr arduino, and now have been able to at least do an include without it not finding the header files: file screenshot

As you can see I had to rename the files to .h headers (not sure how necessary this really was), and rename the folder to the same title as my .cpp and .h, and of course edit all the enclosed files to reference files differently: example

#include "kalman/ekfilter.hpp"
//the "kalman/" is because these used to be in a separate include folder

is now this instead:

#include "ekfilter.h"

So, now, when I just try to compile:

#include <StandardCplusplus.h>
#include <ekfilter.h>

void setup() {
  // put your setup code here, to run once:
}

void loop() {
 // put your main code here, to run repeatedly:
}

I get this mess of errors shown below.

The first error is really driving me nuts, because this StandardCplusplus library should handle the std:: namespace, and there isn't anything I can ostensibly find wrong with the implementation in that codebase.

From what I see, most of anything following _P is an issue that that first error prevents casting the _P variable as a matrix as defined in kmatrix.h. Weirdly enough, and this may point to a solution, these errors do NOT show up when I compile for Arduino UNO.

The last pair of errors I'm just unclear honestly what it even means.

Arduino: 1.6.1 (Mac OS X), Board: "Arduino Due (Programming Port)"

In file included from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/kvector.h:37:0, from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h:33, from TestKalmanLibrary.ino:2:

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ktypes.h:74:48: error: expected class-name before '{' token

struct KalmanError : public std::logic_error {
                                            ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ktypes.h: In constructor 'Kalman::KalmanError::KalmanError(const string&)': /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ktypes.h:82:9: error:

class 'Kalman::KalmanError' does not have any field named 'logic_error'

   : logic_error(message) {}
     ^

In file included from /Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/cctype:19:0, from /Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/istream:21, from /Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/iostream:27, from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/kvector.h:35, from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h:33, from TestKalmanLibrary.ino:2: /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h: At global scope:

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h:807:20:

error: expected unqualified-id before numeric constant

 mutable Matrix _P;  //!< Temporary matrix.
                ^

In file included from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h:817:0, from TestKalmanLibrary.ino:2: /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h: In member function 'void Kalman::EKFilter::init(Kalman::EKFilter::Vector&, Kalman::EKFilter::Matrix&)':

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:196:8: error:

request for member 'swap' in '16', which is of non-class type 'int'

 _P.swap(P_);
    ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h: In member function 'const Matrix& Kalman::EKFilter::calculateP() const': /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:435:10: error: request for member 'resize' in '16', which is of non-class type 'int'

   _P.resize(n, n);         // keep this resize
      ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:439:15: error: expression cannot be used as a function

     _P(i,i) = U(i,i);
           ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:443:17: error: expression cannot be used as a function

       _P(i,j)  = U(i,j)*U(j,j);
             ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:444:17: error: expression cannot be used as a function

       _P(i,i) += U(i,j)*_P(i,j);
             ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:444:35: error: expression cannot be used as a function

       _P(i,i) += U(i,j)*_P(i,j);
                               ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:447:19: error: expression cannot be used as a function

         _P(i,j) += U(i,k)*U(j,k)*U(k,k);
               ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:450:17: error: expression cannot be used as a function

       _P(j,i) = _P(i,j);
             ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:450:27: error: expression cannot be used as a function

       _P(j,i) = _P(i,j);
                       ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h: In member function 'virtual void Kalman::EKFilter::sizeUpdate()': /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:572:26: error: expression cannot be used as a function

       U(i,j) = _P(i,j);
                      ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:583:10: error: request for member 'resize' in '16', which is of non-class type 'int'

   _P.resize(n, nn);
      ^

/Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter_impl.h:586:17: error: expression cannot be used as a function

       _P(i,j) = U(i,j);
             ^

In file included from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/kvector.h:34:0, from /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/ekfilter.h:33, from TestKalmanLibrary.ino:2: /Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/string: In instantiation of 'std::basic_string::size_type std::basic_string::find_first_not_of(const std::basic_string&, std::basic_string::size_type) const [with Ch = char; Tr = std::char_traits; A = std::allocator; std::basic_string::size_type = unsigned int]': /Users/insertnamehere/Documents/Arduino/libraries/ekfilter/kvector_impl.h:66:42: required from here /Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/string:518:64: note: declarations in dependent base 'std::vector >' are not found by unqualified lookup

                             if( Tr::eq(str[j], operator[](i)) ){
                                                            ^

/Users/insertnamehere/Documents/Arduino/libraries/StandardCplusplus-master/string:518:64: note: use 'this->operator[]' instead Error compiling.

So there's a lot to fix here, but this is all after I fixed some issues with the way the library was formatted already:

I had to add -fpermissive to "/boards.txt" compiling preferences

there was a weird implementation in their code that wouldn't compile, I changed this:

// These are explicitly GNU C++ specific.

// This is the exception class we report -- "GNUCC++\0".

const _Unwind_Exception_Class __gxx_exception_class
= ((((((((_Unwind_Exception_Class) 'G' 
  << 8 | (_Unwind_Exception_Class) 'N')
 << 8 | (_Unwind_Exception_Class) 'U')
    << 8 | (_Unwind_Exception_Class) 'C')
   << 8 | (_Unwind_Exception_Class) 'C')
  << 8 | (_Unwind_Exception_Class) '+')
 << 8 | (_Unwind_Exception_Class) '+')
<< 8 | (_Unwind_Exception_Class) '\0');

to this:

const _Unwind_Exception_Class __gxx_exception_class = "GNUCC++\0";
1
looks like you should #include <stdexcept> in ekfilter.hLol4t0
that include is already in ktypes.h which is where the error is cropping up.Colin McDonnell
Also worth noting that I had to add #include "Arduino.h" to all the files so that they would compile for Arduino too.Colin McDonnell
Then you might need to reconfigure your std-lib with exception support (see)Lol4t0
OH MAN, yea you are totally right. not sure how I missed that! Changed the system config in that library and its good! Thanks so much! All that remains is the _P matrix error.Colin McDonnell

1 Answers

0
votes

ALL ISSUES RESOLVED NOW.

Last error solved by including -fexceptions in my compiler flags.

Thanks for the help guys.