vancegroup / EigenArduino

Port of the Eigen matrix-math library to the Arduino (and similar AVR platforms)
GNU General Public License v3.0
75 stars 10 forks source link

Cannot perform cross product on 3D vectors #6

Open dbecker59 opened 10 months ago

dbecker59 commented 10 months ago

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

include

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 `

rpavlik commented 10 months ago

hmm. Weird. I totally haven't touched this in years, but I was pretty sure I used cross products back when I did use it.

You should be able to see the diffs I made to the upstream code, maybe try applying those to a more recent version of eigen? It's on gitlab now, not mercurial/bitbucket, so it's easier to work with.

There is also libc++ out now, which is a lot easier to get going on small systems and a lot easier to work with in general.