Skip to content

Commit f5b46d0

Browse files
committed
Add std_msgs/Int32 message support
1 parent a76c02c commit f5b46d0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "Conversion/Messages/std_msgs/StdMsgsInt32Converter.h"
2+
3+
4+
UStdMsgsInt32Converter::UStdMsgsInt32Converter()
5+
{
6+
_MessageType = "std_msgs/Int32";
7+
}
8+
9+
bool UStdMsgsInt32Converter::ConvertIncomingMessage(const ROSBridgePublishMsg* message, TSharedPtr<FROSBaseMsg> &BaseMsg) {
10+
bool KeyFound = false;
11+
12+
int32 Data = GetInt32FromBSON(TEXT("msg.data"), message->full_msg_bson_, KeyFound);
13+
if (!KeyFound) return false;
14+
15+
BaseMsg = TSharedPtr<FROSBaseMsg>(new ROSMessages::std_msgs::Int32(Data));
16+
return true;
17+
}
18+
19+
bool UStdMsgsInt32Converter::ConvertOutgoingMessage(TSharedPtr<FROSBaseMsg> BaseMsg, bson_t** message) {
20+
auto Int32Message = StaticCastSharedPtr<ROSMessages::std_msgs::Int32>(BaseMsg);
21+
*message = BCON_NEW(
22+
"data", BCON_INT32(Int32Message->_Data)
23+
);
24+
return true;
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include "CoreMinimal.h"
4+
#include "Conversion/Messages/BaseMessageConverter.h"
5+
#include "std_msgs/Int32.h"
6+
#include "StdMsgsInt32Converter.generated.h"
7+
8+
9+
UCLASS()
10+
class ROSINTEGRATION_API UStdMsgsInt32Converter: public UBaseMessageConverter
11+
{
12+
GENERATED_BODY()
13+
14+
public:
15+
UStdMsgsInt32Converter();
16+
virtual bool ConvertIncomingMessage(const ROSBridgePublishMsg* message, TSharedPtr<FROSBaseMsg> &BaseMsg);
17+
virtual bool ConvertOutgoingMessage(TSharedPtr<FROSBaseMsg> BaseMsg, bson_t** message);
18+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include "ROSBaseMsg.h"
4+
5+
namespace ROSMessages{
6+
namespace std_msgs {
7+
class Int32 : public FROSBaseMsg {
8+
public:
9+
Int32() : Int32(0.f) {}
10+
11+
Int32(float data) {
12+
_MessageType = "std_msgs/Int32";
13+
_Data = data;
14+
}
15+
16+
//private:
17+
int32 _Data;
18+
};
19+
}
20+
}

0 commit comments

Comments
 (0)