22 #include "position_3d_thread.h" 24 #include <ros/this_node.h> 25 #include <fawkes_msgs/Position3D.h> 29 #define CFG_PREFIX "/ros/position-3d/" 40 :
Thread(
"RosPosition3DThread",
Thread::OPMODE_WAITFORWAKEUP),
53 cfg_ros_topic_ =
"/objects";
58 ros_pub_ =
rosnode->advertise<fawkes_msgs::Position3D>(cfg_ros_topic_, 100);
61 for (std::list<Position3DInterface *>::iterator it = ifs_.begin(); it != ifs_.end(); it++) {
77 for (std::list<Position3DInterface *>::iterator it = ifs_.begin(); it != ifs_.end(); it++) {
86 if (strncmp(type,
"Position3DInterface", __INTERFACE_TYPE_SIZE) != 0)
return;
89 interface =
blackboard->open_for_reading<Position3DInterface>(id);
97 ifs_.push_back(interface);
107 unsigned int instance_serial)
110 conditional_close(interface);
116 unsigned int instance_serial)
119 conditional_close(interface);
123 RosPosition3DThread::conditional_close(
Interface *interface)
throw()
129 std::list<Position3DInterface *>::iterator it;
130 for (it = ifs_.begin(); it != ifs_.end(); ++it) {
131 if (*interface == **it) {
150 fawkes_msgs::Position3D position;
151 position.header.frame_id = iface->
frame();
152 position.name = iface->
id();
153 position.pose.position.x = iface->
translation()[0];
154 position.pose.position.y = iface->
translation()[1];
155 position.pose.position.z = iface->
translation()[2];
156 position.pose.orientation.x = iface->
rotation()[0];
157 position.pose.orientation.y = iface->
rotation()[1];
158 position.pose.orientation.z = iface->
rotation()[2];
159 position.pose.orientation.w = iface->
rotation()[3];
161 ros_pub_.publish(position);
virtual void register_observer(BlackBoardInterfaceObserver *observer)
Register BB interface observer.
RosPosition3DThread()
Constructor.
double * rotation() const
Get rotation value.
char * frame() const
Get frame value.
virtual ~RosPosition3DThread()
Destructor.
Fawkes library namespace.
virtual void init()
Initialize the thread.
const char * id() const
Get identifier of interface.
virtual const char * what() const
Get primary string.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
Thread class encapsulation of pthreads.
virtual void update_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Update BB event listener.
Base class for all Fawkes BlackBoard interfaces.
Logger * logger
This is the Logger member used to access the logger.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
virtual void bb_interface_reader_removed(fawkes::Interface *interface, unsigned int instance_serial)
A reading instance has been closed for a watched interface.
void bbio_add_observed_create(const char *type_pattern, const char *id_pattern="*")
Add interface creation type to watch list.
virtual void bb_interface_writer_removed(fawkes::Interface *interface, unsigned int instance_serial)
A writing instance has been closed for a watched interface.
Position3DInterface Fawkes BlackBoard Interface.
Base class for exceptions in Fawkes.
void read()
Read from BlackBoard into local copy.
virtual void bb_interface_data_changed(fawkes::Interface *interface)
BlackBoard data changed notification.
virtual void unregister_observer(BlackBoardInterfaceObserver *observer)
Unregister BB interface observer.
bool has_writer() const
Check if there is a writer for the interface.
const char * name() const
Get name of thread.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
double * translation() const
Get translation value.
virtual std::list< Interface * > open_multiple_for_reading(const char *type_pattern, const char *id_pattern="*", const char *owner=NULL)=0
Open multiple interfaces for reading.
void bbil_remove_data_interface(Interface *interface)
Remove an interface to the data modification watch list.
LockPtr< ros::NodeHandle > rosnode
Central ROS node handle.
virtual void bb_interface_created(const char *type, const char *id)
BlackBoard interface created notification.
int32_t visibility_history() const
Get visibility_history value.
unsigned int num_readers() const
Get the number of readers.
Configuration * config
This is the Configuration member used to access the configuration.
virtual void finalize()
Finalize the thread.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
BlackBoard interface listener.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
void bbil_add_data_interface(Interface *interface)
Add an interface to the data modification watch list.
virtual void close(Interface *interface)=0
Close interface.