Go to the documentation of this file.
35 const auto inQueueSize =
params->getParam(
"in_queue_size", 10);
36 const auto outQueueSize =
params->getParam(
"out_queue_size", inQueueSize);
37 const auto lazy =
params->getParam(
"lazy",
false);
38 const auto tcpNoDelay =
params->getParam(
"tcp_no_delay",
false);
41 std::string inTopic =
"input";
42 std::string outTopic =
"output";
49 outTopic = (this->
getMyArgv().size() >= 2 ? this->
getMyArgv()[1] : (inTopic +
"_change_header"));
52 if (
params->hasParam(
"frame_id_prefix"))
55 if (
params->hasParam(
"frame_id_suffix"))
58 if (
params->hasParam(
"frame_id"))
61 if (
params->hasParam(
"frame_id_replace_start"))
63 const auto param =
params->getParam<std::string>(
"frame_id_replace_start", cras::nullopt);
65 const auto& from = parts[0];
66 const auto& to = parts.size() > 1 ? parts[1] :
"";
70 if (
params->hasParam(
"frame_id_replace_end"))
72 const auto param =
params->getParam<std::string>(
"frame_id_replace_end", cras::nullopt);
74 const auto& from = parts[0];
75 const auto& to = parts.size() > 1 ? parts[1] :
"";
79 if (
params->hasParam(
"frame_id_replace"))
81 const auto param =
params->getParam<std::string>(
"frame_id_replace", cras::nullopt);
83 const auto& from = parts[0];
84 const auto& to = parts.size() > 1 ? parts[1] :
"";
88 if (
params->hasParam(
"stamp_relative"))
91 if (
params->hasParam(
"stamp"))
100 this->
pubSub = std::make_unique<cras::GenericLazyPubSub>(nh, inTopic, outTopic, inQueueSize, outQueueSize,
104 this->
pubSub->setLazy(
false);
106 CRAS_INFO(
"Created%s header changer subscribing to %s and publishing to %s.",
107 (lazy ?
" lazy" :
""), nh.resolveName(inTopic).c_str(), nh.resolveName(outTopic).c_str());
113 const auto&
msg =
event.getConstMessage();
121 CRAS_ERROR(
"Running change_header on message type %s which does not have a header! Ignoring all messages.",
132 CRAS_ERROR(
"Change_header failed to extract a header from the message of type %s! "
136 const auto origHeader =
header.value();
172 header->stamp = {now.sec, now.nsec};
182 catch (const ::std::runtime_error&)
191 if (
header.value() == origHeader)
202 CRAS_ERROR(
"Change_header failed to modify the header of the message of type %s! "
bool hasHeader(const ::topic_tools::ShapeShifter &msg)
Tell whether the given message has header field.
Tools for more convenient working with ShapeShifter objects.
::cras::BoundParamHelperPtr privateParams(const ::std::string &ns="") const
TransportHints transport_hints
ros::NodeHandle & getMTPrivateNodeHandle() const
bool allow_concurrent_callbacks
const V_string & getMyArgv() const
void publish(const boost::shared_ptr< M > &message) const
TransportHints & tcpNoDelay(bool nodelay=true)
Lazy subscriber that subscribes only when a paired publisher has subscribers. Version for unknown mes...
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void replace(::std::string &str, const ::std::string &from, const ::std::string &to, const ::cras::ReplacePosition &where=::cras::ReplacePosition::EVERYWHERE)
const Time TIME_MIN(0, 1)
::std::vector<::std::string > split(const ::std::string &str, const ::std::string &delimiter, int maxSplits=-1)
void copyShapeShifter(const ::topic_tools::ShapeShifter &in, ::topic_tools::ShapeShifter &out)
Copy in ShapeShifter to out.
auto bind_front(F &&f, Args &&... args)
const ROSTIME_DECL Time TIME_MAX
::cras::BoundParamHelperPtr params(const ::ros::NodeHandle &node, const ::std::string &ns="") const
T param(const std::string ¶m_name, const T &default_val)
M_string & getConnectionHeader() const
::cras::optional<::std_msgs::Header > getHeader(const ::topic_tools::ShapeShifter &msg)
Get the header field of the given message, if it has any.
ros::NodeHandle & getMTNodeHandle() const
bool setHeader(::topic_tools::ShapeShifter &msg, ::std_msgs::Header &header)
Change the header field of the given message, if it has any.
cras_topic_tools
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:18