Skip to content

Commit b1ad95a

Browse files
yuokamotoweb-flow
authored andcommitted
make sensor component msg qos configurable from robot (#366)
* make sensor component msg qos configurable from robot * Update RRROS2OverlapSensorComponent.h update documentation
1 parent 830ff76 commit b1ad95a

10 files changed

+43
-17
lines changed

Source/RapyutaSimulationPlugins/Private/Robots/RRRobotROS2Interface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void URRRobotROS2Interface::InitInterfaces()
5151
URRUObjectUtils::CreateChildComponent<URRBaseOdomComponent>(Robot, *FString::Printf(TEXT("%sOdom"), *GetName()));
5252
OdomComponent->bPublishOdomTf = bPublishOdomTf;
5353
OdomComponent->PublicationFrequencyHz = OdomPublicationFrequencyHz;
54+
OdomComponent->QoS = OdomQoS;
5455
OdomComponent->RootOffset = Robot->RootOffset;
5556
}
5657
}

Source/RapyutaSimulationPlugins/Private/Sensors/RRBaseOdomComponent.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ URRBaseOdomComponent::URRBaseOdomComponent()
66
{
77
MsgClass = UROS2OdomMsg::StaticClass();
88
TopicName = TEXT("odom");
9+
QoS = UROS2QoS::SensorData;
910
PublicationFrequencyHz = 30;
1011
FrameId = TEXT("odom"); //default frame id
1112
SensorPublisherClass = URRROS2OdomPublisher::StaticClass();

Source/RapyutaSimulationPlugins/Private/Sensors/RRPoseSensorManager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ void URRPoseSensorManager::OnComponentCreated()
3131

3232
void URRPoseSensorManager::InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
3333
const FString& InPublisherName,
34-
const FString& InTopicName,
35-
const UROS2QoS InQoS)
34+
const FString& InTopicName)
3635
{
3736
UE_LOG_WITH_INFO_NAMED(LogRapyutaCore, Warning, TEXT("%s"), *ReferenceTag);
38-
Super::InitalizeWithROS2(InROS2Node, InPublisherName, InTopicName, InQoS);
37+
Super::InitalizeWithROS2(InROS2Node, InPublisherName, InTopicName);
3938
MapOriginPoseSensor->InitalizeWithROS2(InROS2Node);
4039
ServerSimState = CastChecked<ASimulationState>(UGameplayStatics::GetActorOfClass(GetWorld(), ASimulationState::StaticClass()));
4140
}

Source/RapyutaSimulationPlugins/Private/Sensors/RRROS2BaseSensorComponent.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ URRROS2BaseSensorComponent::URRROS2BaseSensorComponent()
1111

1212
void URRROS2BaseSensorComponent::InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
1313
const FString& InPublisherName,
14-
const FString& InTopicName,
15-
const UROS2QoS InQoS)
14+
const FString& InTopicName)
1615
{
1716
// NOTE: Here, [SensorPublisher] is expected to finish custom configuring before being added to [InROS2Node]'s Publishers and init.
1817
// Thus [UROS2NodeComponent::CreatePublisher()] is not used.
@@ -21,11 +20,19 @@ void URRROS2BaseSensorComponent::InitalizeWithROS2(UROS2NodeComponent* InROS2Nod
2120
CreatePublisher(InPublisherName);
2221
PreInitializePublisher(InROS2Node, InTopicName);
2322
// [SensorPublisher] is added to [InROS2Node]'s Publishers here-in
24-
InitializePublisher(InROS2Node, InQoS);
23+
InitializePublisher(InROS2Node, QoS);
2524

2625
// Start getting sensor data
2726
Run();
2827
}
28+
void URRROS2BaseSensorComponent::InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
29+
const FString& InPublisherName,
30+
const FString& InTopicName,
31+
const UROS2QoS InQoS)
32+
{
33+
QoS = InQoS;
34+
InitalizeWithROS2(InROS2Node, InPublisherName, InTopicName);
35+
}
2936

3037
void URRROS2BaseSensorComponent::CreatePublisher(const FString& InPublisherName)
3138
{

Source/RapyutaSimulationPlugins/Private/Sensors/RRROS2OverlapSensorComponent.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ URRROS2OverlapSensorComponent::URRROS2OverlapSensorComponent()
1818

1919
void URRROS2OverlapSensorComponent::InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
2020
const FString& InPublisherName,
21-
const FString& InTopicName,
22-
const UROS2QoS InQoS)
21+
const FString& InTopicName)
2322
{
24-
Super::InitalizeWithROS2(InROS2Node, InPublisherName, InTopicName, InQoS);
23+
Super::InitalizeWithROS2(InROS2Node, InPublisherName, InTopicName);
2524
EventPublisher =
2625
InROS2Node->CreatePublisher(EventTopicName, UROS2Publisher::StaticClass(), UROS2OverlapEventMsg::StaticClass());
2726
}

