Giter Site home page Giter Site logo

vancegroup / eigenarduino Goto Github PK

View Code? Open in Web Editor NEW
73.0 9.0 10.0 30.54 MB

Port of the Eigen matrix-math library to the Arduino (and similar AVR platforms)

License: GNU General Public License v3.0

C++ 35.70% C 64.18% Shell 0.02% Objective-C 0.10%

eigenarduino's Introduction

Eigen for Embedded Use

Maintained at https://github.com/vancegroup/EigenArduino by Ryan Pavlik - [email protected] [email protected]

The Eigen C++ template matrix/vector math library is great: simple syntax, that through the power of expression templates, compiles to code rivalling the speed of Fortran.

Sometimes you need to do a little matrix math on a microcontroller. I don't like to reinvent the wheel, nor do I find extracting the C-style math routines from some existing open-source Arduino code particularly appealing. I'd much rather use what I know works and what I already use on the desktop.

Thus, Eigen for Arduino/AVR. Yes, it works, and it's lovely.

Details

This branch (Eigen30) contains a lightly-modified version of Eigen 3.0.6. Importantly, it includes a header to both indicate to the Arduino IDE that this library should be used, and set up the preprocessor environment so the ample #define lines in the Arduino and AVR libraries don't wreak havoc with Eigen.

General Usage

