23 #include "node_thread.h"
25 #include <gazebo/gazebo_config.h>
26 #include <google/protobuf/message.h>
28 #include <gazebo/gazebo_client.hh>
29 #include <gazebo/msgs/msgs.hh>
30 #include <gazebo/transport/Node.hh>
31 #include <gazebo/transport/TransportIface.hh>
32 #include <gazebo/transport/TransportTypes.hh>
46 :
Thread(
"GazeboNodeThread",
Thread::OPMODE_WAITFORWAKEUP),
60 const std::string robot_channel =
66 if (!gazebo::client::setup()) {
67 throw Exception(
"Failed to initialize Gazebo client");
72 gazebo_world_node_ = gazebo::transport::NodePtr(
new gazebo::transport::Node());
73 logger->
log_info(
name(),
"Initializing world node to namespace '%s'", world_name.c_str());
74 gazebo_world_node_->Init(world_name.c_str());
78 gazebonode_ = gazebo::transport::NodePtr(
new gazebo::transport::Node());
79 logger->
log_info(
name(),
"Initializing node to namespace '%s'", robot_channel.c_str());
80 gazebonode_->Init(robot_channel);
82 status_publisher_ = gazebonode_->Advertise<gazebo::msgs::Time>(
"~/heartbeat");
92 gazebo_world_node_->Fini();
93 gazebo_world_node_.reset();
100 gazebo::msgs::Time time;
101 status_publisher_->Publish(time);
GazeboNodeThread()
Constructor.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
virtual ~GazeboNodeThread()
Destructor.
virtual void finalize()
Finalize the thread.
Thread aspect provide a new aspect.
Thread aspect to use blocked timing.
Configuration * config
This is the Configuration member used to access the configuration.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
Base class for exceptions in Fawkes.
void set_gazebonode(gazebo::transport::NodePtr gazebonode)
Set the Gazebo node handle to use for aspect initialization.
void set_gazebo_world_node(gazebo::transport::NodePtr gazebo_world_node)
Set the Gazebo node handle to use for aspect initialization.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Logger * logger
This is the Logger member used to access the logger.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
Fawkes library namespace.