Source/RapyutaSimulationPlugins/Private/Tools/RRROS2OdomPublisher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
URRROS2OdomPublisher::URRROS2OdomPublisher()
1010
{
1111
MsgClass = UROS2OdomMsg::StaticClass();
12-
QoS = UROS2QoS::KeepLast;
12+
QoS = UROS2QoS::SensorData;
1313
SetDefaultDelegates(); //use UpdateMessage as update delegate
1414
}
1515

Source/RapyutaSimulationPlugins/Public/Robots/RRRobotROS2Interface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class RAPYUTASIMULATIONPLUGINS_API URRRobotROS2Interface : public URRBaseROS2Int
9797
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated)
9898
float OdomPublicationFrequencyHz = 30;
9999

100+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated)
101+
UROS2QoS OdomQoS = UROS2QoS::SensorData;
102+
103+
100104
//! Movement command topic. If empty is given, subscriber will not be initiated.
101105
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated)
102106
FString CmdVelTopicName = TEXT("cmd_vel");

Source/RapyutaSimulationPlugins/Public/Sensors/RRPoseSensorManager.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ class RAPYUTASIMULATIONPLUGINS_API URRPoseSensorManager : public URRROS2EntitySt
7070
*/
7171
virtual void InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
7272
const FString& InPublisherName = EMPTY_STR,
73-
const FString& InTopicName = EMPTY_STR,
74-
const UROS2QoS InQoS = UROS2QoS::SensorData) override;
73+
const FString& InTopicName = EMPTY_STR) override;
7574

7675
/**
7776
* @brief Calculate relative pose with #URRGeneralUtils and update #Data

Source/RapyutaSimulationPlugins/Public/Sensors/RRROS2BaseSensorComponent.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,25 @@ class RAPYUTASIMULATIONPLUGINS_API URRROS2BaseSensorComponent : public USceneCom
101101
* @sa [ROS 2 QoS](https://docs.ros.org/en/rolling/Concepts/About-Quality-of-Service-Settings.html)
102102
*/
103103
UFUNCTION(BlueprintCallable)
104+
virtual void InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
105+
const FString& InPublisherName,
106+
const FString& InTopicName,
107+
const UROS2QoS InQoS);
108+
109+
/**
110+
* @brief Create and initialize publisher and start sensor update by calling
111+
* #CreatePublisher, #PreInitializePublisher, #InitializePublisher and #Run with #QoS
112+
*
113+
* @param InROS2Node ROS2Node which this publisher belongs to
114+
* @param InPublisherName Publisher component name
115+
* @param InTopicName Topic name
116+
* *
117+
* @sa [UROS2NodeComponent](https://rclue.readthedocs.io/en/devel/doxygen_generated/html/d1/d79/_r_o_s2_node_component_8h.html)
118+
* @sa [ROS 2 QoS](https://docs.ros.org/en/rolling/Concepts/About-Quality-of-Service-Settings.html)
119+
*/
104120
virtual void InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
105121
const FString& InPublisherName = TEXT(""),
106-
const FString& InTopicName = TEXT(""),
107-
const UROS2QoS InQoS = UROS2QoS::SensorData);
122+
const FString& InTopicName = TEXT(""));
108123

109124
/**
110125
* @brief Create a Publisher with #SensorPublisherClass.
@@ -184,6 +199,9 @@ class RAPYUTASIMULATIONPLUGINS_API URRROS2BaseSensorComponent : public USceneCom
184199
UPROPERTY(EditAnywhere, BlueprintReadWrite)
185200
int32 PublicationFrequencyHz = 30;
186201

202+
UPROPERTY(EditAnywhere, BlueprintReadWrite)
203+
UROS2QoS QoS = UROS2QoS::SensorData;
204+
187205
//! Append namespace to #FrameId or not.
188206
UPROPERTY(EditAnywhere, BlueprintReadWrite)
189207
bool bAppendNodeNamespace = true;

Source/RapyutaSimulationPlugins/Public/Sensors/RRROS2OverlapSensorComponent.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ class RAPYUTASIMULATIONPLUGINS_API URRROS2OverlapSensorComponent : public URRROS
4343
* @param InROS2Node
4444
* @param InPublisherName
4545
* @param InTopicName
46-
* @param InQoS
4746
*/
4847
virtual void InitalizeWithROS2(UROS2NodeComponent* InROS2Node,
4948
const FString& InPublisherName = EMPTY_STR,
50-
const FString& InTopicName = EMPTY_STR,
51-
const UROS2QoS InQoS = UROS2QoS::SensorData) override;
49+
const FString& InTopicName = EMPTY_STR) override;
5250

5351
void BeginPlay() override;
5452

0 commit comments

Comments
 (0)