Permalink
Browse files

Add Joint assignment operator.

  • Loading branch information...
1 parent 9882afe commit f7a568d64fe2b57280910595ff865d21f82be009 Antonio El Khoury committed Oct 15, 2012
Showing with 43 additions and 0 deletions.
  1. +3 −0 include/ard/rbdl/model/joint.hh
  2. +40 −0 src/joint.cc
@@ -55,6 +55,9 @@ namespace ard
/// \brief Copy Constructor.
Joint (const Joint& joint);
+ /// \brief Assignment operator.
+ Joint operator= (const Joint& joint);
+
/// \brief Destructor
virtual ~Joint ();
View
@@ -147,6 +147,46 @@ namespace ard
joint.linkedBody (linkedBody_);
}
+
+ Joint Joint::operator= (const Joint& joint)
@thomas-moulard

thomas-moulard Oct 16, 2012

You forgot to check for self-assignment here!

+ {
+ name_ = joint.getName ();
+
+ joint.parentJoint (parentJoint_);
+
+ for (unsigned i = 0; i < joint.countChildJoints (); ++i)
+ addChildJoint (*(joint.childJoint (i)));
+
+ rbdlJoint_ = joint.rbdlJoint ();
+ rankInConfiguration_ = joint.rankInConfiguration ();
+ initialPosition_ = joint.initialPosition ();
+ currentTransformation_ = joint.currentTransformation ();
+ velocity_ = joint.jointVelocity();
+ acceleration_ = joint.jointAcceleration ();
+ numberDof_ = joint.numberDof ();
+
+ lowerBound_.resize (joint.numberDof ());
+ upperBound_.resize (joint.numberDof ());
+ lowerVelocityBound_.resize (joint.numberDof ());
+ upperVelocityBound_.resize (joint.numberDof ());
+ lowerTorqueBound_.resize (joint.numberDof ());
+ upperTorqueBound_.resize (joint.numberDof ());
+ for (unsigned i = 0; i < joint.numberDof (); ++i)
+ {
+ lowerBound_[i] = joint.lowerBound (i);
+ upperBound_[i] = joint.upperBound (i);
+ lowerVelocityBound_[i] = joint.lowerVelocityBound (i);
+ upperVelocityBound_[i] = joint.upperVelocityBound (i);
+ lowerTorqueBound_[i] = joint.lowerTorqueBound (i);
+ upperTorqueBound_[i] = joint.upperTorqueBound (i);
+ }
+
+ jacobian_ = joint.jacobianJointWrtConfig ();
+
+ joint.linkedBody (linkedBody_);
+
+ return *this;
+ }
Joint::~Joint ()
{

0 comments on commit f7a568d

Please sign in to comment.