Ich versuche eine Software zu schreiben, um die Vorwärts- und Inverse-Kinematik eines Roboterarms mit Eigen-Matrix-Bibliothek zu berechnen. Ich habe Probleme, eine kommaseparierte dynamische Matrix zu initialisieren. Im Lauf in EXC_BAD_ACCESS LLDB Debugger Bug. Ich bin neu zu LLDB Debugger und nicht ganz sicher Hot-Debuggen mit ihm.Eigen: Komma initialisierende dynamische Matrix
Das ist mein main.cpp-Code und meine Klassendefinition und Implementierung der Klasse RobotArm scheint in Ordnung zu sein.
#include <iostream>
#include <Eigen/Dense>
#include "RobotArm.h"
using namespace Eigen;
using namespace std;
int main(int argc, const char * argv[])
{
RobotArm testArm;
MatrixXd E(5,4);
E << 0, 0, 0, 10,
90, 30, 5, 0,
0, 30, 25, 0,
0, 30, 25, 0,
0, 30, 0, 0;
Vector3d POS = testArm.forwardKinematics(E);
cout << "Position vector [X Y Z]" << POS << endl;
return 0;
}
Das ist mein RobotArm.h
#ifndef ____RobotArm__
#define ____RobotArm__
#include <stdio.h>
#include <Eigen/Dense>
#include <math.h>
using namespace std;
using namespace Eigen;
class RobotArm
{
public:
//Constructor
RobotArm();
Vector3d forwardKinematics(MatrixXd DH);
VectorXd inversekinematics();
void homeArm();
private:
double xPos, yPos, zPos;
MatrixX4d T;
MatrixX4d H;
Vector3d pos;
MatrixX4d substitute(double alpha, double theta, double a, double d);
};
#endif /* defined(____RobotArm__) */
Das ist mein RobotArm.cpp
#include "RobotArm.h"
#include <stdio.h>
#include <Eigen/Dense>
#include <cmath>
#include <iostream>
using namespace std;
using namespace Eigen;
RobotArm::RobotArm()
{
cout << "Successfully created RobotArm object" << endl;
}
Vector3d RobotArm::forwardKinematics(MatrixXd DH)
{
MatrixX4d H;
//H = MatrixX4d::Constant(4,4,1);
H << 1,1,1,1,
1,1,1,1,
1,1,1,1,
1,1,1,1;
//Update current link parameters
for (int i = 0; i < 6; i++)
{
H *= substitute(DH(i,0), DH(i,1), DH(i,2), DH(i,3));
}
pos(0,0) = H(0,3);
pos(1,0) = H(1,3);
pos(1,0) = H(2,3);
return pos;
}
MatrixX4d RobotArm::substitute(double alpha, double theta, double a, double d)
{
T << cos(theta), -sin(theta), 0, a,
(sin(theta)*cos(alpha)), (cos(theta)*cos(alpha)), -sin(alpha), (-sin(alpha)*d),
(sin(theta)*sin(alpha)),(cos(theta)*sin(alpha)), cos(alpha), (cos(alpha)*d),
0, 0, 0, 1;
return T;
}
Der Fehler, wenn sie auf main.cpp
Matrix E initialisieren versuchen, das Auftreten scheintHinweis: Die Software befindet sich noch in der Entwicklung. Was ich gepostet habe, ist nur zum Testen meiner Klasse. Bitte beachten Sie, wie Sie den LLDB-Debugger erlernen können. Vielen Dank.
Danke @Avi Ginsburg :) Ich fürchte, dass ich eine 5x4-Matrix als Argument müssen RobotArm :: forward kinematics(). Also muss ich MatrixXd anstelle von Matrix4d verwenden. Irgendwelche Gedanken? – Vino
Danke für die Antwort :) Aber ich habe immer noch Probleme - "Assertion gescheitert"; Ich denke, es wird ein guter Ausgangspunkt sein, um den LLDB-Debugger zu lernen, um meinen Code zu kompilieren :) Danke für die Hilfe – Vino