ed
robot_plugin.h
Go to the documentation of this file.
1 #ifndef ED_ROBOT_PLUGIN_H_
2 #define ED_ROBOT_PLUGIN_H_
3 
4 #include <ed/plugin.h>
5 #include <ed/relation.h>
6 #include <ed/time_cache.h>
7 #include <ed/uuid.h>
8 
9 #include <ros/subscriber.h>
10 #include <ros/callback_queue.h>
11 #include <sensor_msgs/JointState.h>
12 
13 #include <kdl/tree.hpp>
14 #include <geolib/datatypes.h>
15 
16 #include <urdf/model.h>
17 
18 #include <map>
19 
20 // ----------------------------------------------------------------------------------------------------
21 
23 {
24 
25 public:
26 
27  JointRelation(const KDL::Segment& segment) : segment_(segment) {}
28 
29  bool calculateTransform(const ed::Time& t, geo::Pose3D& tf) const;
30 
31  void insert(const ed::Time& t, float joint_pos) { joint_pos_cache_.insert(t, joint_pos); }
32 
33  inline unsigned int size() const { return joint_pos_cache_.size(); }
34 
35  void setCacheSize(unsigned int n) { joint_pos_cache_.setMaxSize(n); }
36 
37 private:
38 
40  KDL::Segment segment_; // calculates the joint pose
41 
42 };
43 
44 
45 // ----------------------------------------------------------------------------------------------------
46 
48 {
52  boost::shared_ptr<const JointRelation> last_rel;
53 };
54 
55 // ----------------------------------------------------------------------------------------------------
56 
57 class RobotPlugin : public ed::Plugin
58 {
59 
60 public:
61 
62  RobotPlugin();
63 
64  virtual ~RobotPlugin();
65 
67 
68  void initialize();
69 
70  void process(const ed::WorldModel& world, ed::UpdateRequest& req);
71 
72 private:
73 
75 
77 
79 
80  urdf::Model robot_model_;
81 
83 
85 
86  unsigned int joint_cache_size_;
87 
88  void constructRobot(const ed::UUID& parent_id, const KDL::SegmentMap::const_iterator& it_segment, ed::UpdateRequest& req);
89 
90 
91  // ROS Communication
92 
93  ros::CallbackQueue cb_queue_;
94 
96 
97  void jointCallback(const sensor_msgs::JointState::ConstPtr& msg);
98 
99 
100 };
101 
102 #endif
datatypes.h
ed::Plugin
Definition: plugin.h:28
ed::Relation
Definition: relation.h:12
ed::WorldModel
Definition: world_model.h:21
ed::UpdateRequest
Definition: update_request.h:24
std::string
RobotPlugin::initialize
void initialize()
Definition: robot_plugin.cpp:342
t
Timer t
RobotPlugin::configure
void configure(tue::Configuration config)
Definition: robot_plugin.cpp:287
RelationInfo::last_rel
boost::shared_ptr< const JointRelation > last_rel
Definition: robot_plugin.h:52
RobotPlugin::jointCallback
void jointCallback(const sensor_msgs::JointState::ConstPtr &msg)
Definition: robot_plugin.cpp:250
RelationInfo::child_id
ed::UUID child_id
Definition: robot_plugin.h:50
plugin.h
geo::Transform3T
relation.h
JointRelation::insert
void insert(const ed::Time &t, float joint_pos)
Definition: robot_plugin.h:31
ed::Time
Definition: time.h:9
JointRelation::setCacheSize
void setCacheSize(unsigned int n)
Definition: robot_plugin.h:35
tue::config::ReaderWriter
RobotPlugin
Definition: robot_plugin.h:57
ed::TimeCache< float >
JointRelation::segment_
KDL::Segment segment_
Definition: robot_plugin.h:40
ed::UUID
Definition: uuid.h:10
RobotPlugin::tree_
KDL::Tree tree_
Definition: robot_plugin.h:78
RobotPlugin::model_initialized_
bool model_initialized_
Definition: robot_plugin.h:76
time_cache.h
uuid.h
map
RelationInfo::parent_id
ed::UUID parent_id
Definition: robot_plugin.h:49
JointRelation::joint_pos_cache_
ed::TimeCache< float > joint_pos_cache_
Definition: robot_plugin.h:39
RelationInfo::r_idx
ed::Idx r_idx
Definition: robot_plugin.h:51
KDL::Tree
ed::TimeCache::setMaxSize
void setMaxSize(unsigned int n)
Definition: time_cache.h:57
KDL::Segment
RobotPlugin::constructRobot
void constructRobot(const ed::UUID &parent_id, const KDL::SegmentMap::const_iterator &it_segment, ed::UpdateRequest &req)
Definition: robot_plugin.cpp:216
RobotPlugin::joint_cache_size_
unsigned int joint_cache_size_
Definition: robot_plugin.h:86
RobotPlugin::joint_name_to_rel_info_
std::map< std::string, RelationInfo > joint_name_to_rel_info_
Definition: robot_plugin.h:82
RobotPlugin::process
void process(const ed::WorldModel &world, ed::UpdateRequest &req)
Definition: robot_plugin.cpp:348
RobotPlugin::update_req_
ed::UpdateRequest * update_req_
Definition: robot_plugin.h:84
JointRelation
Definition: robot_plugin.h:22
RobotPlugin::joint_subscribers_
std::map< std::string, ros::Subscriber > joint_subscribers_
Definition: robot_plugin.h:95
ed::TimeCache::size
unsigned int size() const
Definition: time_cache.h:55
RobotPlugin::cb_queue_
ros::CallbackQueue cb_queue_
Definition: robot_plugin.h:93
JointRelation::JointRelation
JointRelation(const KDL::Segment &segment)
Definition: robot_plugin.h:27
JointRelation::calculateTransform
bool calculateTransform(const ed::Time &t, geo::Pose3D &tf) const
Definition: robot_plugin.cpp:25
RobotPlugin::robot_name_
std::string robot_name_
Definition: robot_plugin.h:74
RobotPlugin::robot_model_
urdf::Model robot_model_
Definition: robot_plugin.h:80
RelationInfo
Definition: robot_plugin.h:47
RobotPlugin::~RobotPlugin
virtual ~RobotPlugin()
Definition: robot_plugin.cpp:210
ed::TimeCache::insert
void insert(const Time &t, const T &value)
Definition: time_cache.h:22
ed::Idx
uint64_t Idx
Definition: types.h:21
JointRelation::size
unsigned int size() const
Definition: robot_plugin.h:33
config
tue::config::ReaderWriter config
RobotPlugin::RobotPlugin
RobotPlugin()
Definition: robot_plugin.cpp:204