-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into readme/build_from_source_ros_path
- Loading branch information
Showing
61 changed files
with
1,478 additions
and
934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef AIKIDO_CONTROL_ROS_ROSJOINTSTATECLIENT_HPP_ | ||
#define AIKIDO_CONTROL_ROS_ROSJOINTSTATECLIENT_HPP_ | ||
#include <string> | ||
#include <boost/circular_buffer.hpp> | ||
#include <dart/dynamics/dynamics.hpp> | ||
#include <ros/ros.h> | ||
#include <ros/callback_queue.h> | ||
#include <sensor_msgs/JointState.h> | ||
|
||
namespace aikido { | ||
namespace control { | ||
namespace ros { | ||
|
||
/// Client that listens for JointState messages for each skeleton joint and | ||
/// provides a method for extracting the most recent position of each joint. | ||
class RosJointStateClient | ||
{ | ||
public: | ||
/// Constructor. | ||
/// \param _skeleton Skeleton to read JointState updates for. | ||
/// \param _nodeHandle ROS node. | ||
/// \param _topicName Name of topic to subscribe to for JointState updates. | ||
/// \param _capacity Number of JointStateRecords that are saved per joint. | ||
RosJointStateClient( | ||
dart::dynamics::SkeletonPtr _skeleton, | ||
::ros::NodeHandle _nodeHandle, | ||
const std::string& _topicName, | ||
size_t capacity); | ||
|
||
/// Update mBuffer with any JointState messages that have been received. | ||
void spin(); | ||
|
||
/// Returns the most recent position of each joint in _metaSkeleton. | ||
/// \param _metaSkeleton Skeleton to read DOFs from. | ||
/// \return vector of positions for each DOF | ||
Eigen::VectorXd getLatestPosition( | ||
const dart::dynamics::MetaSkeleton& _metaSkeleton) const; | ||
|
||
// TODO: implement | ||
// getPositionAtTime(const MetaSkeleton&, const ros::Time&, bool) | ||
// that interpolates position at the specified time, optionally blocking for | ||
// new data. | ||
private: | ||
struct JointStateRecord | ||
{ | ||
inline bool isValid() const { return mStamp.isValid(); } | ||
|
||
::ros::Time mStamp; | ||
double mPosition; | ||
}; | ||
|
||
/// Callback to add a new JointState to mBuffer | ||
/// \param _jointState New JointState to add to mBuffer | ||
void jointStateCallback(const sensor_msgs::JointState& _jointState); | ||
|
||
mutable std::mutex mMutex; | ||
|
||
dart::dynamics::SkeletonPtr mSkeleton; | ||
std::unordered_map<std::string, | ||
boost::circular_buffer<JointStateRecord>> mBuffer; | ||
size_t mCapacity; | ||
|
||
::ros::CallbackQueue mCallbackQueue; | ||
::ros::NodeHandle mNodeHandle; | ||
::ros::Subscriber mSubscriber; | ||
}; | ||
|
||
} // namespace ros | ||
} // namespace control | ||
} // namespace aikido | ||
|
||
#endif // ifndef AIKIDO_CONTROL_ROS_ROSJOINTSTATECLIENT_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
#ifndef AIKIDO_DISTANCE_ANGULARDISTANCEMETRIC_HPP_ | ||
#define AIKIDO_DISTANCE_ANGULARDISTANCEMETRIC_HPP_ | ||
|
||
#include "DistanceMetric.hpp" | ||
#include "../statespace/SO2.hpp" | ||
#include "DistanceMetric.hpp" | ||
|
||
namespace aikido { | ||
namespace distance { | ||
|
||
namespace aikido | ||
{ | ||
namespace distance | ||
{ | ||
/// Computes the shortest distance between two angles in SO(2) | ||
class SO2Angular : public DistanceMetric | ||
{ | ||
public: | ||
/// Constructor. | ||
/// \param _space The SO2 this distance metric operates on | ||
explicit SO2Angular( | ||
std::shared_ptr<statespace::SO2> _space); | ||
explicit SO2Angular(std::shared_ptr<statespace::SO2> _space); | ||
|
||
// Documentation inherited | ||
statespace::StateSpacePtr getStateSpace() const override; | ||
|
||
/// Computes shortest distance between two angles. (return value between 0 and pi) | ||
/// Computes shortest distance between two angles. (return value between 0 and | ||
/// pi) | ||
/// \param _state1 The first state (type: SO2::State) | ||
/// \param _state2 The second state (type: SO2::State) | ||
double distance(const statespace::StateSpace::State* _state1, | ||
const statespace::StateSpace::State* _state2) const override; | ||
double distance( | ||
const statespace::StateSpace::State* _state1, | ||
const statespace::StateSpace::State* _state2) const override; | ||
|
||
private: | ||
std::shared_ptr<statespace::SO2> mStateSpace; | ||
}; | ||
} | ||
} | ||
|
||
} // namespace distance | ||
} // namespace aikido | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
#ifndef AIKIDO_DISTANCE_GEODESICDISTANCEMETRIC_HPP_ | ||
#define AIKIDO_DISTANCE_GEODESICDISTANCEMETRIC_HPP_ | ||
|
||
#include "DistanceMetric.hpp" | ||
#include "../statespace/SO3.hpp" | ||
#include "DistanceMetric.hpp" | ||
|
||
namespace aikido { | ||
namespace distance { | ||
|
||
namespace aikido | ||
{ | ||
namespace distance | ||
{ | ||
/// Implements a distance metric on SO(3) | ||
class SO3Angular : public DistanceMetric | ||
{ | ||
public: | ||
/// Constructor. | ||
/// \param _space The SO3 this distance metric operates on | ||
explicit SO3Angular( | ||
std::shared_ptr<statespace::SO3> _space); | ||
explicit SO3Angular(std::shared_ptr<statespace::SO3> _space); | ||
|
||
// Documentation inherited | ||
statespace::StateSpacePtr getStateSpace() const override; | ||
|
||
/// Computes distance (in radians) between the two states | ||
/// \param _state1 The first state (type SO3::State) | ||
/// \param _state2 The second state (type SO3::State) | ||
double distance(const statespace::StateSpace::State* _state1, | ||
const statespace::StateSpace::State* _state2) const override; | ||
double distance( | ||
const statespace::StateSpace::State* _state1, | ||
const statespace::StateSpace::State* _state2) const override; | ||
|
||
private: | ||
std::shared_ptr<statespace::SO3> mStateSpace; | ||
}; | ||
} | ||
} | ||
|
||
} // namespace distance | ||
} // namespace aikido | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.