File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
Private/Conversion/Messages/std_msgs Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ };
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments