From 8f2e09e91733cb73bc93d4f9d96d87e5ba4352cc Mon Sep 17 00:00:00 2001
From: themarex <themarex@042f3d55-54a8-47e9-b7fb-15903f145c44>
Date: Thu, 2 Oct 2014 15:31:14 +0000
Subject: [PATCH] Sync interface of BulletRobot with DynamicsRobot.

In general shared_ptr should be passed as const shared_ptr<>& as
outlined here:
http://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/

git-svn-id: http://svn.code.sf.net/p/simox/code/trunk@704 042f3d55-54a8-47e9-b7fb-15903f145c44
---
 .../BulletEngine/BulletRobot.cpp              | 10 ++++-----
 .../DynamicsEngine/BulletEngine/BulletRobot.h | 10 ++++-----
 SimDynamics/DynamicsEngine/DynamicsRobot.cpp  | 22 ++++++++++++++++++-
 SimDynamics/DynamicsEngine/DynamicsRobot.h    |  8 ++++++-
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.cpp b/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.cpp
index 36d2d5f39..00c18c8b3 100644
--- a/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.cpp
+++ b/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.cpp
@@ -1147,7 +1147,7 @@ Eigen::Vector3f BulletRobot::getJointForces(RobotNodePtr rn)
     return result;
 }
 
-Eigen::Matrix4f BulletRobot::getComGlobal( VirtualRobot::RobotNodePtr rn )
+Eigen::Matrix4f BulletRobot::getComGlobal(const VirtualRobot::RobotNodePtr& rn )
 {
     MutexLockPtr lock = getScopedLock();
     BulletObjectPtr bo = boost::dynamic_pointer_cast<BulletObject>(getDynamicsRobotNode(rn));
@@ -1159,7 +1159,7 @@ Eigen::Matrix4f BulletRobot::getComGlobal( VirtualRobot::RobotNodePtr rn )
     return bo->getComGlobal();
 }
 
-Eigen::Vector3f BulletRobot::getComGlobal( VirtualRobot::RobotNodeSetPtr set)
+Eigen::Vector3f BulletRobot::getComGlobal(const VirtualRobot::RobotNodeSetPtr& set)
 {
     MutexLockPtr lock = getScopedLock();
 	Eigen::Vector3f com = Eigen::Vector3f::Zero();
@@ -1177,7 +1177,7 @@ Eigen::Vector3f BulletRobot::getComGlobal( VirtualRobot::RobotNodeSetPtr set)
 	return com;
 }
 
-Eigen::Vector3f BulletRobot::getComVelocityGlobal( VirtualRobot::RobotNodeSetPtr set)
+Eigen::Vector3f BulletRobot::getComVelocityGlobal(const VirtualRobot::RobotNodeSetPtr& set)
 {
     MutexLockPtr lock = getScopedLock();
 	Eigen::Vector3f com = Eigen::Vector3f::Zero();
@@ -1210,7 +1210,7 @@ Eigen::Vector3f BulletRobot::getComVelocityGlobal( VirtualRobot::RobotNodeSetPtr
 	return com;
 }
 
-Eigen::Vector3f BulletRobot::getLinearMomentumGlobal( VirtualRobot::RobotNodeSetPtr set)
+Eigen::Vector3f BulletRobot::getLinearMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set)
 {
     MutexLockPtr lock = getScopedLock();
 	Eigen::Vector3f linMomentum = Eigen::Vector3f::Zero();
@@ -1226,7 +1226,7 @@ Eigen::Vector3f BulletRobot::getLinearMomentumGlobal( VirtualRobot::RobotNodeSet
 	return linMomentum;
 }
 
-Eigen::Vector3f BulletRobot::getAngularMomentumGlobal( VirtualRobot::RobotNodeSetPtr set)
+Eigen::Vector3f BulletRobot::getAngularMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set)
 {
     MutexLockPtr lock = getScopedLock();
 	Eigen::Vector3f angMomentum = Eigen::Vector3f::Zero();
diff --git a/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.h b/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.h
index 0d69bfb6d..bb20b3493 100644
--- a/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.h
+++ b/SimDynamics/DynamicsEngine/BulletEngine/BulletRobot.h
@@ -148,19 +148,19 @@ public:
     /*!
         Returns the CoM pose, which is reported by bullet
     */
-    virtual Eigen::Matrix4f getComGlobal(VirtualRobot::RobotNodePtr rn);
-	Eigen::Vector3f getComGlobal(VirtualRobot::RobotNodeSetPtr set);
-	Eigen::Vector3f getComVelocityGlobal(VirtualRobot::RobotNodeSetPtr set);
+    virtual Eigen::Matrix4f getComGlobal(const VirtualRobot::RobotNodePtr& rn);
+    virtual Eigen::Vector3f getComGlobal(const VirtualRobot::RobotNodeSetPtr& set);
+    virtual Eigen::Vector3f getComVelocityGlobal(const VirtualRobot::RobotNodeSetPtr& set);
 
     /*!
      * Returns the linear momentum in Ns for the bodies in the nodeset.
      */
-	Eigen::Vector3f getLinearMomentumGlobal(VirtualRobot::RobotNodeSetPtr set);
+    virtual Eigen::Vector3f getLinearMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set);
 
     /*!
      * Returns the angular momentum in Nms for the bodies in the nodeset
      */
