lookup_test.cpp
Go to the documentation of this file.
1 
2 
3 #include <ros/ros.h>
4 #include <ros/time.h>
5 #include <rtt/os/main.h>
6 #include <rtt/RTT.hpp>
7 #include <ocl/DeploymentComponent.hpp>
8 #include <ocl/TaskBrowser.hpp>
9 #include "../rtt_tf-component.hpp"
10 #include <geometry_msgs/TransformStamped.h>
11 
13 public:
15  <geometry_msgs::TransformStamped(const std::string &, const std::string &, const ros::Time &)> lookup_;
17  <geometry_msgs::TransformStamped(const std::string &, const std::string &)> lookup_now_;
19  <bool(const std::string &, const std::string &)> subscribe_transform_;
20  geometry_msgs::TransformStamped tform_, tform_now_;
21 
22  LookupComponent(const std::string &name) :
24  ,lookup_("lookupTransformAtTime")
25  ,lookup_now_("lookupTransform")
26  ,subscribe_transform_("subscribeTransform")
27  {
28  this->addProperty("tform",tform_);
29  this->addProperty("tform_now",tform_now_);
30  this->requires("tf")->addOperationCaller(lookup_);
31  this->requires("tf")->addOperationCaller(lookup_now_);
32  this->requires("tf")->addOperationCaller(subscribe_transform_);
33  }
34  virtual ~LookupComponent() { }
35  bool configureHook() {
36  subscribe_transform_("rel_rtt_tf_test","rtt_tf_test");
37  return true;
38  }
39  bool startHook() {
40  return true;
41  }
42  void updateHook() {
43  try{
44  tform_ = lookup_("/world","/rtt_tf_test",ros::Time::now()-ros::Duration(0.1));
45  tform_now_ = lookup_now_("/world","rel_rtt_tf_test");
46  } catch(...) {
47 
48  }
49  }
50  void stopHook() { }
51 };
52 
54 
55 int ORO_main(int argc, char** argv) {
56 
57  LookupComponent lookup("lookup");
58 
59  {
60  // Create deployer
61  OCL::DeploymentComponent deployer;
62 
63  // initialize ROS and load typekits
64  deployer.import("rtt_rosnode");
65  deployer.import("rtt_std_msgs");
66  deployer.import("rtt_geometry_msgs");
67  deployer.import("rtt_tf2_msgs");
68 
69  // import and load our component
70  deployer.import("rtt_tf");
71  deployer.loadComponent("tf","rtt_tf::RTT_TF");
72 
73  RTT::TaskContext *tf_component = deployer.myGetPeer("tf");
74 
75  // Connect components and deployer
76  deployer.connectPeers(&lookup);
77  deployer.setActivity("lookup",0.02,0,ORO_SCHED_OTHER);
78  deployer.setActivity("tf",0.1,0,ORO_SCHED_OTHER);
79 
80  // Connect services between the tf component and the broadcaster
81  lookup.connectServices(tf_component);
82 
83  // Configure and start the components
84  tf_component->configure();
85  tf_component->start();
86 
87  lookup.configure();
88  lookup.start();
89 
90  // Create orocos taskbrowser for easy interaction
91  OCL::TaskBrowser task_browser(&deployer);
92  task_browser.loop();
93 
94  lookup.stop();
95  }
96 
97 
98  return 0;
99 }
100 
geometry_msgs::TransformStamped tform_
Definition: lookup_test.cpp:20
LookupComponent(const std::string &name)
Definition: lookup_test.cpp:22
Property< T > & addProperty(const std::string &name, T &attr)
bool setActivity(const std::string &comp_name, double period, int priority, int scheduler)
virtual bool stop()
ORO_CREATE_COMPONENT(LookupComponent)
bool import(const std::string &package)
friend friend class TaskContext
bool connectPeers(const std::string &one, const std::string &other)
virtual bool configure()
RTT::TaskContext * myGetPeer(std::string name)
bool configureHook()
Definition: lookup_test.cpp:35
geometry_msgs::TransformStamped tform_now_
Definition: lookup_test.cpp:20
ServiceRequester::shared_ptr requires()
RTT::OperationCaller< geometry_msgs::TransformStamped(const std::string &, const std::string &)> lookup_now_
Definition: lookup_test.cpp:17
RTT::OperationCaller< bool(const std::string &, const std::string &)> subscribe_transform_
Definition: lookup_test.cpp:19
int ORO_main(int argc, char **argv)
Definition: lookup_test.cpp:55
virtual ~LookupComponent()
Definition: lookup_test.cpp:34
bool loadComponent(const std::string &name, const std::string &type)
static Time now()
virtual bool connectServices(TaskContext *peer)
RTT::OperationCaller< geometry_msgs::TransformStamped(const std::string &, const std::string &, const ros::Time &)> lookup_
Definition: lookup_test.cpp:15
#define ORO_SCHED_OTHER
virtual bool start()


rtt_tf
Author(s): Ruben Smits
autogenerated on Mon May 10 2021 02:46:04