Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ik panda #340

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
small update
  • Loading branch information
Joobz committed Jul 8, 2022
commit 54c72df3420ffdc7fb4ec8b0cea9c4d45e8a8057
3 changes: 2 additions & 1 deletion gtdynamics/kinematics/Kinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class Kinematics : public Optimizer {
/**
* @fn Create a pose prior for a given link for each given pose.
* @param context Slice or Interval instance.
* @param pose_goals goals for poses
* @param pose_goals an object of PoseGoals: map of time k to desired pose at
* that time, which will be used as mean of the prior
* @returns graph with pose goal factors.
*/
template <class CONTEXT>
Expand Down
4 changes: 2 additions & 2 deletions gtdynamics/kinematics/KinematicsSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ NonlinearFactorGraph Kinematics::jointAngleLimits<Slice>(
NonlinearFactorGraph graph;
for (auto&& joint : robot.joints()) {
graph.add(JointLimitFactor(
JointAngleKey(joint->id(), slice.k), gtsam::noiseModel::Isotropic::Sigma(1, 0.00001),
JointAngleKey(joint->id(), slice.k), gtsam::noiseModel::Isotropic::Sigma(1, 0.001),
joint->parameters().scalar_limits.value_lower_limit,
joint->parameters().scalar_limits.value_upper_limit,
0.04));
0.04));//joint->parameters().scalar_limits.value_limit_threshold));
}
return graph;
}
Expand Down
2 changes: 1 addition & 1 deletion gtdynamics/pandarobot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# add cablerobot subfolders to gtdynamics' SOURCE_SUBDIRS list
# add pandarobot subfolders to gtdynamics' SOURCE_SUBDIRS list
list(APPEND SOURCE_SUBDIRS pandarobot/ikfast pandarobot/gpmp)
set(SOURCE_SUBDIRS ${SOURCE_SUBDIRS} PARENT_SCOPE)

Expand Down
87 changes: 87 additions & 0 deletions gtdynamics/pandarobot/tests/testGaussianProcessPrior.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

/**
* @file testGaussianProcessPrior.cpp
* @author Wanli Qian, Toni Jubes, Frank Dellaert
**/

#include <CppUnitLite/TestHarness.h>

#include <gtsam/base/Matrix.h>
#include <gtsam/base/Testable.h>
#include <gtsam/base/numericalDerivative.h>
#include <gtsam/inference/Symbol.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
#include <gtsam/nonlinear/GaussNewtonOptimizer.h>
#include <gtsam/nonlinear/Values.h>
#include <gtsam/slam/PriorFactor.h>


#include <gtdynamics/pandarobot/gpmp/GaussianProcessPrior.h>

#include <iostream>

using namespace std;
using namespace gtsam;
using namespace gtdynamics;


/* ************************************************************************** */

TEST(GaussianProcessPrior, Optimization) {

/**
* A simple graph:
*
* p1 p2
* | |
* x1 x2
* \ /
* gp
* / \
* v1 v2
*
* p1 and p2 are pose prior factor to fix the poses, gp is the GP factor
* that get correct velocity of v1 and v2
*/

noiseModel::Isotropic::shared_ptr model_prior =
noiseModel::Isotropic::Sigma(3, 0.001);

//noiseModel::Gaussian::shared_ptr Qc_model = noiseModel::Gaussian::Covariance(Qc);

double theta1 = 0;
double theta1d = 5;
double theta2 = 4;
double theta2d = 6;

double EXPECTEDfi = 7;
gtsam::Vector2 expected_error;
expected_error << 1 , -1;

double key1 = 0;
double key2 = 1;
double key3 = 2;
double key4 = 3;
double delta_t = 1;
double Qc = 2;

auto factor = GaussianProcessPrior(key1,key2,key3,key4,delta_t, Qc);
gtsam::Values v;
v.insert(key1,theta1);
v.insert(key2,theta1d);
v.insert(key3,theta2);
v.insert(key4,theta2d);
gtsam::Vector2 actual_error = factor.evaluateError(theta1,theta1d,theta2,theta2d);
double ACTUALfi = factor.error(v);

EXPECT(assert_equal(expected_error,actual_error,1e-06))
EXPECT_DOUBLES_EQUAL(EXPECTEDfi,ACTUALfi,1e-06)

}

/* ************************************************************************** */
/* main function */
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}