mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-26 01:17:51 +08:00
microRTPS bridge: fix templates for ROS2 usage
This commit is contained in:
@@ -97,8 +97,12 @@ bool @(topic)_Subscriber::init()
|
||||
@[else]@
|
||||
Rparam.topic.topicName = "@(topic)PubSubTopic";
|
||||
@[end if]@
|
||||
@[if ros2_distro and ros2_distro != "ardent"]@
|
||||
Rparam.topic.topicName = "rt/" + Wparam.topic.topicName;
|
||||
@[if ros2_distro]@
|
||||
@[ if ros2_distro == "ardent"]@
|
||||
Rparam.qos.m_partition.push_back("rt");
|
||||
@[ else]@
|
||||
Rparam.topic.topicName = "rt/" + Rparam.topic.topicName;
|
||||
@[ end if]@
|
||||
@[end if]@
|
||||
mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, static_cast<SubscriberListener*>(&m_listener));
|
||||
if(mp_subscriber == nullptr)
|
||||
@@ -126,9 +130,17 @@ void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber* sub)
|
||||
{
|
||||
// Take data
|
||||
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
|
||||
@[ if ros2_distro]@
|
||||
@(package)::msg::dds_::@(topic)_ st;
|
||||
@[ else]@
|
||||
@(topic)_ st;
|
||||
@[ end if]@
|
||||
@[else]@
|
||||
@[ if ros2_distro]@
|
||||
@(package)::msg::@(topic) st;
|
||||
@[ else]@
|
||||
@(topic) st;
|
||||
@[ end if]@
|
||||
@[end if]@
|
||||
|
||||
if(sub->takeNextData(&st, &m_info))
|
||||
@@ -157,9 +169,17 @@ bool @(topic)_Subscriber::hasMsg()
|
||||
}
|
||||
|
||||
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
|
||||
@[ if ros2_distro]@
|
||||
@(package)::msg::dds_::@(topic)_ @(topic)_Subscriber::getMsg()
|
||||
@[ else]@
|
||||
@(topic)_ @(topic)_Subscriber::getMsg()
|
||||
@[ end if]@
|
||||
@[else]@
|
||||
@[ if ros2_distro]@
|
||||
@(package)::msg::@(topic) @(topic)_Subscriber::getMsg()
|
||||
@[ else]@
|
||||
@(topic) @(topic)_Subscriber::getMsg()
|
||||
@[ end if]@
|
||||
@[end if]@
|
||||
{
|
||||
m_listener.has_msg = false;
|
||||
|
||||
Reference in New Issue
Block a user