Martin  Felis avatar Martin Felis committed 4b9416a

API: CS::constraint_force and CS::constraint_impulse hold now forces/impulses that are acting on the constrained body instead the other way round

Comments (0)

Files changed (3)

doc/api_changes.txt

 - removed Model::Init():
   All initialization is now done in the default constructor in Model(). To
 	be compatible with the new API simply remove any calls to Model::Init().
+- ConstraintSet::constraint_force and ConstraintSet::constraint_impulse are
+	now the forces or impulses that are acting on the constrained body by the
+	constraint.

include/rbdl/Contacts.h

  * later used when calling one of the contact functions, such as
  * ForwardDynamicsContacts() or ForwardDynamicsContactsLagrangian().
  *
- * The values in the vectors ConstraintSet::constraint_force and
- * ConstraintSet::constraint_impulse contain the computed force or
- * impulse values for each constraint when returning from one of the
- * contact functions.
+ * The values in the vectors ConstraintSet::constraint_force are for each
+ * constraint the force that is excerted on the body by the constraint.
+ * Similarly ConstraintSet::constraint_impulse holds for each constraint
+ * the impulse due to a collision that is excerted by the constraint on the
+ * body.
  *
  * @{
  */
 	/** Enforced accelerations of the contact points along the contact
 	 * normal. */
 	Math::VectorNd constraint_acceleration;
-	/** Actual constraint forces along the contact normals. */
+	/** Actual constraint forces along the contact normals that is excerted on
+	 * the body. */
 	Math::VectorNd constraint_force;
-	/** Actual constraint impulses along the contact normals. */
+	/** Actual constraint impulses along the contact normals that is acting
+	 * on the body. */
 	Math::VectorNd constraint_impulse;
 
 	// Variables used by the Lagrangian methods
  \left(
    \begin{array}{c}
 	   \dot{q}^{+} \\
-		 \Lambda
+		 -\Lambda
    \end{array}
  \right)
  =
 
 	// Copy back contact forces
 	for (i = 0; i < CS.size(); i++) {
-		CS.constraint_force[i] = CS.x[model.dof_count + i];
+		CS.constraint_force[i] = -CS.x[model.dof_count + i];
 	}
 }
 
 
 	// Copy back contact impulses
 	for (i = 0; i < CS.size(); i++) {
-		CS.constraint_impulse[i] = CS.x[model.dof_count + i];
+		CS.constraint_impulse[i] = -CS.x[model.dof_count + i];
 	}
 }
 
 			UpdateKinematicsCustom (model, NULL, NULL, &CS.QDDot_0);
 			CS.point_accel_0[ci] = CalcPointAcceleration (model, Q, QDot, CS.QDDot_0, body_id, point, false);
 
-			CS.a[ci] = acceleration - normal.dot(CS.point_accel_0[ci]);
+			CS.a[ci] = - acceleration + normal.dot(CS.point_accel_0[ci]);
 		}
 		LOG << "point_accel_0 = " << CS.point_accel_0[ci].transpose();
 	}
 	for (ci = 0; ci < CS.size(); ci++) {
 		unsigned int body_id = CS.body[ci];
 
-		CS.f_ext_constraints[body_id] += CS.f_t[ci] * CS.constraint_force[ci]; 
+		CS.f_ext_constraints[body_id] -= CS.f_t[ci] * CS.constraint_force[ci]; 
 		LOG << "f_ext[" << body_id << "] = " << CS.f_ext_constraints[body_id].transpose() << std::endl;
 	}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.