The avr-gcc toolchain, while capable of compiling C++, doesn't include a C++ standard library implementation. Thus, you'll have to provide your own. I've worked with the following two:

  • stlport-avr - This is what is most frequently used/tested with EigenArduino: it's based on a complete, widely-used, liberally-licensed standard library implementation (STLport - which contrary to popular belief, hasn't sat dormant since the last tagged release in 2008 - see the STLport git repo for ample signs of life). If you can control your compiler flags and use a new enough GCC, you can even use the C++11 version of STLport (master/pre-6.0). As it's just a branch of the main STLport repo, with an "Arduino-compatible" installed branch updated with an included build script, keeping in sync with upstream improvements is simple. The main drawback to using this as your C++ standard library on AVR is that iostreams won't work: They're highly dependent on locale support, and I haven't yet figured out a good way to fake/disable that.

  • StandardCplusplus - This is a more minimal, but also more incomplete library, based on the LGPL v2.1+ uClibc++ library with added (MIT-licensed) headers for Arduino stream and std::iostream interaction from Andy Brown's SGI STL port. This is actually my fork of the initial StandardCplusplus project. That initial version, like upstream uClibc++, lacked implementations for some important headers used by Eigen (such as <limits>!), hence the need for modifications. I do think it works (as in builds) now with Eigen, but I'm not tremendously confident that my additions are correct or complete. As it is a distinct repository from the uClibc++ it was based on, investigating changes and keeping in sync with upstream is a challenge. (I did a merge once, but it wasn't fun.) The advantage to this library is that it does contain iostream support that works. It also claims to be modified to improve embedded performance, though I have done no empirical testing to support or refute this.

Arduino-Specific Usage

Get it

Clone, add as submodule, or download and unzip the desired branch of this repository inside your Arduino "libraries" directory, named to match the branch name. (If you need more detail, see [my instructions with screenshots][stlport-wiki] for doing this with STLport-avr, it's essentially the same, only the names are changed.)

Include it

Add includes to the compatibility headers for your standard C++ library and this library, in that order. For example:

#include <stlport.h>
#include <Eigen30.h>

Carry on

The compatibility header has included <Eigen/Core> for you. Enjoy the functionality. You may now also include any of the other Eigen headers using the same way you'd include them in a standard desktop system: <Eigen/Geometry>, etc.

Let us know how it works!

If you find this useful, we would appreciate hearing from you. If you use this for academic work, we would also appreciate a copy of the publication and a citation: this helps make a case for our work. You may contact the main developer, Ryan Pavlik (Iowa State University), by email at [email protected] or [email protected], or his advisor, Dr. Judy M. Vance.

Paper materials and copies of publications may be mailed to:

Ryan Pavlik or Dr. Judy M. Vance

Virtual Reality Applications Center

1620 Howe Hall

Ames, Iowa 50011-2274

USA

Licenses

The compatibility header in the main directory may be used according to these terms:

Copyright Iowa State University 2012.

Distributed under the Boost Software License, Version 1.0.

(See copy at http://www.boost.org/LICENSE_1_0.txt)

Alternately, at your option, it may be used according to the license of the Eigen version that it accompanies.

The 3.0 branch of Eigen is licensed under the LGPL3+ or GPL2+ at your option. The developers' interpretation, with support from the FSF, can be found here: http://eigen.tuxfamily.org/index.php?title=Licensing_FAQ&oldid=1117 (Version 3.1.1 and newer have switch to the MPL v2 which better expresses the developers' intent.)

eigenarduino's People

Contributors

bjacob avatar cbecker avatar chhtz avatar dgomezferro avatar eamonnerbonne avatar ggael avatar hauke76 avatar hawk78 avatar jkm avatar jlblancoc avatar jlp avatar keir avatar lowdanie avatar marton78 avatar mborgerding avatar montel avatar moritz avatar neundorf avatar peterrom avatar phamelin avatar ptroja avatar rhysu avatar rpavlik avatar scotchi avatar senst avatar ssameer avatar timholy avatar trevor avatar uwolfer avatar yguel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eigenarduino's Issues

Cannot perform cross product on 3D vectors

I'm about to start a project that'll need eigen and this was the only library that even remotely worked, but I've found that the 3D cros product doesn't work. Here's an example sketch:

`/*
Name: Arduino_Device_Application.ino
Created: 12/7/2023 3:15:25 AM
Author: danie
*/

// the setup function runs once when you press reset or power the board

#include <EigenAVR.h>
#include <Eigen30.h>

void setup() {
Serial.begin(115200);
}

// the loop function runs over and over again until power down or reset
void loop() {
Serial.print("\n Length: ");
Serial.print(Eigen::Vector3f({ 1, 0, 0 }).cross(Eigen::Vector3f({ 0, 1, 0 }))(2));
delay(1000);
}`

which when I build, gives the following output

`Compiling 'Arduino_Device_Application' for 'Arduino Due (Programming Port) (arduino_due_x_dbg)'
Build Folder: "file:///C:/Users/******/AppData/Local/Temp/VMBuilds/Arduino_Device_Application/arduino_due_x_dbg/Release"

Arduino_Device_Application.cpp.o: In function loop

Error linking for board Arduino Due (Programming Port) (arduino_due_x_dbg)
Build failed for project 'Arduino_Device_Application'
Arduino_Device_Application.ino:19: undefined reference to Eigen Matrix<float, 3, 1, 0, 3, 1> Eigen MatrixBase<Eigen Matrix<float, 3, 1, 0, 3, 1> > cross3<Eigen Matrix<float, 3, 1, 0, 3, 1> >(Eigen MatrixBase<Eigen Matrix<float, 3, 1, 0, 3, 1> > const&) const

collect2.exe*: error: ld returned 1 exit status
`

Matrix multiplication with MatrixXd

Hello,

I am currently using this library with Arduino Mega 2560, but I am having an issue with matrix multiplication that is it is not returning any solution. For example consider example below:

#include <stlport.h>
#include <Eigen30.h>
#include <Eigen/LU>
#include <Eigen/Dense>

Eigen::MatrixXd b, c;

void setup() {
  Serial.begin(9600);
  Eigen::MatrixXd a;

  for(int i=0; i < 4; i++){
    for(int j=0; j < 4;j++){
      a(i,j) = 1;
    }
  }

  c = a * a;

}

void loop() {

}

This code returns a matrix like below:

1 1 1 1 
1 1 1 1
1 1 1 1 
1 1 1 1 

Or if I define the matrix as

Eigen::MatrixXd a(4,4);

And then initialise it to all one, the multiplication operation does not return anything. Am I using the library wrong or is there a problem with this library?

Can't compilate "fatal error: cstddef: No such file or directory"

Hi,

Literally can't compilate ALWAYS console shows this error

fatal error: cstddef: No such file or directory
#include <cstddef>

And the program program is literally

#include <Eigen30.h>
#include <EigenAVR.h>

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

}

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

}

In any program I get that error

I don't know what to do :(

Kind regards.

GitHub3

JacobiSVD Returns Incorrect Matrices

Hi,

I'm attempting to use the JacbiSVD algorithm on some 3x3 matrices and consistently get wildly incorrect SVD results (comparing to MATLAB). Both the singular values and the resulting U,V matrices are off by several orders of magnitude. Any ideas why this could be? I'm using stlport.h to compile for an Arduino Mega 2560.

Thanks!

PCA?

Is it just me or is PCA missing in this library? Is the idea to just use svd and perform further steps as needed (to get PCA)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.