-	Eigen::Vector3f getAngularMomentumGlobal(VirtualRobot::RobotNodeSetPtr set);
+    virtual Eigen::Vector3f getAngularMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set);
 
 	// experimental...
 	virtual void ensureKinematicConstraints();
diff --git a/SimDynamics/DynamicsEngine/DynamicsRobot.cpp b/SimDynamics/DynamicsEngine/DynamicsRobot.cpp
index 45e0a7694..b969c67da 100644
--- a/SimDynamics/DynamicsEngine/DynamicsRobot.cpp
+++ b/SimDynamics/DynamicsEngine/DynamicsRobot.cpp
@@ -286,7 +286,7 @@ double DynamicsRobot::getJointTargetSpeed( VirtualRobot::RobotNodePtr rn )
     return 0.0f;
 }
 
-Eigen::Matrix4f DynamicsRobot::getComGlobal( VirtualRobot::RobotNodePtr rn )
+Eigen::Matrix4f DynamicsRobot::getComGlobal(const VirtualRobot::RobotNodePtr& rn )
 {
     MutexLockPtr lock = getScopedLock();
     Eigen::Matrix4f com = Eigen::Matrix4f::Identity();
@@ -295,6 +295,26 @@ Eigen::Matrix4f DynamicsRobot::getComGlobal( VirtualRobot::RobotNodePtr rn )
     return com;
 }
 
+Eigen::Vector3f DynamicsRobot::getComGlobal(const VirtualRobot::RobotNodeSetPtr& bodies)
+{
+    return Eigen::Vector3f::Zero();
+}
+
+Eigen::Vector3f DynamicsRobot::getComVelocityGlobal(const VirtualRobot::RobotNodeSetPtr& bodies)
+{
+    return Eigen::Vector3f::Zero();
+}
+
+Eigen::Vector3f DynamicsRobot::getLinearMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set)
+{
+    return Eigen::Vector3f::Zero();
+}
+
+Eigen::Vector3f DynamicsRobot::getAngularMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set)
+{
+    return Eigen::Vector3f::Zero();
+}
+
 void DynamicsRobot::setGlobalPose(Eigen::Matrix4f &gp)
 {
     MutexLockPtr lock = getScopedLock();
diff --git a/SimDynamics/DynamicsEngine/DynamicsRobot.h b/SimDynamics/DynamicsEngine/DynamicsRobot.h
index 96ec5fe26..cc8d8ab41 100644
--- a/SimDynamics/DynamicsEngine/DynamicsRobot.h
+++ b/SimDynamics/DynamicsEngine/DynamicsRobot.h
@@ -97,7 +97,13 @@ public:
     virtual double getJointSpeed(VirtualRobot::RobotNodePtr rn);
     virtual double getJointTargetSpeed(VirtualRobot::RobotNodePtr rn);
 
-    virtual Eigen::Matrix4f getComGlobal(VirtualRobot::RobotNodePtr rn);
+    virtual Eigen::Matrix4f getComGlobal(const VirtualRobot::RobotNodePtr& rn);
+
+    virtual Eigen::Vector3f getComGlobal(const VirtualRobot::RobotNodeSetPtr& bodies);
+    virtual Eigen::Vector3f getComVelocityGlobal(const VirtualRobot::RobotNodeSetPtr& bodies);
+
+    virtual Eigen::Vector3f getLinearMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set);
+    virtual Eigen::Vector3f getAngularMomentumGlobal(const VirtualRobot::RobotNodeSetPtr& set);
 
     virtual void setGlobalPose(Eigen::Matrix4f &gp);
 
-- 
GitLab