diff --git a/free_gait_action_loader/src/free_gait_action_loader/action_handling.py b/free_gait_action_loader/src/free_gait_action_loader/action_handling.py
index 331dfeb..12ffd6d 100644
--- a/free_gait_action_loader/src/free_gait_action_loader/action_handling.py
+++ b/free_gait_action_loader/src/free_gait_action_loader/action_handling.py
@@ -69,6 +69,7 @@ def _initialize(self, package_path, parameters):
self.name = parameters['name']
if 'file' in parameters:
self.file = abspath(join(package_path, parameters['file']))
+ rospy.loginfo(self.file)
if 'type' in parameters:
self.type = ActionType.from_text(parameters['type'])
if 'description' in parameters:
@@ -95,11 +96,13 @@ def update(self):
self.actions = []
rospack = rospkg.RosPack()
packages = rospack.get_depends_on(self.name, implicit=False)
- rospy.loginfo(packages)
+ rospy.loginfo(rospack)
for package in packages:
rospy.loginfo(package)
manifest = rospack.get_manifest(package)
+ rospy.loginfo(manifest.exports)
file_path = manifest.get_export(self.name, 'actions')
+ rospy.loginfo(file_path)
if not file_path:
continue
elif len(file_path) != 1:
@@ -114,7 +117,9 @@ def update(self):
package_path = rospack.get_path(package)
parameters = load_file(file_path)
+ # rospy.loginfo(parameters[0][0]['actions'])
for action_parameters in parameters[0][0]['actions']:
+ rospy.loginfo(action_parameters)
entry = ActionEntry(package_path, action_parameters['action'])
self.actions.append(entry)
diff --git a/free_gait_action_loader/src/free_gait_action_loader/action_handling.pyc b/free_gait_action_loader/src/free_gait_action_loader/action_handling.pyc
index f5a41c4..3f42cff 100644
Binary files a/free_gait_action_loader/src/free_gait_action_loader/action_handling.pyc and b/free_gait_action_loader/src/free_gait_action_loader/action_handling.pyc differ
diff --git a/free_gait_core/CMakeLists.txt b/free_gait_core/CMakeLists.txt
index 44fe48b..4948cac 100644
--- a/free_gait_core/CMakeLists.txt
+++ b/free_gait_core/CMakeLists.txt
@@ -94,6 +94,7 @@ add_library(${PROJECT_NAME}
src/executor/StateBatch.cpp
src/executor/StateBatchComputer.cpp
src/executor/AdapterBase.cpp
+# src/executor/AdapterDummy.cpp
src/pose_optimization/PoseOptimizationBase.cpp
src/pose_optimization/PoseConstraintsChecker.cpp
src/pose_optimization/PoseOptimizationGeometric.cpp
diff --git a/free_gait_core/include/free_gait_core/executor/executor.hpp.gch b/free_gait_core/include/free_gait_core/executor/executor.hpp.gch
new file mode 100644
index 0000000..325db09
Binary files /dev/null and b/free_gait_core/include/free_gait_core/executor/executor.hpp.gch differ
diff --git a/free_gait_core/package.xml b/free_gait_core/package.xml
index 6c82edd..61da670 100644
--- a/free_gait_core/package.xml
+++ b/free_gait_core/package.xml
@@ -19,4 +19,9 @@
robot_utils
std_utils
message_logger
+
+
+
diff --git a/free_gait_core/plugin_description.xml b/free_gait_core/plugin_description.xml
new file mode 100644
index 0000000..d8c73bd
--- /dev/null
+++ b/free_gait_core/plugin_description.xml
@@ -0,0 +1,7 @@
+
+
+ Display to preview Free Gait actions.
+
+
diff --git a/free_gait_core/src/executor/BatchExecutor.cpp b/free_gait_core/src/executor/BatchExecutor.cpp
index 63b771b..49c5941 100644
--- a/free_gait_core/src/executor/BatchExecutor.cpp
+++ b/free_gait_core/src/executor/BatchExecutor.cpp
@@ -73,7 +73,9 @@ void BatchExecutor::processInThread()
while (!executor_.getQueue().empty() && !requestForCancelling_) {
executor_.advance(timeStep_);
time += timeStep_;
+// std::cout<<"Updated Joint Positions: "<& limbs, const std::vector
+
+namespace free_gait {
+
+class AdapterDummy : public AdapterBase
+{
+ public:
+ AdapterDummy();
+ virtual ~AdapterDummy();
+
+ //! Copying data from real robot to free gait state.
+ virtual bool resetExtrasWithRobot(const StepQueue& stepQueue, State& state);
+ virtual bool updateExtrasBefore(const StepQueue& stepQueue, State& state);
+ virtual bool updateExtrasAfter(const StepQueue& stepQueue, State& state);
+
+ //! State independent functions.
+ virtual const std::string& getWorldFrameId() const;
+ virtual const std::string& getBaseFrameId() const;
+ virtual const std::vector& getLimbs() const;
+ virtual const std::vector& getBranches() const;
+ virtual LimbEnum getLimbEnumFromLimbString(const std::string& limb) const;
+ virtual std::string getLimbStringFromLimbEnum(const LimbEnum& limb) const;
+ virtual std::string getBaseString() const;
+ virtual JointNodeEnum getJointNodeEnumFromJointNodeString(const std::string& jointNode) const;
+ virtual std::string getJointNodeStringFromJointNodeEnum(const JointNodeEnum& jointNode) const;
+ virtual bool getLimbJointPositionsFromPositionBaseToFootInBaseFrame(
+ const Position& positionBaseToFootInBaseFrame, const LimbEnum& limb,
+ JointPositionsLeg& jointPositions) const;
+ virtual Position getPositionBaseToFootInBaseFrame(const LimbEnum& limb,
+ const JointPositionsLeg& jointPositions) const;
+ virtual Position getPositionBaseToHipInBaseFrame(const LimbEnum& limb) const;
+
+ //! Reading state of real robot.
+ virtual bool isExecutionOk() const;
+ virtual bool isLegGrounded(const LimbEnum& limb) const;
+ virtual JointPositionsLeg getJointPositionsForLimb(const LimbEnum& limb) const;
+ virtual JointPositions getAllJointPositions() const;
+ virtual JointVelocitiesLeg getJointVelocitiesForLimb(const LimbEnum& limb) const;
+ virtual JointVelocities getAllJointVelocities() const;
+ virtual JointAccelerationsLeg getJointAccelerationsForLimb(const LimbEnum& limb) const;
+ virtual JointAccelerations getAllJointAccelerations() const;
+ virtual JointEffortsLeg getJointEffortsForLimb(const LimbEnum& limb) const;
+ virtual JointEfforts getAllJointEfforts() const;
+ virtual Position getPositionWorldToBaseInWorldFrame() const;
+ virtual RotationQuaternion getOrientationBaseToWorld() const;
+ virtual LinearVelocity getLinearVelocityBaseInWorldFrame() const;
+ virtual LocalAngularVelocity getAngularVelocityBaseInBaseFrame() const;
+ virtual LinearAcceleration getLinearAccelerationBaseInWorldFrame() const;
+ virtual AngularAcceleration getAngularAccelerationBaseInBaseFrame() const;
+ virtual Position getPositionBaseToFootInBaseFrame(const LimbEnum& limb) const;
+ virtual Position getPositionWorldToFootInWorldFrame(const LimbEnum& limb) const;
+ virtual Position getCenterOfMassInWorldFrame() const;
+
+ /*!
+ * Transform is frameId to world => C_IF.
+ * @param frameId
+ * @return
+ */
+ virtual void getAvailableFrameTransforms(std::vector& frameTransforms) const;
+ virtual Pose getFrameTransform(const std::string& frameId) const;
+ virtual ControlSetup getControlSetup(const BranchEnum& branch) const;
+ virtual ControlSetup getControlSetup(const LimbEnum& limb) const;
+
+ //! Depending on state of real robot.
+ virtual JointVelocitiesLeg getJointVelocitiesFromEndEffectorLinearVelocityInWorldFrame(
+ const LimbEnum& limb, const LinearVelocity& endEffectorLinearVelocityInWorldFrame) const;
+ virtual LinearVelocity getEndEffectorLinearVelocityFromJointVelocities(const LimbEnum& limb,
+ const JointVelocitiesLeg& jointVelocities,
+ const std::string& frameId) const;
+ virtual JointAccelerationsLeg getJointAccelerationsFromEndEffectorLinearAccelerationInWorldFrame(
+ const LimbEnum& limb, const LinearAcceleration& endEffectorLinearAccelerationInWorldFrame) const;
+
+ //! Hook to write data to internal robot representation from state.
+// virtual bool setInternalDataFromState(const State& state) const;
+ virtual bool setInternalDataFromState(const State& state, bool updateContacts = true, bool updatePosition = true,
+ bool updateVelocity = true, bool updateAcceleration = false) const;
+
+ virtual void createCopyOfState() const;
+ virtual void resetToCopyOfState() const;
+
+ const State& getState() const;
+
+ private:
+ std::unique_ptr state_;
+ std::vector limbs_;
+ std::vector branches_;
+ const std::string worldFrameId_;
+ const std::string baseFrameId_;
+ Stance footholdsInSupport_;
+};
+
+} /* namespace free_gait */
diff --git a/free_gait_ros/include/free_gait_ros/AdapterRos.hpp b/free_gait_ros/include/free_gait_ros/AdapterRos.hpp
index 5a62b45..7663f30 100644
--- a/free_gait_ros/include/free_gait_ros/AdapterRos.hpp
+++ b/free_gait_ros/include/free_gait_ros/AdapterRos.hpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include "pluginlib_tutorials/polygon_base.h"
// STD
#include
@@ -39,6 +40,8 @@ class AdapterRos
private:
ros::NodeHandle& nodeHandle_;
+ pluginlib::ClassLoader tutor_loader_;
+ std::unique_ptr tutor_;
pluginlib::ClassLoader adapterLoader_;
std::unique_ptr adapter_;
pluginlib::ClassLoader adapterRosInterfaceLoader_;
diff --git a/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceBase.hpp b/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceBase.hpp
index 6f8059e..304a0c7 100644
--- a/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceBase.hpp
+++ b/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceBase.hpp
@@ -36,13 +36,13 @@ class AdapterRosInterfaceBase
virtual bool initializeAdapter(AdapterBase& adapter) const = 0;
virtual bool updateAdapterWithRobotState(AdapterBase& adapter) const = 0;
- void updateRobotState(const free_gait_msgs::RobotStateConstPtr& robotState);
+// void updateRobotState(const free_gait_msgs::RobotStateConstPtr& robotState);
protected:
ros::NodeHandle* nodeHandle_;
std::string robotDescriptionUrdfString_;
- ros::Subscriber joint_states_sub_;
- JointPositions all_joint_positions_;
+// ros::Subscriber joint_states_sub_;
+// JointPositions all_joint_positions_;
};
diff --git a/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceDummy.hpp b/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceDummy.hpp
new file mode 100644
index 0000000..6cd4a2f
--- /dev/null
+++ b/free_gait_ros/include/free_gait_ros/AdapterRosInterfaceDummy.hpp
@@ -0,0 +1,40 @@
+/*
+ * filename.hpp
+ * Descriotion:
+ *
+ * Created on: Dec 26, 2018
+ * Author: Shunyao Wang
+ * Institute: Harbin Institute of Technology, Shenzhen
+ */
+
+#pragma once
+#include "moveit_msgs/RobotState.h"
+#include "free_gait_ros/free_gait_ros.hpp"
+
+namespace free_gait {
+
+class AdapterRosInterfaceDummy : public AdapterRosInterfaceBase
+{
+public:
+ AdapterRosInterfaceDummy();
+ ~AdapterRosInterfaceDummy();
+
+ virtual bool subscribeToRobotState(const std::string& robotStateTopic);
+ virtual void unsubscribeFromRobotState();
+ virtual const std::string getRobotStateMessageType();
+ virtual bool isReady() const;
+
+ //! Update adapter.
+ virtual bool initializeAdapter(AdapterBase& adapter) const;
+ virtual bool updateAdapterWithRobotState(AdapterBase& adapter) const;
+
+ void updateRobotState(const free_gait_msgs::RobotStateConstPtr& robotState);
+
+
+private:
+ ros::Subscriber joint_states_sub_;
+ JointPositions all_joint_positions_;
+
+};
+
+} // namespace
diff --git a/free_gait_ros/include/free_gait_ros/free_gait_ros.hpp b/free_gait_ros/include/free_gait_ros/free_gait_ros.hpp
index 2113ae8..d0933f3 100644
--- a/free_gait_ros/include/free_gait_ros/free_gait_ros.hpp
+++ b/free_gait_ros/include/free_gait_ros/free_gait_ros.hpp
@@ -17,3 +17,4 @@
#include "free_gait_ros/StepFrameConverter.hpp"
#include "free_gait_ros/StateRosPublisher.hpp"
#include "free_gait_ros/RosVisualization.hpp"
+#include "free_gait_ros/AdapterDummy.hpp"
diff --git a/free_gait_ros/launch/test.launch b/free_gait_ros/launch/test.launch
new file mode 100644
index 0000000..fbc63d2
--- /dev/null
+++ b/free_gait_ros/launch/test.launch
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/free_gait_ros/package.xml b/free_gait_ros/package.xml
index ae4e5f1..08416f9 100644
--- a/free_gait_ros/package.xml
+++ b/free_gait_ros/package.xml
@@ -22,4 +22,8 @@
robot_state_publisher
kdl_parser
eigen
+
+
+
+
diff --git a/free_gait_ros/plugin_description.xml b/free_gait_ros/plugin_description.xml
new file mode 100644
index 0000000..876334a
--- /dev/null
+++ b/free_gait_ros/plugin_description.xml
@@ -0,0 +1,12 @@
+
+
+ Display to preview Free Gait actions.
+
+
+ Display to preview Free Gait actions.
+
+
diff --git a/free_gait_ros/src/AdapterDummy.cpp b/free_gait_ros/src/AdapterDummy.cpp
new file mode 100644
index 0000000..de90444
--- /dev/null
+++ b/free_gait_ros/src/AdapterDummy.cpp
@@ -0,0 +1,407 @@
+/*
+ * AdapterDummy.cpp
+ *
+ * Created on: Mar 23, 2017
+ * Author: Péter Fankhauser
+ * Institute: ETH Zurich
+ */
+
+#include "free_gait_ros/AdapterDummy.hpp"
+
+namespace free_gait {
+
+AdapterDummy::AdapterDummy()
+ : AdapterBase(),
+ worldFrameId_("odom"),
+ baseFrameId_("base_link")
+{
+ state_.reset(new State());
+ state_->initialize(getLimbs(), getBranches());
+// state_->LoadRobotDescriptionFromFile("/home/hitstar/catkin_ws/src/quadruped_locomotion-dev/quadruped_model/urdf/simpledog.urdf");
+// std::cout<LF_Chain.getNrOfJoints()<getPositionWorldToBaseInWorldFrame();
+ RotationQuaternion I_R_B = state_->getOrientationBaseToWorld();
+// BaseMotionBase baseMotion = stepQueue.getCurrentStep().getBaseMotion();
+// BaseAuto baseAuto;
+// BaseTarget baseTarget;
+// BaseTrajectory baseTrajectory;
+// switch (baseMotion.getType()) {
+// case BaseMotionBase::Type::Auto:
+// {
+// baseAuto = (dynamic_cast(baseMotion));
+// break;
+// }
+// case BaseMotionBase::Type::Target:
+// {
+// baseTarget = (dynamic_cast(baseMotion));
+// break;
+// }
+// case BaseMotionBase::Type::Trajectory:
+// {
+// baseTrajectory = (dynamic_cast(baseMotion));
+// break;
+// }
+// default:
+// {
+// baseAuto = (dynamic_cast(baseMotion));
+// break;
+// }
+// }
+ if(stepQueue.empty()) return true;
+ double time = stepQueue.getCurrentStep().getTime();
+// std::cout<<"+++++++++++++TIME++++++++++++++++"<isSupportLeg(limb))
+ {
+ if(!(time>0.001))
+ {
+ footholdsInSupport_[limb] = state_->getPositionWorldToFootInWorldFrame(limb);
+ }
+// I_r_IF = state_->getPositionWorldToFootInWorldFrame(limb);
+ I_r_IF = footholdsInSupport_.at(limb);
+// baseMotion.getDuration();
+// std::cout<<"=========================="<getLimbJointPositionsFromPositionBaseToFootInBaseFrame(B_r_BF, limb, joint_limb);
+ state_->setJointPositionsForLimb(limb, joint_limb);
+ } else {
+
+ }
+ }
+// stepQueue.getCurrentStep().getLegMotion(LimbEnum::LF_LEG
+ return true;
+}
+
+const std::string& AdapterDummy::getWorldFrameId() const
+{
+ return worldFrameId_;
+}
+
+const std::string& AdapterDummy::getBaseFrameId() const
+{
+ return baseFrameId_;
+}
+
+const std::vector& AdapterDummy::getLimbs() const
+{
+ return limbs_;
+}
+
+const std::vector& AdapterDummy::getBranches() const
+{
+ return branches_;
+}
+
+LimbEnum AdapterDummy::getLimbEnumFromLimbString(const std::string& limb) const
+{
+ if(limb == "LF_LEG")
+ return static_cast(0);
+ if(limb == "RF_LEG")
+ return static_cast(1);
+ if(limb == "LH_LEG")
+ return static_cast(2);
+ if(limb == "RH_LEG")
+ return static_cast(3);
+
+// throw std::runtime_error("AdapterDummy::getLimbEnumFromLimbString() is not implemented.");
+}
+
+std::string AdapterDummy::getLimbStringFromLimbEnum(const LimbEnum& limb) const
+{
+ if(limb == LimbEnum::LF_LEG)
+ return "LF_LEG";
+ if(limb == LimbEnum::RF_LEG)
+ return "RF_LEG";
+ if(limb == LimbEnum::LH_LEG)
+ return "LH_LEG";
+ if(limb == LimbEnum::RH_LEG)
+ return "RH_LEG";
+// throw std::runtime_error("AdapterDummy::getLimbStringFromLimbEnum() is not implemented.");
+}
+
+std::string AdapterDummy::getBaseString() const
+{
+ return "BASE";
+ throw std::runtime_error("AdapterDummy::getBaseString() is not implemented.");
+}
+
+JointNodeEnum AdapterDummy::getJointNodeEnumFromJointNodeString(const std::string& jointNode) const
+{
+ throw std::runtime_error("AdapterDummy::getJointNodeEnumFromJointNodeString() is not implemented.");
+}
+
+std::string AdapterDummy::getJointNodeStringFromJointNodeEnum(const JointNodeEnum& jointNode) const
+{
+ throw std::runtime_error("AdapterDummy::getJointNodeStringFromJointNodeEnum() is not implemented.");
+}
+
+bool AdapterDummy::getLimbJointPositionsFromPositionBaseToFootInBaseFrame(
+ const Position& positionBaseToFootInBaseFrame, const LimbEnum& limb,
+ JointPositionsLeg& jointPositions) const
+{
+ // TODO(Shunyao): solve the single limb IK
+// QuadrupedKinematics::FowardKinematicsSolve()
+// state_->FowardKinematicsSolve()
+ std::cout<<"start"<getLimbJointPositionsFromPositionBaseToFootInBaseFrame(positionBaseToFootInBaseFrame,
+ limb,jointPositions))
+ {
+ return true;
+ }
+ throw std::runtime_error("AdapterDummy::getLimbJointPositionsFromPositionBaseToFootInBaseFrame() is not implemented.");
+}
+
+Position AdapterDummy::getPositionBaseToFootInBaseFrame(
+ const LimbEnum& limb, const JointPositionsLeg& jointPositions) const
+{
+ // TODO(Shunyao): solve the single limb Kinematics
+// state_->FowardKinematicsSolve()
+ return state_->getPositionBaseToFootInBaseFrame(limb,jointPositions);
+ throw std::runtime_error("AdapterDummy::getPositionBaseToFootInBaseFrame() is not implemented.");
+}
+
+Position AdapterDummy::getPositionBaseToHipInBaseFrame(const LimbEnum& limb) const
+{
+ switch (limb) {
+ case LimbEnum::LF_LEG:
+ return Position(0.3, 0.2, 0.0);
+ case LimbEnum::RF_LEG:
+ return Position(0.3, -0.2, 0.0);
+ case LimbEnum::LH_LEG:
+ return Position(-0.3, 0.2, 0.0);
+ case LimbEnum::RH_LEG:
+ return Position(-0.3, -0.2, 0.0);
+ default:
+ throw std::runtime_error("AdapterDummy::getPositionBaseToHipInBaseFrame() something went wrong.");
+ }
+}
+
+bool AdapterDummy::isExecutionOk() const
+{
+ // TODO(Shunyao): How to confirm isOK? from State?
+ return true;
+ throw std::runtime_error("AdapterDummy::isExecutionOk() is not implemented.");
+}
+
+bool AdapterDummy::isLegGrounded(const LimbEnum& limb) const
+{
+// return state_->isSupportLeg(limb);
+ return true;
+ throw std::runtime_error("AdapterDummy::isLegGrounded() is not implemented.");
+}
+
+JointPositionsLeg AdapterDummy::getJointPositionsForLimb(const LimbEnum& limb) const
+{
+ return state_->getJointPositionsForLimb(limb);
+}
+
+JointPositions AdapterDummy::getAllJointPositions() const
+{
+ return state_->getJointPositions();
+}
+
+JointVelocitiesLeg AdapterDummy::getJointVelocitiesForLimb(const LimbEnum& limb) const
+{
+ return state_->getJointVelocitiesForLimb(limb);
+}
+
+JointVelocities AdapterDummy::getAllJointVelocities() const
+{
+ return state_->getJointVelocities();
+}
+
+JointAccelerationsLeg AdapterDummy::getJointAccelerationsForLimb(const LimbEnum& limb) const
+{
+ throw std::runtime_error("AdapterDummy::getJointAccelerationsForLimb() is not implemented.");
+}
+
+JointAccelerations AdapterDummy::getAllJointAccelerations() const
+{
+ throw std::runtime_error("AdapterDummy::getAllJointAccelerations() is not implemented.");
+}
+
+JointEffortsLeg AdapterDummy::getJointEffortsForLimb(const LimbEnum& limb) const
+{
+ return state_->getJointEffortsForLimb(limb);
+}
+
+JointEfforts AdapterDummy::getAllJointEfforts() const
+{
+ return state_->getAllJointEfforts();
+}
+
+Position AdapterDummy::getPositionWorldToBaseInWorldFrame() const
+{
+// return Position(0,0,0);
+ return state_->getPositionWorldToBaseInWorldFrame();
+}
+
+RotationQuaternion AdapterDummy::getOrientationBaseToWorld() const
+{
+// return RotationQuaternion(1,0,0,0);
+ return state_->getOrientationBaseToWorld();
+}
+
+LinearVelocity AdapterDummy::getLinearVelocityBaseInWorldFrame() const
+{
+ return state_->getLinearVelocityBaseInWorldFrame();
+}
+
+LocalAngularVelocity AdapterDummy::getAngularVelocityBaseInBaseFrame() const
+{
+ return state_->getAngularVelocityBaseInBaseFrame();
+}
+
+LinearAcceleration AdapterDummy::getLinearAccelerationBaseInWorldFrame() const
+{
+ throw std::runtime_error("AdapterDummy::getLinearAccelerationBaseInWorldFrame() is not implemented.");
+}
+
+AngularAcceleration AdapterDummy::getAngularAccelerationBaseInBaseFrame() const
+{
+ throw std::runtime_error("AdapterDummy::getAngularAccelerationBaseInBaseFrame() is not implemented.");
+}
+
+Position AdapterDummy::getPositionBaseToFootInBaseFrame(const LimbEnum& limb) const
+{
+ return state_->getPositionBaseToFootInBaseFrame(limb);
+ throw std::runtime_error("AdapterDummy::getPositionBaseToFootInBaseFrame() is not implemented.");
+}
+
+Position AdapterDummy::getPositionWorldToFootInWorldFrame(const LimbEnum& limb) const
+{
+ return state_->getPositionWorldToFootInWorldFrame(limb);
+ throw std::runtime_error("AdapterDummy::getPositionWorldToFootInWorldFrame() is not implemented.");
+}
+
+Position AdapterDummy::getCenterOfMassInWorldFrame() const
+{
+// return Position(0,0,0);
+ return state_->getPositionWorldToBaseInWorldFrame();
+}
+
+void AdapterDummy::getAvailableFrameTransforms(std::vector& frameTransforms) const
+{
+ frameTransforms.push_back("/odom");
+// throw std::runtime_error("AdapterDummy::getAvailableFrameTransforms() is not implemented.");
+}
+
+Pose AdapterDummy::getFrameTransform(const std::string& frameId) const
+{
+ //TODO(Shunyao): It's seems to feedback Odom To Map, amcl?
+ return Pose(Position(0,0,0),RotationQuaternion());//fixed odom with map temparently
+ throw std::runtime_error("AdapterDummy::getFrameTransform() is not implemented.");
+}
+
+ControlSetup AdapterDummy::getControlSetup(const BranchEnum& branch) const
+{
+// TODO(Shunyao): How to set up Control Level, In State class to set controlSetup
+ return ControlSetup({{ControlLevel::Position, true},
+ {ControlLevel::Velocity, false},
+ {ControlLevel::Acceleration, false},
+ {ControlLevel::Effort, false}});
+ throw std::runtime_error("AdapterDummy::getControlSetup() is not implemented.");
+}
+
+ControlSetup AdapterDummy::getControlSetup(const LimbEnum& limb) const
+{
+ return ControlSetup({{ControlLevel::Position, true},
+ {ControlLevel::Velocity, false},
+ {ControlLevel::Acceleration, false},
+ {ControlLevel::Effort, false}});
+ throw std::runtime_error("AdapterDummy::getControlSetup() is not implemented.");
+}
+
+//! State depending on real robot.
+JointVelocitiesLeg AdapterDummy::getJointVelocitiesFromEndEffectorLinearVelocityInWorldFrame(
+ const LimbEnum& limb, const LinearVelocity& endEffectorLinearVelocityInWorldFrame) const
+{
+ throw std::runtime_error("AdapterDummy::getJointVelocitiesFromEndEffectorLinearVelocityInWorldFrame() is not implemented.");
+}
+
+LinearVelocity AdapterDummy::getEndEffectorLinearVelocityFromJointVelocities(const LimbEnum& limb,
+ const JointVelocitiesLeg& jointVelocities,
+ const std::string& frameId) const
+{
+ //TODO(Shunyao): dp = Jacobian * dq
+// if(frameId != getBaseFrameId())
+// {
+// transformLinearVelocity(frameId, getBaseFrameId(),)
+// }
+ return state_->getEndEffectorLinearVelocityFromJointVelocities(limb, jointVelocities);
+ throw std::runtime_error("AdapterDummy::getEndEffectorLinearVelocityFromJointVelocities() is not implemented.");
+}
+
+JointAccelerationsLeg AdapterDummy::getJointAccelerationsFromEndEffectorLinearAccelerationInWorldFrame(
+ const LimbEnum& limb, const LinearAcceleration& endEffectorLinearAccelerationInWorldFrame) const
+{
+ throw std::runtime_error("AdapterDummy::getJointAccelerationsFromEndEffectorLinearAccelerationInWorldFrame() is not implemented.");
+}
+
+bool AdapterDummy::setInternalDataFromState(const State& state, bool updateContacts, bool updatePosition,
+ bool updateVelocity, bool updateAcceleration) const
+{
+ *state_ = state;
+ return true;
+}
+
+void AdapterDummy::createCopyOfState() const
+{
+
+}
+
+void AdapterDummy::resetToCopyOfState() const
+{
+
+}
+
+const State& AdapterDummy::getState() const
+{
+ return *state_;
+}
+
+} /* namespace */
+
+#include
+PLUGINLIB_EXPORT_CLASS(free_gait::AdapterDummy, free_gait::AdapterBase)
diff --git a/free_gait_ros/src/AdapterRos.cpp b/free_gait_ros/src/AdapterRos.cpp
index eb8b7ec..78b219b 100644
--- a/free_gait_ros/src/AdapterRos.cpp
+++ b/free_gait_ros/src/AdapterRos.cpp
@@ -7,28 +7,47 @@
*/
#include "free_gait_ros/AdapterRos.hpp"
-
namespace free_gait {
AdapterRos::AdapterRos(ros::NodeHandle& nodeHandle, const AdapterType type)
: nodeHandle_(nodeHandle),
- adapterLoader_("free_gait_core", "free_gait::AdapterBase"),
+ tutor_loader_("pluginlib_tutorials", "polygon_base::RegularPolygon"),
+ adapterLoader_("free_gait_ros", "free_gait::AdapterBase"),
adapterRosInterfaceLoader_("free_gait_ros", "free_gait::AdapterRosInterfaceBase")
{
// Load and initialize adapter.
+ std::cout<<"Constructing AdapterRos..."< tutor_loader("pluginlib_tutorials", "polygon_base::RegularPolygon");
+// tutor_loader.createInstance("pluginlib_tutorials/regular_triangle");
+ tutor_.reset(tutor_loader_.createUnmanagedInstance("pluginlib_tutorials/regular_triangle"));
+ std::cout<<"Haved loaded tutorials"< libs_before = adapterRosInterfaceLoader_.getRegisteredLibraries();
std::string adapterRosInterfacePluginName;
nodeHandle.getParam("/free_gait/adapter_ros_interface_plugin", adapterRosInterfacePluginName);
+ std::cout<<"===="< libs_after =adapterRosInterfaceLoader_.getRegisteredLibraries();
+ std::cout<setNodeHandle(nodeHandle_);
adapterRosInterface_->readRobotDescription();
diff --git a/free_gait_ros/src/AdapterRosInterfaceBase.cpp b/free_gait_ros/src/AdapterRosInterfaceBase.cpp
index d193c70..f83f6cf 100644
--- a/free_gait_ros/src/AdapterRosInterfaceBase.cpp
+++ b/free_gait_ros/src/AdapterRosInterfaceBase.cpp
@@ -10,6 +10,7 @@
#include
+
namespace free_gait {
AdapterRosInterfaceBase::AdapterRosInterfaceBase()
@@ -34,13 +35,14 @@ bool AdapterRosInterfaceBase::readRobotDescription()
} else {
throw pluginlib::PluginlibException("Did not find ROS parameter for robot description '/free_gait/robot_description'.");
}
-
- if (nodeHandle_->hasParam(robotDescriptionPath)) {
- nodeHandle_->getParam(robotDescriptionPath, robotDescriptionUrdfString_);
- } else {
- throw pluginlib::PluginlibException("Did not find ROS parameter for robot description '" + robotDescriptionPath + "'.");
- }
-
+ robotDescriptionUrdfString_ = robotDescriptionPath;
+// ROS_INFO("=================================================");
+// if (nodeHandle_->hasParam(robotDescriptionPath)) {
+// nodeHandle_->getParam(robotDescriptionPath, robotDescriptionUrdfString_);
+// } else {
+// throw pluginlib::PluginlibException("Did not find ROS parameter for robot description '" + robotDescriptionPath + "'.");
+// }
+// ROS_INFO("=================================================");
return true;
}
bool AdapterRosInterfaceBase::updateAdapterWithRobotState(AdapterBase& adapter) const
@@ -54,17 +56,17 @@ bool AdapterRosInterfaceBase::updateAdapterWithRobotState(AdapterBase& adapter)
bool AdapterRosInterfaceBase::subscribeToRobotState(const std::string& robotStateTopic)
{
// topic: "/free_gait/robot_state",
- joint_states_sub_ = nodeHandle_->subscribe("/robot_state", 1, &AdapterRosInterfaceBase::updateRobotState,this);
+ //joint_states_sub_ = nodeHandle_->subscribe("/robot_state", 1, &AdapterRosInterfaceBase::updateRobotState,this);
}
-void AdapterRosInterfaceBase::updateRobotState(const free_gait_msgs::RobotStateConstPtr& robotState)
-{
- for(int i = 1;i<12;i++)
- {
- all_joint_positions_(i) = robotState->lf_leg_joints.position[i];
- }
+//void AdapterRosInterfaceBase::updateRobotState(const free_gait_msgs::RobotStateConstPtr& robotState)
+//{
+// for(int i = 1;i<12;i++)
+// {
+// all_joint_positions_(i) = robotState->lf_leg_joints.position[i];
+// }
-}
+//}
} /* namespace free_gait */
diff --git a/free_gait_ros/src/AdapterRosInterfaceDummy.cpp b/free_gait_ros/src/AdapterRosInterfaceDummy.cpp
new file mode 100644
index 0000000..7a16295
--- /dev/null
+++ b/free_gait_ros/src/AdapterRosInterfaceDummy.cpp
@@ -0,0 +1,76 @@
+/*
+ * AdapterRosInterfaceDummy.cpp
+ * Descriotion: Adapter Ros interface with Dummy states, use for a visulization
+ * in Rviz
+ *
+ * Created on: Dec 26, 2018
+ * Author: Shunyao Wang
+ * Institute: Harbin Institute of Technology, Shenzhen
+ */
+
+#include "free_gait_ros/AdapterRosInterfaceDummy.hpp"
+
+namespace free_gait {
+
+AdapterRosInterfaceDummy::AdapterRosInterfaceDummy()
+{
+
+}
+
+AdapterRosInterfaceDummy::~AdapterRosInterfaceDummy()
+{
+
+}
+
+bool AdapterRosInterfaceDummy::subscribeToRobotState(const std::string& robotStateTopic)
+{
+ joint_states_sub_ = nodeHandle_->subscribe(robotStateTopic, 1, &AdapterRosInterfaceDummy::updateRobotState,this);
+}
+void AdapterRosInterfaceDummy::unsubscribeFromRobotState()
+{
+ joint_states_sub_.shutdown();
+// throw std::runtime_error("AdapterRosInterfaceDummy::unsubscribeFromRobotState() is not implemented.");
+
+}
+const std::string AdapterRosInterfaceDummy::getRobotStateMessageType()
+{
+ return ros::message_traits::datatype();
+ throw std::runtime_error("AdapterRosInterfaceDummy::getRobotStateMessageType() is not implemented.");
+
+}
+bool AdapterRosInterfaceDummy::isReady() const
+{
+ throw std::runtime_error("AdapterRosInterfaceDummy::isReady() is not implemented.");
+
+}
+
+
+//! Update adapter.
+bool AdapterRosInterfaceDummy::initializeAdapter(AdapterBase& adapter) const
+{
+ std::cout<<"Initial Adapter"<lf_leg_joints.position[i];
+ }
+
+}
+
+}//namespace
+
+
+#include
+PLUGINLIB_EXPORT_CLASS(free_gait::AdapterRosInterfaceDummy, free_gait::AdapterRosInterfaceBase)
diff --git a/free_gait_ros/src/FreeGaitActionServer.cpp b/free_gait_ros/src/FreeGaitActionServer.cpp
index 88d7bd3..69cae38 100644
--- a/free_gait_ros/src/FreeGaitActionServer.cpp
+++ b/free_gait_ros/src/FreeGaitActionServer.cpp
@@ -72,6 +72,7 @@ void FreeGaitActionServer::update()
}
} else {
// Ongoing.
+ ROS_INFO("publish feedback");
lock.lock();
if (executor_.getQueue().active()) publishFeedback();
lock.unlock();
diff --git a/free_gait_ros/src/StateRosPublisher.cpp b/free_gait_ros/src/StateRosPublisher.cpp
index c7b742c..5455f00 100644
--- a/free_gait_ros/src/StateRosPublisher.cpp
+++ b/free_gait_ros/src/StateRosPublisher.cpp
@@ -85,7 +85,7 @@ bool StateRosPublisher::publish(const State& state)
state.getAllJointNames(jointNames);
- JointPositions jointPositions = state.getJointPositions();
+ JointPositions jointPositions = state.getJointPositionsToReach();//.getJointPositions();
if (jointNames.size() != jointPositions.vector().size()) {
ROS_ERROR("Joint name vector and joint position are not of equal size!");
@@ -94,12 +94,12 @@ bool StateRosPublisher::publish(const State& state)
std::map jointPositionsMap;
for (size_t i = 0; i < jointNames.size(); ++i) {
jointPositionsMap[jointNames[i]] = jointPositions(i);
- std::cout<publishTransforms(jointPositionsMap, time, tfPrefix_);
robotStatePublisher_->publishFixedTransforms(tfPrefix_);
-ROS_INFO("In ros state publisher");
+//ROS_INFO("In ros state publisher");
// Publish base position.
geometry_msgs::TransformStamped tfTransform;
tfTransform.header.stamp = time;
diff --git a/free_gait_ros/test/action_server_test.cpp b/free_gait_ros/test/action_server_test.cpp
new file mode 100644
index 0000000..f03be3e
--- /dev/null
+++ b/free_gait_ros/test/action_server_test.cpp
@@ -0,0 +1,105 @@
+/*
+ * action_server_test.cpp
+ * Descriotion:
+ *
+ * Created on: Aug 31, 2017
+ * Author: Shunyao Wang
+ * Institute: Harbin Institute of Technology, Shenzhen
+ */
+#include "free_gait_ros/free_gait_ros.hpp"
+#include "free_gait_core/free_gait_core.hpp"
+#include "pluginlib/class_loader.h"
+#include "boost/bind.hpp"
+#include "boost/thread.hpp"
+
+using namespace free_gait;
+using namespace std;
+class ActionServerTest
+{
+public:
+ ActionServerTest(ros::NodeHandle& nodehandle)
+ : nodeHandle_(nodehandle),
+ adapter_loader("free_gait_ros", "free_gait::AdapterBase")
+ {
+ adapter.reset(adapter_loader.createUnmanagedInstance("free_gait_ros/AdapterDummy"));
+ state.reset(new State());
+ parameters.reset(new StepParameters());
+ completer.reset(new StepCompleter(*parameters, *adapter));
+ computer.reset(new StepComputer());
+ executor.reset(new Executor(*completer, *computer, *adapter, *state));
+ rosPublisher.reset(new StateRosPublisher(nodeHandle_, *adapter));
+ executor->initialize();
+
+ server_.reset(new FreeGaitActionServer(nodeHandle_, "/free_gait/action_server", *executor, *adapter));
+ server_->initialize();
+ server_->start();
+// server_->update();
+ action_server_thread_ = boost::thread(boost::bind(&ActionServerTest::ActionServerThread, this));
+
+ }
+ ~ActionServerTest() {}
+
+ void ActionServerThread()//(const FreeGaitActionServer& server)
+ {
+ ROS_INFO("In action server thread");
+ double dt = 0.001;
+ double time = 0.0;
+ ros::Rate rate(100);
+ while (ros::ok()) {
+ server_->update();
+// TODO(Shunyao): How to Update?
+ if (!executor->getQueue().empty()) {
+ executor->advance(dt, true);
+ time = time + dt;
+ rosPublisher->publish(adapter->getState());
+ }
+ rate.sleep();
+ }
+
+ }
+private:
+// FreeGaitActionServer server_;
+ std::unique_ptr server_;
+ boost::thread action_server_thread_;
+ ros::NodeHandle nodeHandle_;
+ std::unique_ptr adapter;
+ pluginlib::ClassLoader adapter_loader;
+ std::unique_ptr state;
+ std::unique_ptr parameters;
+ std::unique_ptr completer;
+ std::unique_ptr computer;
+ std::unique_ptr executor;
+ std::unique_ptr rosPublisher;
+};
+
+
+
+int main(int argc, char *argv[])
+{
+ ros::init(argc, argv, "action_server_test");
+ ros::NodeHandle nh("~");
+ ActionServerTest ac_test(nh);
+ ros::spin();
+// pluginlib::ClassLoader adapter_loader("free_gait_ros", "free_gait::AdapterBase");
+// std::unique_ptr adapter;
+// adapter.reset(adapter_loader.createUnmanagedInstance("free_gait_ros/AdapterDummy"));
+
+
+// double dt = 0.001;
+// double time = 0.0;
+//// ros::Time t_start = ros::Time::now();
+// ros::Rate rate(1000);
+// ros::spin();
+
+// while (!executor.getQueue().empty()) {
+// executor.advance(dt, true);
+// time = time + dt;
+// rosPublisher.publish(adapter->getState());
+
+// }
+
+// ros::Time t_end = ros::Time::now();
+// cout<<"end time : "<