mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 02:53:34 +08:00
fastrtps: clean up and fix template for client/agent code
This commit is contained in:
@@ -48,7 +48,7 @@ topic = spec.short_name
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* @@file @(topic)_Subscriber.cpp
|
||||
* This file contains the implementation of the subscriber functions.
|
||||
*
|
||||
@@ -72,26 +72,26 @@ topic = spec.short_name
|
||||
bool @(topic)_Subscriber::init()
|
||||
{
|
||||
// Create RTPSParticipant
|
||||
|
||||
|
||||
ParticipantAttributes PParam;
|
||||
PParam.rtps.builtin.domainId = 0; //MUST BE THE SAME AS IN THE PUBLISHER
|
||||
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
|
||||
PParam.rtps.setName("Participant_subscriber"); //You can put the name you want
|
||||
PParam.rtps.setName("@(topic)_subscriber"); //You can put the name you want
|
||||
mp_participant = Domain::createParticipant(PParam);
|
||||
if(mp_participant == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
//Register the type
|
||||
|
||||
Domain::registerType(mp_participant,(TopicDataType*) &myType);
|
||||
|
||||
|
||||
Domain::registerType(mp_participant, (TopicDataType*) &myType);
|
||||
|
||||
// Create Subscriber
|
||||
|
||||
|
||||
SubscriberAttributes Rparam;
|
||||
Rparam.topic.topicKind = NO_KEY;
|
||||
Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
|
||||
Rparam.topic.topicName = "@(topic)_PubSubTopic";
|
||||
mp_subscriber = Domain::createSubscriber(mp_participant,Rparam,(SubscriberListener*)&m_listener);
|
||||
Rparam.topic.topicName = "@(topic)";
|
||||
mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, (SubscriberListener*) &m_listener);
|
||||
if(mp_subscriber == nullptr)
|
||||
return false;
|
||||
return true;
|
||||
@@ -143,4 +143,4 @@ bool @(topic)_Subscriber::hasMsg()
|
||||
{
|
||||
m_listener.has_msg = false;
|
||||
return m_listener.msg;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user