-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make factors and others type-agnostic (precursor to SphericalJoints) #286
Changes from all commits
1f818e9
edad0fb
df8e41e
f056c46
6a7a9b1
0282ec0
d42ed7f
99d6d54
d62a362
29df3fb
01f4968
7ebbd06
bb8ce34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,8 @@ typedef gtdynamics::JointMeasurementFactor<gtdynamics::RevoluteJoint> RevoluteJo | |
|
||
#include <gtdynamics/factors/PoseFactor.h> | ||
class PoseFactor : gtsam::NonlinearFactor { | ||
PoseFactor(gtsam::Key wTp_key, gtsam::Key wTc_key, gtsam::Key q_key, | ||
const gtsam::noiseModel::Base* cost_model, | ||
const gtdynamics::Joint* joint); | ||
PoseFactor(const gtsam::noiseModel::Base *cost_model, | ||
const gtdynamics::Joint *joint, int k = 0); | ||
|
||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
|
@@ -93,21 +92,17 @@ class ContactPointFactor : gtsam::NoiseModelFactor { | |
|
||
#include <gtdynamics/factors/TwistFactor.h> | ||
class TwistFactor : gtsam::NonlinearFactor { | ||
TwistFactor(gtsam::Key twistP_key, gtsam::Key twistC_key, gtsam::Key q_key, | ||
gtsam::Key qVel_key, | ||
const gtsam::noiseModel::Base* cost_model, | ||
const gtdynamics::Joint* joint); | ||
TwistFactor(const gtsam::noiseModel::Base *cost_model, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal |
||
const gtdynamics::Joint *joint, int k = 0); | ||
|
||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
}; | ||
|
||
#include <gtdynamics/factors/TwistAccelFactor.h> | ||
class TwistAccelFactor : gtsam::NonlinearFactor { | ||
TwistAccelFactor(gtsam::Key twist_key_c, gtsam::Key twistAccel_key_p, gtsam::Key twistAccel_key_c, | ||
gtsam::Key q_key, gtsam::Key qVel_key, gtsam::Key qAccel_key, | ||
const gtsam::noiseModel::Base* cost_model, | ||
const gtdynamics::JointTyped* joint); | ||
TwistAccelFactor(const gtsam::noiseModel::Base *cost_model, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal |
||
const gtdynamics::Joint *joint, int k = 0); | ||
|
||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
|
@@ -116,7 +111,7 @@ class TwistAccelFactor : gtsam::NonlinearFactor { | |
#include <gtdynamics/factors/TorqueFactor.h> | ||
class TorqueFactor : gtsam::NonlinearFactor { | ||
TorqueFactor(const gtsam::noiseModel::Base *cost_model, | ||
const gtdynamics::JointTyped *joint, size_t k=0); | ||
const gtdynamics::Joint *joint, size_t k = 0); | ||
|
||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
|
@@ -145,15 +140,16 @@ class WrenchFactor : gtsam::NonlinearFactor { | |
#include <gtdynamics/factors/WrenchEquivalenceFactor.h> | ||
class WrenchEquivalenceFactor : gtsam::NonlinearFactor{ | ||
WrenchEquivalenceFactor(const gtsam::noiseModel::Base *cost_model, | ||
gtdynamics::JointTyped *joint, size_t k = 0); | ||
gtdynamics::Joint *joint, size_t k = 0); | ||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
}; | ||
|
||
#include <gtdynamics/factors/WrenchPlanarFactor.h> | ||
class WrenchPlanarFactor : gtsam::NonlinearFactor { | ||
WrenchPlanarFactor(const gtsam::noiseModel::Base *cost_model, | ||
Vector planar_axis, gtdynamics::JointTyped *joint, size_t k=0); | ||
Vector planar_axis, gtdynamics::Joint *joint, | ||
size_t k = 0); | ||
void print(const string &s="", | ||
const gtsam::KeyFormatter &keyFormatter=gtdynamics::GTDKeyFormatter); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* -------------------------------------------------------------------------- */ | ||
|
||
/** | ||
* @file JointLimitFactor.h | ||
* @file JointLimitDoubleFactor.h | ||
* @brief apply joint limit | ||
* @author: Frank Dellaert, Mandy Xie, Stephanie McCormick, Varun Agrawal | ||
*/ | ||
|
@@ -24,21 +24,19 @@ | |
#include <string> | ||
#include <vector> | ||
|
||
#include "gtdynamics/universal_robot/JointTyped.h" | ||
#include "gtdynamics/universal_robot/Joint.h" | ||
|
||
namespace gtdynamics { | ||
|
||
/** | ||
* JointLimitFactor is a class which enforces joint angle, velocity, | ||
* acceleration and torque value to be within limi | ||
* JointLimitDoubleFactor is a class which enforces joint angle, velocity, | ||
* acceleration and torque value to be within limits | ||
*/ | ||
class JointLimitFactor | ||
: public gtsam::NoiseModelFactor1<JointTyped::JointCoordinateType> { | ||
class JointLimitDoubleFactor : public gtsam::NoiseModelFactor1<double> { | ||
private: | ||
using JointCoordinateType = JointTyped::JointCoordinateType; | ||
using This = JointLimitFactor; | ||
using Base = gtsam::NoiseModelFactor1<JointCoordinateType>; | ||
JointCoordinateType low_, high_; | ||
using This = JointLimitDoubleFactor; | ||
using Base = gtsam::NoiseModelFactor1<double>; | ||
double low_, high_; | ||
|
||
public: | ||
/** | ||
|
@@ -49,16 +47,16 @@ class JointLimitFactor | |
* @param upper_limit joint upper limit | ||
* @param limit_threshold joint limit threshold | ||
*/ | ||
JointLimitFactor(gtsam::Key q_key, | ||
const gtsam::noiseModel::Base::shared_ptr &cost_model, | ||
JointCoordinateType lower_limit, | ||
JointCoordinateType upper_limit, | ||
JointCoordinateType limit_threshold) | ||
JointLimitDoubleFactor(gtsam::Key q_key, | ||
const gtsam::noiseModel::Base::shared_ptr &cost_model, | ||
double lower_limit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do this and not keep it generic via JointCoordinateType? |
||
double upper_limit, | ||
double limit_threshold) | ||
: Base(cost_model, q_key), | ||
low_(lower_limit + limit_threshold), | ||
high_(upper_limit - limit_threshold) {} | ||
|
||
virtual ~JointLimitFactor() {} | ||
virtual ~JointLimitDoubleFactor() {} | ||
|
||
public: | ||
/** | ||
|
@@ -72,7 +70,7 @@ class JointLimitFactor | |
* @param q joint value | ||
*/ | ||
gtsam::Vector evaluateError( | ||
const JointCoordinateType &q, | ||
const double &q, | ||
boost::optional<gtsam::Matrix &> H_q = boost::none) const override { | ||
if (q < low_) { | ||
if (H_q) *H_q = -gtsam::I_1x1; | ||
|
@@ -96,7 +94,7 @@ class JointLimitFactor | |
void print(const std::string &s = "", | ||
const gtsam::KeyFormatter &keyFormatter = | ||
gtsam::DefaultKeyFormatter) const override { | ||
std::cout << s << "JointLimitFactor" << std::endl; | ||
std::cout << s << "JointLimitDoubleFactor" << std::endl; | ||
Base::print("", keyFormatter); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just add this constructor in addition? No reason to remove the previous constructor.