30 #ifndef EXOTICA_CORE_SERVER_H_ 31 #define EXOTICA_CORE_SERVER_H_ 49 RosNode(std::shared_ptr<ros::NodeHandle> nh,
int numThreads = 2);
55 std::shared_ptr<ros::NodeHandle>
nh_;
67 if (!singleton_server_) singleton_server_.reset(
new Server);
68 return singleton_server_;
75 bool HasModel(
const std::string &path);
80 void GetModel(
const std::string &path, robot_model::RobotModelPtr &model,
const std::string &
urdf =
"",
const std::string &
srdf =
"");
85 robot_model::RobotModelConstPtr GetModel(
const std::string &path,
const std::string &
urdf =
"",
const std::string &
srdf =
"");
89 std::string GetName();
91 inline static void InitRos(std::shared_ptr<ros::NodeHandle> nh,
int numThreads = 2)
93 Instance()->node_.reset(
new RosNode(nh, numThreads));
96 inline static bool IsRos() {
return Instance()->node_ !=
nullptr; }
99 if (!IsRos())
ThrowPretty(
"EXOTica server not initialized as ROS node!");
100 return Instance()->node_->GetNodeHandle();
103 template <
typename T>
104 static bool GetParam(
const std::string &name, T ¶m)
106 return Instance()->GetNodeHandle().getParam(name, param);
109 template <
typename T>
110 static void SetParam(
const std::string &name, T ¶m)
112 Instance()->GetNodeHandle().setParam(name, param);
115 inline bool static HasParam(
const std::string &name)
119 return Instance()->GetNodeHandle().hasParam(name);
127 template <
typename T,
typename... Args>
130 return Instance()->GetNodeHandle().advertise<T>(std::forward<Args>(
args)...);
133 template <
typename T,
typename... Args>
136 return Instance()->GetNodeHandle().subscribe<T>(std::forward<Args>(
args)...);
139 template <
typename T>
142 return Instance()->GetNodeHandle().serviceClient<T>(service_name, persistent);
147 if (!IsRos())
ThrowPretty(
"EXOTica server not initialized as ROS node!");
148 Instance()->node_->GetTF().sendTransform(transform);
151 static void SendTransform(
const std::vector<tf::StampedTransform> &transforms)
153 if (!IsRos())
ThrowPretty(
"EXOTica server not initialized as ROS node!");
154 Instance()->node_->GetTF().sendTransform(transforms);
159 if (!IsRos())
ThrowPretty(
"EXOTica server not initialized as ROS node!");
160 Instance()->node_->GetTF().sendTransform(transform);
163 static void SendTransform(
const std::vector<geometry_msgs::TransformStamped> &transforms)
165 if (!IsRos())
ThrowPretty(
"EXOTica server not initialized as ROS node!");
166 Instance()->node_->GetTF().sendTransform(transforms);
169 static void Destroy();
176 void operator=(
Server const &) =
delete;
177 robot_model::RobotModelPtr LoadModel(
const std::string &name,
const std::string &
urdf =
"",
const std::string &
srdf =
"");
191 #endif // EXOTICA_CORE_SERVER_H_ tf::TransformBroadcaster tf_
static void SendTransform(const geometry_msgs::TransformStamped &transform)
static bool GetParam(const std::string &name, T ¶m)
std::shared_ptr< ros::NodeHandle > nh_
static std::shared_ptr< Server > Instance()
Get the server.
static void InitRos(std::shared_ptr< ros::NodeHandle > nh, int numThreads=2)
std::map< std::string, robot_model::RobotModelPtr > robot_models_
Robot model cache.
static void SendTransform(const tf::StampedTransform &transform)
static void SendTransform(const std::vector< geometry_msgs::TransformStamped > &transforms)
static bool HasParam(const std::string &name)
static ros::Publisher Advertise(Args &&...args)
std::shared_ptr< RosNode > node_
static std::shared_ptr< Server > singleton_server_
static ros::ServiceClient ServiceClient(const std::string &service_name, bool persistent=false)
static void SendTransform(const std::vector< tf::StampedTransform > &transforms)
static void SetParam(const std::string &name, T ¶m)
static ros::Subscriber Subscribe(Args &&...args)
std::shared_ptr< Server > ServerPtr
ros::NodeHandle & GetNodeHandle()
static ros::NodeHandle & GetNodeHandle()
tf::TransformBroadcaster & GetTF()
std::string name_
The name of this server.