本文整理汇总了C++中ros::Publisher::getTopic方法的典型用法代码示例。如果您正苦于以下问题:C++ Publisher::getTopic方法的具体用法?C++ Publisher::getTopic怎么用?C++ Publisher::getTopic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ros::Publisher
的用法示例。
在下文中一共展示了Publisher::getTopic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendTUMComStringCommand
void TargetAggregation::sendTUMComStringCommand(const char* cmd, ros::Publisher& tumcompub)
{
std_msgs::String msg;
msg.data = cmd;
tumcompub.publish(msg);
ROS_INFO("send TUMCom command \"%s\" on topic %s", cmd, tumcompub.getTopic().c_str());
}
示例2: diagnostics
///\brief Publishes diagnostics and status
void diagnostics(diagnostic_updater::DiagnosticStatusWrapper& stat)
{
double now = ros::Time::now().toSec();
double interval = now - lastDiagTime_;
if (open_)
stat.summary(0, "OK");
else
stat.summary(2, "Joystick not open.");
stat.add("topic", pub_.getTopic());
stat.add("device", joy_dev_);
stat.add("dead zone", deadzone_);
stat.add("autorepeat rate (Hz)", autorepeat_rate_);
stat.add("coalesce interval (s)", coalesce_interval_);
stat.add("recent joystick event rate (Hz)", event_count_ / interval);
stat.add("recent publication rate (Hz)", pub_count_ / interval);
stat.add("subscribers", pub_.getNumSubscribers());
event_count_ = 0;
pub_count_ = 0;
lastDiagTime_ = now;
}
示例3: main
//.........这里部分代码省略.........
}
// Fail if there was a state space but it couldn't be loaded.
else if(hasAlternateStateSpace && !state_space->isInit())
{
ROS_ERROR_STREAM("Unable to load StateSpace from state_space_path \"" << state_space_path << "\"");
exit(EXIT_FAILURE);
}
// Push a simple state space to the param server.
else
{
shared_ptr<const SimpleFeatureSpace> simple_state_space
= boost::dynamic_pointer_cast<const SimpleFeatureSpace>(the_mdp->getStateSpace());
// Exists and is a SimpleFeatureSpace
if(simple_state_space)
{
XmlRpc::XmlRpcValue state_space_xml;
state_space_xml << *simple_state_space;
nh.setParam("state_space", state_space_xml);
}
}
// Push a simple action space to the param server.
{
shared_ptr<const SimpleFeatureSpace> simple_action_space
= boost::dynamic_pointer_cast<const SimpleFeatureSpace>(the_mdp->getActionSpace());
// Exists and is a SimpleFeatureSpace
if(simple_action_space)
{
XmlRpc::XmlRpcValue action_space_xml;
action_space_xml << *simple_action_space;
nh.setParam("action_space", action_space_xml);
}
}
// Debug print.
ROS_DEBUG_STREAM("Initial state: " << the_mdp->prettyState());
//
// Read policy file.
//
the_policy = PolicyFactory::loadFromFile<Policy>(policy_paths[0],
the_mdp->getStateSpace(), the_mdp->getActionSpace());
if(!the_policy)
{
ROS_ERROR("Unable to load Policy '%s'.", policy_paths[0].c_str());
exit(EXIT_FAILURE);
}
the_policy->setName(name);
//
// Associate POMDP with Policy.
//
if(!the_mdp->setMyPolicy(the_policy))
{
ROS_ERROR("Unable to associate policy '%s' and POMDP '%s'!",
the_policy->getName().c_str(), the_mdp->getName().c_str());
exit(EXIT_FAILURE);
}
//
// Determine initial action (set internally within POMDP).
//
int a = the_mdp->applyPolicy();
if(a == -1)
{
ROS_ERROR("Error applying policy '%s' to initial state of '%s'.", the_policy->getName().c_str(), the_mdp->getName().c_str());
exit(EXIT_FAILURE);
}
ROS_DEBUG_STREAM("Initial action: " << the_mdp->prettyAction(a));
//
// Advertise topics.
//
// Create names (default).
// action_pub_name = ros::this_node::getName() + "/" + DEFAULT_ACTION_TOPIC;
// obs_sub_name = ros::this_node::getName() + "/" + DEFAULT_OBSERVATION_TOPIC;
action_pub_name = DEFAULT_ACTION_TOPIC;
obs_sub_name = DEFAULT_OBSERVATION_TOPIC;
// Advertise.
action_pub = nh.advertise<pomdp_node::action>(action_pub_name, DEFAULT_ACTION_QUEUE);
if(!action_pub)
ROS_ERROR_STREAM("Unable to initialize topic " << action_pub);
else
ROS_INFO_STREAM("Ready to publish actions on " << action_pub.getTopic());
obs_sub = nh.subscribe(obs_sub_name, DEFAULT_OBSERVATION_QUEUE, observationCallback);
if(!obs_sub)
ROS_ERROR_STREAM("Unable to subscribe to " << obs_sub_name);
else
ROS_INFO_STREAM("Listening for observations on " << obs_sub.getTopic());
ros::spin();
return 0;
}