├── .gitignore ├── README.md ├── Resources ├── Icon128.png ├── add_component.png ├── connect.png ├── publish.png └── subscribe.png ├── Source ├── ThirdParty │ └── json.hpp └── UnrealROS │ ├── Private │ ├── UnrealROS.cpp │ └── rosbridge.cpp │ ├── Public │ ├── RosMessageBase.h │ ├── UnrealROS.h │ ├── avl_msgs │ │ └── VehicleStateMsg.h │ ├── geometry_msgs │ │ └── Vector3Msg.h │ ├── rosbridge.h │ ├── sensor_msgs │ │ └── JoyMsg.h │ └── std_msgs │ │ ├── BoolMsg.h │ │ ├── ByteMsg.h │ │ ├── ByteMultiArrayMsg.h │ │ ├── CharMsg.h │ │ ├── ColorRGBAMsg.h │ │ ├── DurationMsg.h │ │ ├── EmptyMsg.h │ │ ├── Float32Msg.h │ │ ├── Float32MultiArrayMsg.h │ │ ├── Float64Msg.h │ │ ├── Float64MultiArrayMsg.h │ │ ├── HeaderMsg.h │ │ ├── Int16Msg.h │ │ ├── Int16MultiArrayMsg.h │ │ ├── Int32Msg.h │ │ ├── Int32MultiArrayMsg.h │ │ ├── Int64Msg.h │ │ ├── Int64MultiArrayMsg.h │ │ ├── Int8Msg.h │ │ ├── Int8MultiArrayMsg.h │ │ ├── MultiArrayDimensionMsg.h │ │ ├── MultiArrayLayoutMsg.h │ │ ├── StringMsg.h │ │ ├── TimeMsg.h │ │ ├── UInt16Msg.h │ │ ├── UInt16MultiArrayMsg.h │ │ ├── UInt32Msg.h │ │ ├── UInt32MultiArrayMsg.h │ │ ├── UInt64Msg.h │ │ ├── UInt64MultiArrayMsg.h │ │ ├── UInt8Msg.h │ │ └── UInt8MultiArrayMsg.h │ └── UnrealROS.Build.cs └── UnrealROS.uplugin /.gitignore: -------------------------------------------------------------------------------- 1 | Binaries/ 2 | Intermediate/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnrealROS 2 | UnrealROS ia an Unreal Engine plugin that provides a ROS message publish/subscribe interface over TCP by interfacing with ROS's [rosbridge](http://wiki.ros.org/rosbridge_suite) package. The plugin provides rosbridge functionality by providing a rosbridge ActorComponent that can be attached to an actor. The component provides the following blueprint functions: 3 | - **Connect**: Connects to the remote rosbridge instance. 4 | - **Advertise**: Advertises a topic to be published by the plugin. 5 | - **Unadvertise**: Unadvertises a topic that will no longer be published b ythe plugin. 6 | - **Publish**: Publishes a message to a topic that has already been advertised. 7 | - **Subscribe**: Subscribes to a topic that has been advertised. 8 | - **Unsubscribe**: Unsubscribes from a topic. 9 | 10 | # Installation 11 | To install this plugin into an Unreal Engine project follow these steps: 12 | 13 | 1. Navigate to an Unreal Engine project folder that contains the `.uproject` folder. 14 | 2. Create a `Plugins` folder if it does not already exist. 15 | 3. Clone this repository into the `Plugins` folder. 16 | 17 | Launch the project. You should be prompted to re-compile the project which should complete successfully. The plugin is now ready to use in the Unreal Engine editor. 18 | 19 | # Usage 20 | To use the rosbridge actor component, create or edit an Actor blueprint. In the Actor's editing window, press `Add Component` and select the `Rosbridge` component as shown in the below image. 21 | 22 |

23 | 24 |

25 | 26 | The component must first be connected to a remote rosbridge session. See [rosbridge](http://wiki.ros.org/rosbridge_suite) documentation on how to launch rosbridge. The image below shows the rosbridge component being connected to rosbridge running on a computer with IP address `192.168.1.10` on port `9090`. 27 | 28 |

29 | 30 |

31 | 32 | After being connected, the rosbridge component can be used for publish/scubscribe functionality. 33 | 34 | ## Publish 35 | To publish a message, the following steps must be followed: 36 | 37 | 1. If the topic has not been advertised yet, advertise the topic. 38 | 2. Construct an instance of a message class. 39 | 3. Set the contents of the message. 40 | 4. Publish the message. 41 | 42 | These steps are shown in the image below. 43 | 44 |

45 | 46 |

47 | 48 | This will publish the message over rosbirgde into the ROS system. 49 | 50 | ## Subscribe 51 | To subscribe to a message, use the following process: 52 | 53 | 1. Subscribe to the topic and specify a callback event. 54 | 2. In the callback event, cast the base message to the expected message type. 55 | 3. Get the contents of the message from the casted message. 56 | 4. Use the message contents in any way desired. 57 | 58 | The following image illustrates the subscription process: 59 | 60 |

61 | 62 |

63 | 64 | Whenever a message is published to the topic that is being subscribed to, the callback event will be triggered and the message will be passed to the `Message` pin. This message is a RosMessageBase type and must be cast to the expected message type in order to get the message contents correctly. 65 | -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbyssRobotics/UnrealROS/7972ac87e3d373c63769d06b607bb21aaf807d8c/Resources/Icon128.png -------------------------------------------------------------------------------- /Resources/add_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbyssRobotics/UnrealROS/7972ac87e3d373c63769d06b607bb21aaf807d8c/Resources/add_component.png -------------------------------------------------------------------------------- /Resources/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbyssRobotics/UnrealROS/7972ac87e3d373c63769d06b607bb21aaf807d8c/Resources/connect.png -------------------------------------------------------------------------------- /Resources/publish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbyssRobotics/UnrealROS/7972ac87e3d373c63769d06b607bb21aaf807d8c/Resources/publish.png -------------------------------------------------------------------------------- /Resources/subscribe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbyssRobotics/UnrealROS/7972ac87e3d373c63769d06b607bb21aaf807d8c/Resources/subscribe.png -------------------------------------------------------------------------------- /Source/UnrealROS/Private/UnrealROS.cpp: -------------------------------------------------------------------------------- 1 | #include "UnrealROS.h" 2 | 3 | #define LOCTEXT_NAMESPACE "FUnrealROSModule" 4 | 5 | void FUnrealROSModule::StartupModule() 6 | { 7 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 8 | 9 | } 10 | 11 | void FUnrealROSModule::ShutdownModule() 12 | { 13 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 14 | // we call this function before unloading the module. 15 | 16 | } 17 | 18 | #undef LOCTEXT_NAMESPACE 19 | 20 | IMPLEMENT_MODULE(FUnrealROSModule, UnrealROS) 21 | -------------------------------------------------------------------------------- /Source/UnrealROS/Private/rosbridge.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Provides the base rosbridge functionality. Provides blueprint 5 | // callable functions to connect to a rosbridge server, and publish 6 | // and subscribe to ROS topics through the rosbridge API. 7 | //============================================================================== 8 | 9 | #include "rosbridge.h" 10 | 11 | // AddOnScreenDebugMessage function 12 | #include "Engine.h" 13 | 14 | // Stringstream for JSON parsing 15 | #include 16 | 17 | //============================================================================== 18 | // CLASS DEFINITION 19 | //============================================================================== 20 | 21 | //------------------------------------------------------------------------------ 22 | // Name: URosbridge constructor 23 | // Description: Default constructor. 24 | //------------------------------------------------------------------------------ 25 | URosbridge::URosbridge() 26 | { 27 | 28 | // Enable ticks 29 | PrimaryComponentTick.bCanEverTick = true; 30 | PrimaryComponentTick.bStartWithTickEnabled = true; 31 | 32 | } 33 | 34 | //-------------------------------------------------------------------------- 35 | // Name: connect 36 | // Description: Connects to a rosbridge server. 37 | // Arguments: - address: rosbridge server address 38 | // - port: rosbridge server port 39 | //-------------------------------------------------------------------------- 40 | void URosbridge::connect(FString address, int port) 41 | { 42 | 43 | // Configure the IPv4 address that the socket will connect to 44 | TSharedRef internet_address = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr(); 45 | bool address_valid; 46 | internet_address->SetIp(*address, address_valid); 47 | internet_address->SetPort(port); 48 | 49 | // Ensure that the address is valid 50 | if (!address_valid) 51 | { 52 | print(FColor::Red, FString::Printf(TEXT("connect: invalid address"))); 53 | return; 54 | } 55 | 56 | // Attempt to connect the socket to the address 57 | if (tcp_socket->Connect(*internet_address)) 58 | { 59 | socket_connected = true; 60 | print(FColor::Green, TEXT("socket connected")); 61 | } 62 | else 63 | { 64 | socket_connected = false; 65 | print(FColor::Red, TEXT("socket connection failed")); 66 | } 67 | 68 | 69 | } 70 | 71 | //------------------------------------------------------------------------------ 72 | // Name: advertise 73 | // Description: Advertises that a ROS topic will be published. 74 | // Arguments: - topic: topic name 75 | // - type: message type 76 | //------------------------------------------------------------------------------ 77 | void URosbridge::advertise(FString topic, FString type) 78 | { 79 | 80 | // Ensure the TCP socket is connected 81 | if (!socket_connected) 82 | { 83 | print(FColor::Red, FString::Printf(TEXT("advertise: rosbridge is not connected"))); 84 | return; 85 | } 86 | 87 | // Ensure that the type is valid 88 | if (message_type_map.find(type) == message_type_map.end()) 89 | { 90 | print(FColor::Red, FString::Printf(TEXT("advertise: unknown message type (%s)"), *type)); 91 | return; 92 | } 93 | 94 | // Assemble the JSON object 95 | json json_message; 96 | json_message["op"] = "advertise"; 97 | json_message["topic"] = std::string(TCHAR_TO_UTF8(*topic)); 98 | json_message["type"] = std::string(TCHAR_TO_UTF8(*type)); 99 | 100 | // Convert the JSON object to an array of bytes 101 | std::string json_string = json_message.dump(); 102 | int32 num_bytes = json_string.length(); 103 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 104 | 105 | // Send the message 106 | int32 num_bytes_sent; 107 | if (!(tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent))) 108 | print(FColor::Red, TEXT("advertise failed")); 109 | 110 | } 111 | 112 | //------------------------------------------------------------------------------ 113 | // Name: unadvertise 114 | // Description: Stops advertising that a ROS topic will be published. 115 | // Arguments: - topic: topic name 116 | //------------------------------------------------------------------------------ 117 | void URosbridge::unadvertise(FString topic) 118 | { 119 | 120 | // Ensure the TCP socket is connected 121 | if (!socket_connected) 122 | { 123 | print(FColor::Red, FString::Printf(TEXT("unadvertise: rosbridge is not connected"))); 124 | return; 125 | } 126 | 127 | // Assemble the JSON object 128 | json json_message; 129 | json_message["op"] = "unadvertise"; 130 | json_message["topic"] = std::string(TCHAR_TO_UTF8(*topic)); 131 | 132 | // Convert the JSON object to an array of bytes 133 | std::string json_string = json_message.dump(); 134 | int32 num_bytes = json_string.length(); 135 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 136 | 137 | // Send the message 138 | int32 num_bytes_sent; 139 | if (!(tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent))) 140 | print(FColor::Red, TEXT("unadvertise failed")); 141 | 142 | } 143 | 144 | //------------------------------------------------------------------------------ 145 | // Name: publish 146 | // Description: Publishes to a ROS topic. 147 | // Arguments: - topic: topic name 148 | // - type: message type 149 | //------------------------------------------------------------------------------ 150 | void URosbridge::publish(FString topic, UPARAM(ref) URosMessageBase* message) 151 | { 152 | 153 | // Ensure that there is a message connected 154 | if (message == nullptr) 155 | { 156 | print(FColor::Red, FString::Printf(TEXT("publish: a message to publish must be specified"))); 157 | return; 158 | } 159 | 160 | // Ensure the TCP socket is connected 161 | if (!socket_connected) 162 | { 163 | print(FColor::Red, FString::Printf(TEXT("publish: rosbridge is not connected"))); 164 | return; 165 | } 166 | 167 | // Assemble the JSON object 168 | json json_message; 169 | json_message["op"] = "publish"; 170 | json_message["topic"] = std::string(TCHAR_TO_UTF8(*topic)); 171 | 172 | try 173 | { 174 | json_message["msg"] = message->get_json(); 175 | } 176 | catch (...) 177 | { 178 | print(FColor::Red, FString::Printf(TEXT("publish: unable to convert message to JSON (%s)"), *(message->type))); 179 | return; 180 | } 181 | 182 | //std::string s = message->get_json().dump(); 183 | //print(FColor::Green, FString(s.c_str())); 184 | 185 | // Convert the JSON object to an array of bytes 186 | std::string json_string = json_message.dump(); 187 | int32 num_bytes = json_string.length(); 188 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 189 | 190 | // Send the message 191 | int32 num_bytes_sent; 192 | if (!(tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent))) 193 | print(FColor::Red, TEXT("publish failed")); 194 | 195 | } 196 | 197 | //------------------------------------------------------------------------------ 198 | // Name: subscribe 199 | // Description: Subscribes to a ROS topic. 200 | // Arguments: - topic: topic name 201 | // - message_type: message type 202 | // - callback: callback to be called when a message arrives on 203 | // the topic 204 | //------------------------------------------------------------------------------ 205 | void URosbridge::subscribe(FString topic, TSubclassOf message_type, 206 | const FMessageReceivedCallback& callback) 207 | { 208 | 209 | // Ensure the message type is selected 210 | if (message_type == NULL) 211 | { 212 | print(FColor::Red, FString::Printf(TEXT("subscribe: message type must be selected"))); 213 | return; 214 | } 215 | 216 | // Ensure the TCP socket is connected 217 | if (!socket_connected) 218 | { 219 | print(FColor::Red, FString::Printf(TEXT("subscribe: rosbridge is not connected"))); 220 | return; 221 | } 222 | 223 | // Create an instance of the class in order to get the type string 224 | URosMessageBase* message_instance = NewObject(this, message_type); 225 | FString type_string = message_instance->type; 226 | 227 | // Add the subscription to the mapping between the topic name and the topic's 228 | // message received callback 229 | subscription_callback_map[topic] = callback; 230 | 231 | // Assemble the rosbridge JSON object to subscribe 232 | json json_message; 233 | json_message["op"] = "subscribe"; 234 | json_message["topic"] = std::string(TCHAR_TO_UTF8(*topic)); 235 | json_message["type"] = std::string(TCHAR_TO_UTF8(*type_string)); 236 | 237 | // Convert the JSON object to an array of bytes to be sent over TCP 238 | std::string json_string = json_message.dump(); 239 | int32 num_bytes = json_string.length(); 240 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 241 | 242 | // Send the subscribe message bytes with the TCP socket 243 | int32 num_bytes_sent; 244 | if (tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent)) 245 | { 246 | subscription_map[topic] = type_string; 247 | print(FColor::Green, TEXT("subscribe succeeded")); 248 | } 249 | else 250 | { 251 | print(FColor::Red, TEXT("subscribe failed")); 252 | } 253 | 254 | } 255 | 256 | //------------------------------------------------------------------------------ 257 | // Name: unsubscribe 258 | // Description: Unsubscribes from a ROS topic. 259 | // Arguments: - topic: topic name 260 | //------------------------------------------------------------------------------ 261 | void URosbridge::unsubscribe(FString topic) 262 | { 263 | 264 | // Ensure the TCP socket is connected 265 | if (!socket_connected) 266 | { 267 | print(FColor::Red, FString::Printf(TEXT("unsubscribe: rosbridge is not connected"))); 268 | return; 269 | } 270 | 271 | // Assemble the JSON object 272 | json json_message; 273 | json_message["op"] = "unsubscribe"; 274 | json_message["topic"] = std::string(TCHAR_TO_UTF8(*topic)); 275 | 276 | // Convert the JSON object to an array of bytes 277 | std::string json_string = json_message.dump(); 278 | int32 num_bytes = json_string.length(); 279 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 280 | 281 | // Send the message 282 | int32 num_bytes_sent; 283 | if (tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent)) 284 | print(FColor::Green, TEXT("unsubscribe succeeded")); 285 | else 286 | print(FColor::Red, TEXT("unsubscribe failed")); 287 | 288 | } 289 | 290 | //------------------------------------------------------------------------------ 291 | // Name: set_level 292 | // Description: Sets the status message level on the rosbridge server. 293 | // Arguments: - level: status_message_level 294 | //------------------------------------------------------------------------------ 295 | void URosbridge::set_level(FString level) 296 | { 297 | 298 | // Ensure the TCP socket is connected 299 | if (!socket_connected) 300 | { 301 | print(FColor::Red, FString::Printf(TEXT("set_level: rosbridge is not connected"))); 302 | return; 303 | } 304 | 305 | // Assemble the JSON object for a topic subscribe message 306 | json json_message; 307 | json_message["op"] = "set_level"; 308 | json_message["level"] = std::string(TCHAR_TO_UTF8(*level)); 309 | 310 | // Convert the JSON object to an array of bytes 311 | std::string json_string = json_message.dump(); 312 | int32 num_bytes = json_string.length(); 313 | const uint8* json_bytes = reinterpret_cast(json_string.c_str()); 314 | 315 | // Send the subscribe message 316 | int32 num_bytes_sent; 317 | if (tcp_socket->Send(json_bytes, num_bytes, num_bytes_sent)) 318 | print(FColor::Green, TEXT("set_level succeeded")); 319 | else 320 | print(FColor::Red, TEXT("set_level failed")); 321 | 322 | } 323 | 324 | //------------------------------------------------------------------------------ 325 | // Name: BeginPlay 326 | // Description: Called when the game starts or when spawned. Override of 327 | // AActor::BeginPlay. 328 | //------------------------------------------------------------------------------ 329 | void URosbridge::BeginPlay() 330 | { 331 | 332 | Super::BeginPlay(); 333 | 334 | // Create a socket 335 | tcp_socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket("tcp_socket", TEXT("default"), false); 336 | 337 | // Find all subclasses of the ROS message base class 338 | TArray< TAssetSubclassOf > subclass_list; 339 | for (TObjectIterator it; it; ++it) 340 | if (it->IsChildOf(URosMessageBase::StaticClass()) && !it->HasAnyClassFlags(CLASS_Abstract)) 341 | subclass_list.Add(*it); 342 | 343 | // Populate the map between message type string and UClass using the list 344 | // of objects inheriting the ROS message base class 345 | for (TAssetSubclassOf type : subclass_list) 346 | { 347 | 348 | // Get the UClass of the subclass and create an instance of it. 349 | UClass* message_class = type.Get(); 350 | URosMessageBase* message_instance = NewObject(this, message_class); 351 | 352 | // Use the message instance to get the type string and add it to the 353 | // type string to UClass map 354 | FString message_type = message_instance->type; 355 | message_type_map[message_type] = message_class; 356 | 357 | // print(FColor::Turquoise, message_type); 358 | 359 | } 360 | 361 | } 362 | 363 | //------------------------------------------------------------------------------ 364 | // Name: Tick 365 | // Description: Called every game tick. Override of AActor::Tick. 366 | // Arguments: - DeltaTime: time since last tick in seconds 367 | //------------------------------------------------------------------------------ 368 | void URosbridge::TickComponent(float DeltaTime, enum ELevelTick TickType, 369 | FActorComponentTickFunction *ThisTickFunction) 370 | { 371 | 372 | // Check whether there is data ready to be read in the receive buffer 373 | uint32 num_pending_bytes; 374 | if (tcp_socket->HasPendingData(num_pending_bytes)) 375 | { 376 | 377 | // Initialize the received data buffer to hold the number of pending bytes 378 | TArray received_data; 379 | received_data.Init(0, FMath::Min(num_pending_bytes, 65507u)); 380 | 381 | // Receive the data from the socket 382 | int32 num_bytes_read; 383 | tcp_socket->Recv(received_data.GetData(), received_data.Num(), num_bytes_read); 384 | 385 | // Convert the received data buffer into a std::string and add it to the 386 | // receive buffer for processing 387 | received_data.Add(0); 388 | FString received_fstring = FString(ANSI_TO_TCHAR(reinterpret_cast(received_data.GetData()))); 389 | std::string received_string(TCHAR_TO_UTF8(*received_fstring)); 390 | 391 | //std::string received_string((char*)received_data.GetData()); 392 | receive_buffer += received_string; 393 | 394 | // Assume the received buffer can contain more than one JSON object with 395 | // random characters between them. We must loop through the receive 396 | // buffer and extract every JSON object by locating the opening bracket 397 | // and closing bracket. Since there may be brackets in between, we must 398 | // keep track of the number of opened brackets and find when the last one 399 | // has been closed to find the end of the JSON object 400 | size_t json_start_pos = std::string::npos; 401 | size_t json_stop_pos = std::string::npos; 402 | std::string json_string; 403 | 404 | // Locate the first opening bracket in the receive buffer, 405 | // indicating the start of the JSON object. Repeat for every 406 | // JSON object in the receive buffer 407 | json_start_pos = receive_buffer.find_first_of('{'); 408 | while (json_start_pos != std::string::npos) 409 | { 410 | 411 | // Find the last closing bracket that closes the first 412 | // opening bracket by keeping a count of how many brackets 413 | // are left open 414 | json_stop_pos = std::string::npos; 415 | size_t num_open_brackets = 1; 416 | for (size_t i = json_start_pos + 1; i < receive_buffer.length(); i++) 417 | { 418 | if (receive_buffer[i] == '{') 419 | num_open_brackets++; 420 | if (receive_buffer[i] == '}') 421 | num_open_brackets--; 422 | if (num_open_brackets == 0) 423 | { 424 | json_stop_pos = i; 425 | break; 426 | } 427 | } 428 | 429 | // If there is an unbalanced number of brackets, move on 430 | // and do not parse the JSON object since it is incomplete 431 | if (json_stop_pos == std::string::npos) 432 | return; 433 | 434 | // Extract the JSON object string between the open and close brackets 435 | // and parse it into a JSON object to be handled 436 | json_string = receive_buffer.substr(json_start_pos, json_stop_pos - json_start_pos + 1); 437 | 438 | try 439 | { 440 | nlohmann::json json_message = nlohmann::json::parse(json_string); 441 | handle_received_json(json_message); 442 | } 443 | catch (const std::exception & ex) 444 | { 445 | FString reason(ex.what()); 446 | FString buffer_string(json_string.c_str()); 447 | print(FColor::Yellow, FString::Printf(TEXT("failed to parse received JSON string %d %d (%s)"), json_start_pos, json_stop_pos, *buffer_string)); 448 | } 449 | 450 | // Remove the parts that have been parsed from the receive buffer and 451 | // find the start of the next JSON object in the received string if there 452 | // is one 453 | receive_buffer.erase(0, json_stop_pos + 1); 454 | json_start_pos = receive_buffer.find_first_of('{'); 455 | 456 | } 457 | 458 | } 459 | 460 | } 461 | 462 | //------------------------------------------------------------------------------ 463 | // Name: EndPlay 464 | // Description: Called when the game ends. Override of AActor::EndPlay. 465 | // Arguments: - EndPlayReason: reason for play ending 466 | //------------------------------------------------------------------------------ 467 | void URosbridge::EndPlay(const EEndPlayReason::Type EndPlayReason) 468 | { 469 | tcp_socket->Close(); 470 | } 471 | 472 | //------------------------------------------------------------------------------ 473 | // Name: handle_received_json 474 | // Description: Handles a JSON message received over TCP. 475 | // Arguments: - json_message: JSON message to be handles 476 | //------------------------------------------------------------------------------ 477 | void URosbridge::handle_received_json(nlohmann::json json_message) 478 | { 479 | 480 | try 481 | { 482 | 483 | // Parse the JSON message based on the operation tag 484 | std::string operation = json_message["op"]; 485 | 486 | // Status messages contain messages about successes and failures of 487 | // commands sent to the server 488 | if (operation == "status") 489 | { 490 | print(FColor::Green, TEXT("operation: status")); 491 | } 492 | 493 | // Publish messages contain a ROS message sent by the server when this 494 | // client is subscribed to a topic 495 | else if (operation == "publish") 496 | { 497 | 498 | // Extract the topic name from the message 499 | std::string topic_string = json_message["topic"]; 500 | FString topic = FString(topic_string.c_str()); 501 | 502 | // Use the topic name to find the corresponding message type in 503 | // the subscriptions 504 | FString message_type = subscription_map[topic]; 505 | 506 | // Get the UClass associated with the message type 507 | UClass* message_class = message_type_map[message_type]; 508 | 509 | // Construct an instance of the message class and load its data 510 | // from the JSON message. 511 | URosMessageBase* ros_message = NewObject(this, message_class); 512 | ros_message->from_json(json_message["msg"]); 513 | 514 | // Broadcast the message received event 515 | subscription_callback_map[topic].Execute(ros_message); 516 | 517 | } 518 | 519 | // Service response messages contain a ROS service response sent by the 520 | // server when this client calls a service 521 | else if (operation == "service_response") 522 | { 523 | print(FColor::Green, TEXT("operation: service_response")); 524 | } 525 | 526 | // All other operations can be ignored since they are either invalid or 527 | // are not sent to the client by the server 528 | else 529 | { 530 | print(FColor::Yellow, FString::Printf(TEXT("ignoring operation (%s)"), *FString(operation.c_str()))); 531 | } 532 | 533 | } 534 | catch (const std::exception& ex) 535 | { 536 | FString reason(ex.what()); 537 | std::string json_string = json_message.dump(); 538 | FString json_fstring = FString(json_string.c_str()); 539 | print(FColor::Yellow, FString::Printf(TEXT("handle_received_json: failed to parse JSON message (%s)(%s)"), *reason, *json_fstring)); 540 | } 541 | 542 | } 543 | 544 | //------------------------------------------------------------------------------ 545 | // Name: handle_received_json 546 | // Description: Handles a JSON message received over TCP. 547 | // Arguments: - json_message: JSON message to be handles 548 | //------------------------------------------------------------------------------ 549 | void URosbridge::print(FColor color, FString message) 550 | { 551 | GEngine->AddOnScreenDebugMessage(-1, 15.0f, color, *message); 552 | } 553 | 554 | //------------------------------------------------------------------------------ 555 | // Name: json_to_bytes 556 | // Description: Converts a JSON object to an array of uint8 bytes. 557 | // Arguments: - json: JSON object to be converted 558 | // - num_bytes: number of bytes in resulting byte array 559 | // Returns: Array of bytes representing the JSON object. 560 | //------------------------------------------------------------------------------ 561 | const uint8* URosbridge::json_to_bytes(json json, int32& num_bytes) 562 | { 563 | 564 | std::string json_string = json.dump(); 565 | num_bytes = json_string.length(); 566 | const uint8* byte_array = reinterpret_cast(json_string.c_str()); 567 | return byte_array; 568 | 569 | } 570 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/RosMessageBase.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines a base ROS message and its interface with JSON. 5 | //============================================================================== 6 | #pragma once 7 | 8 | // JSON parsing 9 | #include "ThirdParty/json.hpp" 10 | using namespace nlohmann; 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "UObject/NoExportTypes.h" 15 | #include "RosMessageBase.generated.h" 16 | 17 | //============================================================================== 18 | // CLASS DECLARATION 19 | //============================================================================== 20 | 21 | UCLASS(BlueprintType) 22 | class UNREALROS_API URosMessageBase : public UObject 23 | { 24 | 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | // String representation of the message type 30 | UPROPERTY(BlueprintReadOnly, Category = "ROS") 31 | FString type = "avl_unreal/RosMessageBase"; 32 | 33 | public: 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: URosMessageBase constructor 37 | // Description: Default constructor. 38 | //-------------------------------------------------------------------------- 39 | URosMessageBase( ) 40 | { 41 | 42 | } 43 | 44 | //-------------------------------------------------------------------------- 45 | // Name: URosMessageBase constructor 46 | // Description: Constructs the class with a type name. 47 | //-------------------------------------------------------------------------- 48 | URosMessageBase(FString type_name) : type(type_name) 49 | { 50 | 51 | } 52 | 53 | //-------------------------------------------------------------------------- 54 | // Name: URosMessageBase destructor 55 | // Description: Default destructor. 56 | //-------------------------------------------------------------------------- 57 | virtual ~URosMessageBase() 58 | { 59 | 60 | } 61 | 62 | //-------------------------------------------------------------------------- 63 | // Name: get_json 64 | // Description: Gets the JSON object corresponding to the message. 65 | // Returns: JSON object corresponding to the message. 66 | //-------------------------------------------------------------------------- 67 | virtual json get_json() 68 | { 69 | json json; 70 | json = json::parse("{}"); 71 | return json; 72 | } 73 | 74 | //-------------------------------------------------------------------------- 75 | // Name: get_json_string 76 | // Description: Gets a string representation of the JSON object 77 | // corresponding to the message. 78 | // Returns: String representation of the JSON object corresponding to 79 | // the message. 80 | //-------------------------------------------------------------------------- 81 | UFUNCTION(BlueprintPure, Category = "ROS") 82 | FString get_json_string() 83 | { 84 | return FString(this->get_json().dump().c_str()); 85 | } 86 | 87 | //-------------------------------------------------------------------------- 88 | // Name: from_json 89 | // Description: Populates the message fields from the given JSON object. 90 | // Arguments: -json: JSON object to populate message fields from 91 | //-------------------------------------------------------------------------- 92 | virtual void from_json(json json) 93 | { 94 | 95 | } 96 | 97 | template 98 | FORCEINLINE TArray CastArray(TArray InArray) 99 | { 100 | TArray OutArray; 101 | OutArray.Reserve(InArray.Num()); 102 | 103 | for (auto& Elem : InArray) 104 | { 105 | To ThisCastedObject = Cast(Elem); 106 | if (ThisCastedObject) 107 | { 108 | OutArray.Emplace(ThisCastedObject); 109 | } 110 | } 111 | return OutArray; 112 | } 113 | 114 | }; 115 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/UnrealROS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Modules/ModuleManager.h" 4 | 5 | class FUnrealROSModule : public IModuleInterface 6 | { 7 | 8 | public: 9 | 10 | /** IModuleInterface implementation */ 11 | virtual void StartupModule() override; 12 | virtual void ShutdownModule() override; 13 | 14 | }; 15 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/avl_msgs/VehicleStateMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the avl_msgs/VehicleStateMsg ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "VehicleStateMsg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UVehicleStateMsg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UVehicleStateMsg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UVehicleStateMsg() : URosMessageBase("avl_simulation/VehicleStateMsg") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UVehicleStateMsg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UVehicleStateMsg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | 54 | json json; 55 | 56 | m_rpm = json["rpm"] = m_rpm; 57 | 58 | json["roll"] = m_roll; 59 | json["pitch"] = m_pitch; 60 | json["yaw"] = m_yaw; 61 | 62 | json["v_eb_b_x"] = m_v_eb_b_x; 63 | json["v_eb_b_y"] = m_v_eb_b_y; 64 | json["v_eb_b_z"] = m_v_eb_b_z; 65 | 66 | json["lat"] = m_lat; 67 | json["lon"] = m_lon; 68 | json["alt"] = m_alt; 69 | 70 | json["lat0"] = m_lat0; 71 | json["lon0"] = m_lon0; 72 | json["alt0"] = m_alt0; 73 | 74 | json["r_b_n"] = m_r_b_n; 75 | json["r_b_e"] = m_r_b_e; 76 | json["r_b_d"] = m_r_b_d; 77 | 78 | json["w_ib_b_x"] = m_w_ib_b_x; 79 | json["w_ib_b_y"] = m_w_ib_b_y; 80 | json["w_ib_b_z"] = m_w_ib_b_z; 81 | 82 | json["f_ib_b_x"] = m_f_ib_b_x; 83 | json["f_ib_b_y"] = m_f_ib_b_y; 84 | json["f_ib_b_z"] = m_f_ib_b_z; 85 | 86 | return json; 87 | 88 | } 89 | 90 | //-------------------------------------------------------------------------- 91 | // Name: from_json 92 | // Description: Populates the message fields from the given JSON object. 93 | // Arguments: - json: JSON object to populate message fields from 94 | //-------------------------------------------------------------------------- 95 | void from_json(json json) override 96 | { 97 | 98 | m_rpm = json["rpm"]; 99 | 100 | m_roll = json["roll"]; 101 | m_pitch = json["pitch"]; 102 | m_yaw = json["yaw"]; 103 | 104 | m_v_eb_b_x = json["v_eb_b_x"]; 105 | m_v_eb_b_y = json["v_eb_b_y"]; 106 | m_v_eb_b_z = json["v_eb_b_z"]; 107 | 108 | m_lat = json["lat"]; 109 | m_lon = json["lon"]; 110 | m_alt = json["alt"]; 111 | 112 | m_lat0 = json["lat0"]; 113 | m_lon0 = json["lon0"]; 114 | m_alt0 = json["alt0"]; 115 | 116 | m_r_b_n = json["r_b_n"]; 117 | m_r_b_e = json["r_b_e"]; 118 | m_r_b_d = json["r_b_d"]; 119 | 120 | m_w_ib_b_x = json["w_ib_b_x"]; 121 | m_w_ib_b_y = json["w_ib_b_y"]; 122 | m_w_ib_b_z = json["w_ib_b_z"]; 123 | 124 | m_f_ib_b_x = json["f_ib_b_x"]; 125 | m_f_ib_b_y = json["f_ib_b_y"]; 126 | m_f_ib_b_z = json["f_ib_b_z"]; 127 | 128 | } 129 | 130 | //-------------------------------------------------------------------------- 131 | // Name: get_contents 132 | // Description: Gets the contents of the ROS message. 133 | // Arguments: - data: message data 134 | //-------------------------------------------------------------------------- 135 | UFUNCTION(BlueprintPure, Category = "ROS") 136 | void get_contents(float& rpm, FVector& attitude, FVector& velocity, 137 | FVector& pos_lla, FVector& ned_origin, FVector& pos_ned, 138 | FVector& angular_velocity, FVector& linear_acceleration) 139 | { 140 | 141 | rpm = m_rpm; 142 | 143 | attitude.X = m_roll; 144 | attitude.Y = m_pitch; 145 | attitude.Z = m_yaw; 146 | 147 | velocity.X = m_v_eb_b_x; 148 | velocity.Y = m_v_eb_b_y; 149 | velocity.Z = m_v_eb_b_z; 150 | 151 | pos_lla.X = m_lat; 152 | pos_lla.Y = m_lon; 153 | pos_lla.Z = m_alt; 154 | 155 | ned_origin.X = m_lat0; 156 | ned_origin.Y = m_lon0; 157 | ned_origin.Z = m_alt0; 158 | pos_ned.X = m_r_b_n; 159 | pos_ned.Y = m_r_b_e; 160 | pos_ned.Z = m_r_b_d; 161 | 162 | angular_velocity.X = m_w_ib_b_x; 163 | angular_velocity.Y = m_w_ib_b_y; 164 | angular_velocity.Z = m_w_ib_b_z; 165 | 166 | linear_acceleration.X = m_f_ib_b_x; 167 | linear_acceleration.Y = m_f_ib_b_y; 168 | linear_acceleration.Z = m_f_ib_b_z; 169 | 170 | } 171 | 172 | //-------------------------------------------------------------------------- 173 | // Name: set_contents 174 | // Description: Sets the contents of the ROS message. 175 | // Arguments: - data: message data 176 | //-------------------------------------------------------------------------- 177 | UFUNCTION(BlueprintCallable, Category = "ROS") 178 | void set_contents(float rpm, FVector attitude, FVector velocity, 179 | FVector pos_lla, FVector ned_origin, FVector pos_ned, 180 | FVector angular_velocity, FVector linear_acceleration) 181 | { 182 | 183 | m_rpm = rpm; 184 | 185 | m_roll = attitude.X; 186 | m_pitch = attitude.Y; 187 | m_yaw = attitude.Z; 188 | 189 | m_v_eb_b_x = velocity.X; 190 | m_v_eb_b_y = velocity.Y; 191 | m_v_eb_b_z = velocity.Z; 192 | 193 | m_lat = pos_lla.X; 194 | m_lon = pos_lla.Y; 195 | m_alt = pos_lla.Z; 196 | 197 | m_lat0 = ned_origin.X; 198 | m_lon0 = ned_origin.Y; 199 | m_alt0 = ned_origin.Z; 200 | m_r_b_n = pos_ned.X; 201 | m_r_b_e = pos_ned.Y; 202 | m_r_b_d = pos_ned.Z; 203 | 204 | m_w_ib_b_x = angular_velocity.X; 205 | m_w_ib_b_y = angular_velocity.Y; 206 | m_w_ib_b_z = angular_velocity.Z; 207 | 208 | m_f_ib_b_x = linear_acceleration.X; 209 | m_f_ib_b_y = linear_acceleration.Y; 210 | m_f_ib_b_z = linear_acceleration.Z; 211 | 212 | } 213 | 214 | public: 215 | 216 | // Propeller RPM 217 | double m_rpm; 218 | 219 | // Euler angles to rotate from the NED frame to the body frame.These are the 220 | // vehicle's roll, pitch, and heading. Units are radians. 221 | double m_roll; 222 | double m_pitch; 223 | double m_yaw; 224 | 225 | // Vehicle body frame velocity relative to the earth frame, expressed in the body 226 | // frame.This is the vehicle's ground-relative speed. Units are m/s. 227 | double m_v_eb_b_x; 228 | double m_v_eb_b_y; 229 | double m_v_eb_b_z; 230 | 231 | // Vehicle body frame position expressed in geodetic coordinates.Units are 232 | // radians for lat / lon and meters for alt. 233 | double m_lat; 234 | double m_lon; 235 | double m_alt; 236 | 237 | // Vehicle body frame position expressed in a local cartesian frame with origin 238 | // at lat0, lon0, and alt0.Units are radians for lat0 / lon0 and meters for the 239 | // rest. 240 | double m_lat0; 241 | double m_lon0; 242 | double m_alt0; 243 | double m_r_b_n; 244 | double m_r_b_e; 245 | double m_r_b_d; 246 | 247 | // Vehicle body frame rotation rate relative to the inertial frame, expressed in 248 | // the body frame.These are the values that a gyroscope would read if mounted to 249 | // the vehicle body frame.Units are rad / s. 250 | double m_w_ib_b_x; 251 | double m_w_ib_b_y; 252 | double m_w_ib_b_z; 253 | 254 | // Vehicle body frame acceleration relative to the inertial frame, expressed in 255 | // the body frame.These are the values that an accelerometer would read if 256 | // mounted to the vehicle body frame.Units are m / s ^ 2. 257 | double m_f_ib_b_x; 258 | double m_f_ib_b_y; 259 | double m_f_ib_b_z; 260 | 261 | }; 262 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/geometry_msgs/Vector3Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the geometry_msgs/Vector3 ROS message and its interface 5 | // with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Vector3Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UVector3Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UVector3Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UVector3Msg() : URosMessageBase("geometry_msgs/Vector3") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UVector3Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UVector3Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["x"] = m_x; 55 | json["y"] = m_y; 56 | json["z"] = m_z; 57 | return json; 58 | } 59 | 60 | //-------------------------------------------------------------------------- 61 | // Name: from_json 62 | // Description: Populates the message fields from the given JSON object. 63 | // Arguments: - json: JSON object to populate message fields from 64 | //-------------------------------------------------------------------------- 65 | void from_json(json json) override 66 | { 67 | m_x = json["x"]; 68 | m_y = json["y"]; 69 | m_z = json["z"]; 70 | } 71 | 72 | //-------------------------------------------------------------------------- 73 | // Name: get_contents 74 | // Description: Gets the contents of the ROS message. 75 | // Arguments: - data: message data 76 | //-------------------------------------------------------------------------- 77 | UFUNCTION(BlueprintPure, Category = "ROS") 78 | void get_contents(float& x, float& y, float& z) 79 | { 80 | x = static_cast(m_x); 81 | y = static_cast(m_y); 82 | z = static_cast(m_z); 83 | } 84 | 85 | //-------------------------------------------------------------------------- 86 | // Name: set_contents 87 | // Description: Sets the contents of the ROS message. 88 | // Arguments: - data: message data 89 | //-------------------------------------------------------------------------- 90 | UFUNCTION(BlueprintCallable, Category = "ROS") 91 | void set_contents(float x, float y, float z) 92 | { 93 | m_x = static_cast(x); 94 | m_y = static_cast(y); 95 | m_z = static_cast(z); 96 | } 97 | 98 | private: 99 | 100 | double m_x; 101 | double m_y; 102 | double m_z; 103 | 104 | }; 105 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/rosbridge.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Provides the base rosbridge functionality. Provides blueprint 5 | // callable functions to connect to a rosbridge server, and publish 6 | // and subscribe to ROS topics through the rosbridge API. 7 | //============================================================================== 8 | 9 | #pragma once 10 | 11 | // TCP socket functionality 12 | #include "Networking.h" 13 | 14 | // UE4 core functionality 15 | #include "CoreMinimal.h" 16 | 17 | // Actor base class 18 | #include "GameFramework/Actor.h" 19 | 20 | // JSON parsing 21 | #include "ThirdParty/json.hpp" 22 | 23 | // Map class 24 | #include 25 | 26 | // ROS message base class 27 | #include "RosMessageBase.h" 28 | 29 | #include "rosbridge.generated.h" 30 | 31 | //============================================================================== 32 | // CLASS DECLARATION 33 | //============================================================================== 34 | 35 | UCLASS(ClassGroup = ROS, editinlinenew, meta = (BlueprintSpawnableComponent)) 36 | class UNREALROS_API URosbridge : public UActorComponent 37 | { 38 | 39 | GENERATED_BODY() 40 | 41 | public: 42 | 43 | //-------------------------------------------------------------------------- 44 | // Name: ARosbridge constructor 45 | // Description: Default constructor. 46 | //-------------------------------------------------------------------------- 47 | URosbridge(); 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: OnMessageReceived delegate 51 | // Description: Declare a delegate type that gets called when a message is 52 | // received from a subscription. 53 | //-------------------------------------------------------------------------- 54 | DECLARE_DYNAMIC_DELEGATE_OneParam(FMessageReceivedCallback, URosMessageBase*, Message); 55 | 56 | //-------------------------------------------------------------------------- 57 | // Name: connect 58 | // Description: Connects to a rosbridge server. 59 | // Arguments: - address: rosbridge server address 60 | // - port: rosbridge server port 61 | //-------------------------------------------------------------------------- 62 | UFUNCTION(BlueprintCallable, Category = "ROS") 63 | void connect(FString address, int port); 64 | 65 | //-------------------------------------------------------------------------- 66 | // Name: advertise 67 | // Description: Advertises that a ROS topic will be published. 68 | // Arguments: - topic: topic name 69 | // - type: message type 70 | //-------------------------------------------------------------------------- 71 | UFUNCTION(BlueprintCallable, Category = "ROS") 72 | void advertise(FString topic, FString type); 73 | 74 | //-------------------------------------------------------------------------- 75 | // Name: unadvertise 76 | // Description: Stops advertising that a ROS topic will be published. 77 | // Arguments: - topic: topic name 78 | //-------------------------------------------------------------------------- 79 | UFUNCTION(BlueprintCallable, Category = "ROS") 80 | void unadvertise(FString topic); 81 | 82 | //-------------------------------------------------------------------------- 83 | // Name: publish 84 | // Description: Publishes to a ROS topic. 85 | // Arguments: - topic: topic name 86 | // - type: message type 87 | //-------------------------------------------------------------------------- 88 | UFUNCTION(BlueprintCallable, Category = "ROS") 89 | void publish(FString topic, UPARAM(ref) URosMessageBase* message); 90 | 91 | //-------------------------------------------------------------------------- 92 | // Name: subscribe 93 | // Description: Subscribes to a ROS topic. 94 | // Arguments: - topic: topic name 95 | // - message_type: message type 96 | // - callback: callback to be called when a message arrives on 97 | // the topic 98 | //-------------------------------------------------------------------------- 99 | UFUNCTION(BlueprintCallable, Category = "ROS") 100 | void subscribe(FString topic, TSubclassOf message_type, 101 | const FMessageReceivedCallback& callback); 102 | 103 | //-------------------------------------------------------------------------- 104 | // Name: unsubscribe 105 | // Description: Unsubscribes from a ROS topic. 106 | // Arguments: - topic: topic name 107 | //-------------------------------------------------------------------------- 108 | UFUNCTION(BlueprintCallable, Category = "ROS") 109 | void unsubscribe(FString topic); 110 | 111 | //------------------------------------------------------------------------------ 112 | // Name: set_level 113 | // Description: Sets the status message level on the rosbridge server. 114 | // Arguments: - level: status_message_level 115 | //------------------------------------------------------------------------------ 116 | void set_level(FString level); 117 | 118 | protected: 119 | 120 | //-------------------------------------------------------------------------- 121 | // Name: BeginPlay 122 | // Description: Called when the game starts or when spawned. Override of 123 | // AActor::BeginPlay. 124 | //-------------------------------------------------------------------------- 125 | virtual void BeginPlay() override; 126 | 127 | //-------------------------------------------------------------------------- 128 | // Name: Tick 129 | // Description: Called every game tick. Override of AActor::Tick. 130 | // Arguments: - DeltaTime: time since last tick in seconds 131 | //-------------------------------------------------------------------------- 132 | void TickComponent(float DeltaTime, enum ELevelTick TickType, 133 | FActorComponentTickFunction *ThisTickFunction) override; 134 | 135 | //-------------------------------------------------------------------------- 136 | // Name: EndPlay 137 | // Description: Called when the game ends. Override of AActor::EndPlay. 138 | // Arguments: - EndPlayReason: reason for play ending 139 | //-------------------------------------------------------------------------- 140 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 141 | 142 | //-------------------------------------------------------------------------- 143 | // Name: handle_received_json 144 | // Description: Handles a JSON message received over TCP. 145 | // Arguments: - json_message: JSON message to be handles 146 | //-------------------------------------------------------------------------- 147 | void handle_received_json(nlohmann::json json_message); 148 | 149 | private: 150 | 151 | // Socket instance for TCP communication 152 | FSocket* tcp_socket; 153 | 154 | // Receive buffer for bytes received over TCP 155 | std::string receive_buffer; 156 | 157 | // Map between a string representing a ROS message type and a UClass that 158 | // can be used to create an instance of the message type 159 | std::map message_type_map; 160 | 161 | // Map between topic name and type name for all subscriptions. Used to get 162 | // the type of an incoming message since that is not indicated by rosbridge 163 | std::map subscription_map; 164 | std::map subscription_callback_map; 165 | 166 | // Flag indicating whether the TCP server is connected 167 | bool socket_connected = false; 168 | 169 | private: 170 | 171 | //-------------------------------------------------------------------------- 172 | // Name: print 173 | // Description: Prints a message on the editor screen. 174 | // Arguments: - color: message color 175 | // - message: message string 176 | //-------------------------------------------------------------------------- 177 | void print(FColor color, FString message); 178 | 179 | //-------------------------------------------------------------------------- 180 | // Name: json_to_bytes 181 | // Description: Converts a JSON object to an array of uint8 bytes. 182 | // Arguments: - json: JSON object to be converted 183 | // - num_bytes: number of bytes in resulting byte array 184 | // Returns: Array of bytes representing the JSON object. 185 | //-------------------------------------------------------------------------- 186 | const uint8* json_to_bytes(json json, int32& num_bytes); 187 | 188 | }; 189 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/sensor_msgs/JoyMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the sensor_msgs/Joy ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "std_msgs/HeaderMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "JoyMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UJoyMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UJoyMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UJoyMsg() : URosMessageBase("sensor_msgs/Joy") 36 | { 37 | 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UJoyMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UJoyMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["header"] = m_header->get_json(); 58 | for (float item : m_axes) 59 | json["axes"].push_back(item); 60 | for (uint32_t item : m_buttons) 61 | json["buttons"].push_back(item); 62 | return json; 63 | 64 | } 65 | 66 | //-------------------------------------------------------------------------- 67 | // Name: from_json 68 | // Description: Populates the message fields from the given JSON object. 69 | // Arguments: - json: JSON object to populate message fields from 70 | //-------------------------------------------------------------------------- 71 | void from_json(json json_message) override 72 | { 73 | 74 | UHeaderMsg* header = NewObject(); 75 | header->from_json(json_message["header"]); 76 | m_header = header; 77 | 78 | m_axes.Empty(); 79 | for (float item : json_message["axes"]) 80 | m_axes.Push(item); 81 | 82 | m_buttons.Empty(); 83 | for (uint32_t item : json_message["buttons"]) 84 | m_buttons.Push(item); 85 | 86 | } 87 | 88 | //-------------------------------------------------------------------------- 89 | // Name: get_contents 90 | // Description: Gets the contents of the ROS message. 91 | // Arguments: - data: message data 92 | //-------------------------------------------------------------------------- 93 | UFUNCTION(BlueprintPure, Category = "ROS") 94 | void get_contents(UHeaderMsg*& header, TArray& axes, TArray& buttons) 95 | { 96 | header = m_header; 97 | axes = m_axes; 98 | buttons.Empty(); 99 | for (size_t i = 0; i < m_buttons.Num(); i++) 100 | buttons.Add(static_cast(m_buttons[i])); 101 | 102 | } 103 | 104 | //-------------------------------------------------------------------------- 105 | // Name: set_contents 106 | // Description: Sets the contents of the ROS message. 107 | // Arguments: - data: message data 108 | //-------------------------------------------------------------------------- 109 | UFUNCTION(BlueprintCallable, Category = "ROS") 110 | void set_contents(UHeaderMsg* header, TArray axes, TArray buttons) 111 | { 112 | m_header = header; 113 | m_axes = axes; 114 | m_buttons.Empty(); 115 | for (size_t i = 0; i < buttons.Num(); i++) 116 | m_buttons.Add(static_cast(buttons[i])); 117 | } 118 | 119 | private: 120 | 121 | UHeaderMsg* m_header; 122 | TArray m_axes; 123 | TArray m_buttons; 124 | 125 | }; 126 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/BoolMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Bool ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | // ROS message base class 11 | #include "RosMessageBase.h" 12 | 13 | // UE4 imports 14 | #include "CoreMinimal.h" 15 | #include "BoolMsg.generated.h" 16 | 17 | //============================================================================== 18 | // CLASS DECLARATION 19 | //============================================================================== 20 | 21 | UCLASS(BlueprintType) 22 | class UNREALROS_API UBoolMsg : public URosMessageBase 23 | { 24 | 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | //-------------------------------------------------------------------------- 30 | // Name: UBoolMsg constructor 31 | // Description: Default constructor. 32 | //-------------------------------------------------------------------------- 33 | UBoolMsg() : URosMessageBase("std_msgs/Bool") 34 | { 35 | 36 | }; 37 | 38 | //-------------------------------------------------------------------------- 39 | // Name: UBoolMsg destructor 40 | // Description: Default destructor. 41 | //-------------------------------------------------------------------------- 42 | ~UBoolMsg() override 43 | { 44 | 45 | } 46 | 47 | //-------------------------------------------------------------------------- 48 | // Name: get_json 49 | // Description: Gets the JSON object corresponding to the message. 50 | // Returns: JSON object corresponding to the message. 51 | //-------------------------------------------------------------------------- 52 | json get_json() override 53 | { 54 | json json; 55 | json["data"] = m_data; 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | m_data = json["data"]; 67 | } 68 | 69 | //-------------------------------------------------------------------------- 70 | // Name: get_contents 71 | // Description: Gets the contents of the ROS message. 72 | // Arguments: - data: message data 73 | //-------------------------------------------------------------------------- 74 | UFUNCTION(BlueprintPure, Category = "ROS") 75 | void get_contents(bool& data) 76 | { 77 | data = m_data; 78 | } 79 | 80 | //-------------------------------------------------------------------------- 81 | // Name: set_contents 82 | // Description: Sets the contents of the ROS message. 83 | // Arguments: - data: message data 84 | //-------------------------------------------------------------------------- 85 | UFUNCTION(BlueprintCallable, Category = "ROS") 86 | void set_contents(bool data) 87 | { 88 | m_data = data; 89 | } 90 | 91 | private: 92 | 93 | bool m_data; 94 | 95 | }; 96 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/ByteMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Byte ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | // ROS message base class 11 | #include "RosMessageBase.h" 12 | 13 | // UE4 imports 14 | #include "CoreMinimal.h" 15 | #include "ByteMsg.generated.h" 16 | 17 | //============================================================================== 18 | // CLASS DECLARATION 19 | //============================================================================== 20 | 21 | UCLASS(BlueprintType) 22 | class UNREALROS_API UByteMsg : public URosMessageBase 23 | { 24 | 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | //-------------------------------------------------------------------------- 30 | // Name: UByteMsg constructor 31 | // Description: Default constructor. 32 | //-------------------------------------------------------------------------- 33 | UByteMsg() : URosMessageBase("std_msgs/Byte") 34 | { 35 | 36 | }; 37 | 38 | //-------------------------------------------------------------------------- 39 | // Name: UByteMsg destructor 40 | // Description: Default destructor. 41 | //-------------------------------------------------------------------------- 42 | ~UByteMsg() override 43 | { 44 | 45 | } 46 | 47 | //-------------------------------------------------------------------------- 48 | // Name: get_json 49 | // Description: Gets the JSON object corresponding to the message. 50 | // Returns: JSON object corresponding to the message. 51 | //-------------------------------------------------------------------------- 52 | json get_json() override 53 | { 54 | json json; 55 | json["data"] = m_data; 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | m_data = json["data"]; 67 | } 68 | 69 | //-------------------------------------------------------------------------- 70 | // Name: get_contents 71 | // Description: Gets the contents of the ROS message. 72 | // Arguments: - data: message data 73 | //-------------------------------------------------------------------------- 74 | UFUNCTION(BlueprintPure, Category = "ROS") 75 | void get_contents(int& data) 76 | { 77 | data = static_cast(m_data); 78 | } 79 | 80 | //-------------------------------------------------------------------------- 81 | // Name: set_contents 82 | // Description: Sets the contents of the ROS message. 83 | // Arguments: - data: message data 84 | //-------------------------------------------------------------------------- 85 | UFUNCTION(BlueprintCallable, Category = "ROS") 86 | void set_contents(int data) 87 | { 88 | m_data = static_cast(data); 89 | } 90 | 91 | private: 92 | 93 | int8_t m_data; 94 | 95 | }; -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/ByteMultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/ByteMultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | // ROS message base class 11 | #include "RosMessageBase.h" 12 | 13 | // Message dependencies 14 | #include "MultiArrayLayoutMsg.h" 15 | 16 | // UE4 imports 17 | #include "CoreMinimal.h" 18 | #include "ByteMultiArrayMsg.generated.h" 19 | 20 | //============================================================================== 21 | // CLASS DECLARATION 22 | //============================================================================== 23 | 24 | UCLASS(BlueprintType) 25 | class UNREALROS_API UByteMultiArrayMsg : public URosMessageBase 26 | { 27 | 28 | GENERATED_BODY() 29 | 30 | public: 31 | 32 | //-------------------------------------------------------------------------- 33 | // Name: UByteMultiArrayMsg constructor 34 | // Description: Default constructor. 35 | //-------------------------------------------------------------------------- 36 | UByteMultiArrayMsg() : URosMessageBase("std_msgs/ByteMultiArray") 37 | { 38 | m_layout = NewObject(); 39 | }; 40 | 41 | //-------------------------------------------------------------------------- 42 | // Name: UByteMultiArrayMsg destructor 43 | // Description: Default destructor. 44 | //-------------------------------------------------------------------------- 45 | ~UByteMultiArrayMsg() override 46 | { 47 | 48 | } 49 | 50 | //-------------------------------------------------------------------------- 51 | // Name: get_json 52 | // Description: Gets the JSON object corresponding to the message. 53 | // Returns: JSON object corresponding to the message. 54 | //-------------------------------------------------------------------------- 55 | json get_json() override 56 | { 57 | json json; 58 | json["layout"] = m_layout->get_json(); 59 | for (auto item : m_data) 60 | json["data"].push_back(item); 61 | return json; 62 | } 63 | 64 | //-------------------------------------------------------------------------- 65 | // Name: from_json 66 | // Description: Populates the message fields from the given JSON object. 67 | // Arguments: - json: JSON object to populate message fields from 68 | //-------------------------------------------------------------------------- 69 | void from_json(json json) override 70 | { 71 | 72 | UMultiArrayLayoutMsg* layout = NewObject(); 73 | layout->from_json(json["layout"]); 74 | m_layout = layout; 75 | 76 | m_data.Empty(); 77 | for (auto item : json["data"]) 78 | m_data.Push(item); 79 | 80 | } 81 | 82 | //-------------------------------------------------------------------------- 83 | // Name: get_contents 84 | // Description: Gets the contents of the ROS message. 85 | // Arguments: - data: message data 86 | //-------------------------------------------------------------------------- 87 | UFUNCTION(BlueprintPure, Category = "ROS") 88 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 89 | { 90 | layout = m_layout; 91 | data.Empty(); 92 | for (size_t i = 0; i < m_data.Num(); i++) 93 | data.Add(static_cast(m_data[i])); 94 | } 95 | 96 | //-------------------------------------------------------------------------- 97 | // Name: set_contents 98 | // Description: Sets the contents of the ROS message. 99 | // Arguments: - data: message data 100 | //-------------------------------------------------------------------------- 101 | UFUNCTION(BlueprintCallable, Category = "ROS") 102 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 103 | { 104 | m_layout = layout; 105 | m_data.Empty(); 106 | for (size_t i = 0; i < data.Num(); i++) 107 | m_data.Add(static_cast(data[i])); 108 | } 109 | 110 | private: 111 | 112 | // Specification of data layout 113 | UMultiArrayLayoutMsg* m_layout; 114 | 115 | // Array of data 116 | TArray m_data; 117 | 118 | }; 119 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/CharMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Char ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | // ROS message base class 11 | #include "RosMessageBase.h" 12 | 13 | // UE4 imports 14 | #include "CoreMinimal.h" 15 | #include "CharMsg.generated.h" 16 | 17 | //============================================================================== 18 | // CLASS DECLARATION 19 | //============================================================================== 20 | 21 | UCLASS(BlueprintType) 22 | class UNREALROS_API UCharMsg : public URosMessageBase 23 | { 24 | 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | //-------------------------------------------------------------------------- 30 | // Name: UCharMsg constructor 31 | // Description: Default constructor. 32 | //-------------------------------------------------------------------------- 33 | UCharMsg() : URosMessageBase("std_msgs/Char") 34 | { 35 | 36 | }; 37 | 38 | //-------------------------------------------------------------------------- 39 | // Name: UCharMsg destructor 40 | // Description: Default destructor. 41 | //-------------------------------------------------------------------------- 42 | ~UCharMsg() override 43 | { 44 | 45 | } 46 | 47 | //-------------------------------------------------------------------------- 48 | // Name: get_json 49 | // Description: Gets the JSON object corresponding to the message. 50 | // Returns: JSON object corresponding to the message. 51 | //-------------------------------------------------------------------------- 52 | json get_json() override 53 | { 54 | json json; 55 | json["data"] = m_data; 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | m_data = json["data"]; 67 | } 68 | 69 | //-------------------------------------------------------------------------- 70 | // Name: get_contents 71 | // Description: Gets the contents of the ROS message. 72 | // Arguments: - data: message data 73 | //-------------------------------------------------------------------------- 74 | UFUNCTION(BlueprintPure, Category = "ROS") 75 | void get_contents(int& data) 76 | { 77 | data = static_cast(m_data); 78 | } 79 | 80 | //-------------------------------------------------------------------------- 81 | // Name: set_contents 82 | // Description: Sets the contents of the ROS message. 83 | // Arguments: - data: message data 84 | //-------------------------------------------------------------------------- 85 | UFUNCTION(BlueprintCallable, Category = "ROS") 86 | void set_contents(int data) 87 | { 88 | m_data = static_cast(data); 89 | } 90 | 91 | private: 92 | 93 | uint8 m_data; 94 | 95 | }; -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/ColorRGBAMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/ColorRGBA ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "RosMessageBase.h" 12 | #include "ColorRGBAMsg.generated.h" 13 | 14 | //============================================================================== 15 | // CLASS DECLARATION 16 | //============================================================================== 17 | 18 | UCLASS(BlueprintType) 19 | class UNREALROS_API UColorRGBAMsg : public URosMessageBase 20 | { 21 | 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | //-------------------------------------------------------------------------- 27 | // Name: UColorRGBAMsg constructor 28 | // Description: Default constructor. 29 | //-------------------------------------------------------------------------- 30 | UColorRGBAMsg() : URosMessageBase("std_msgs/ColorRGBA") 31 | { 32 | 33 | }; 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: UColorRGBAMsg destructor 37 | // Description: Default destructor. 38 | //-------------------------------------------------------------------------- 39 | ~UColorRGBAMsg() override 40 | { 41 | 42 | } 43 | 44 | //-------------------------------------------------------------------------- 45 | // Name: get_json 46 | // Description: Gets the JSON object corresponding to the message. 47 | // Returns: JSON object corresponding to the message. 48 | //-------------------------------------------------------------------------- 49 | json get_json() override 50 | { 51 | json json; 52 | json["r"] = m_r; 53 | json["g"] = m_g; 54 | json["b"] = m_b; 55 | json["a"] = m_a; 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | m_r = json["r"]; 67 | m_g = json["g"]; 68 | m_b = json["b"]; 69 | m_a = json["a"]; 70 | } 71 | 72 | //-------------------------------------------------------------------------- 73 | // Name: get_contents 74 | // Description: Gets the contents of the ROS message. 75 | // Arguments: - data: message data 76 | //-------------------------------------------------------------------------- 77 | UFUNCTION(BlueprintPure, Category = "ROS") 78 | void get_contents(float& r, float& g, float& b, float& a) 79 | { 80 | r = m_r; 81 | g = m_g; 82 | b = m_b; 83 | a = m_a; 84 | } 85 | 86 | //-------------------------------------------------------------------------- 87 | // Name: set_contents 88 | // Description: Sets the contents of the ROS message. 89 | // Arguments: - data: message data 90 | //-------------------------------------------------------------------------- 91 | UFUNCTION(BlueprintCallable, Category = "ROS") 92 | void set_contents(float r, float g, float b, float a) 93 | { 94 | m_r = r; 95 | m_g = g; 96 | m_b = b; 97 | m_a = a; 98 | } 99 | 100 | private: 101 | 102 | float m_r; 103 | float m_g; 104 | float m_b; 105 | float m_a; 106 | 107 | 108 | }; 109 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/DurationMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Duration ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "RosMessageBase.h" 12 | #include "DurationMsg.generated.h" 13 | 14 | //============================================================================== 15 | // CLASS DECLARATION 16 | //============================================================================== 17 | 18 | UCLASS(BlueprintType) 19 | class UNREALROS_API UDurationMsg : public URosMessageBase 20 | { 21 | 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | //-------------------------------------------------------------------------- 27 | // Name: UDurationMsg constructor 28 | // Description: Default constructor. 29 | //-------------------------------------------------------------------------- 30 | UDurationMsg() : URosMessageBase("std_msgs/Duration") 31 | { 32 | 33 | }; 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: UDurationMsg destructor 37 | // Description: Default destructor. 38 | //-------------------------------------------------------------------------- 39 | ~UDurationMsg() override 40 | { 41 | 42 | } 43 | 44 | //-------------------------------------------------------------------------- 45 | // Name: get_json 46 | // Description: Gets the JSON object corresponding to the message. 47 | // Returns: JSON object corresponding to the message. 48 | //-------------------------------------------------------------------------- 49 | json get_json() override 50 | { 51 | json json; 52 | json["data"]["secs"] = m_secs; 53 | json["data"]["nsecs"] = m_nsecs; 54 | return json; 55 | } 56 | 57 | //-------------------------------------------------------------------------- 58 | // Name: from_json 59 | // Description: Populates the message fields from the given JSON object. 60 | // Arguments: - json: JSON object to populate message fields from 61 | //-------------------------------------------------------------------------- 62 | void from_json(json json) override 63 | { 64 | m_secs = json["data"]["secs"]; 65 | m_nsecs = json["data"]["nsecs"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& secs, int& nsecs) 75 | { 76 | secs = static_cast(m_secs); 77 | nsecs = static_cast(m_nsecs); 78 | } 79 | 80 | //-------------------------------------------------------------------------- 81 | // Name: set_contents 82 | // Description: Sets the contents of the ROS message. 83 | // Arguments: - data: message data 84 | //-------------------------------------------------------------------------- 85 | UFUNCTION(BlueprintCallable, Category = "ROS") 86 | void set_contents(int secs, int nsecs) 87 | { 88 | m_secs = static_cast(secs); 89 | m_nsecs = static_cast(nsecs); 90 | } 91 | 92 | private: 93 | 94 | int32_t m_secs; 95 | int32_t m_nsecs; 96 | 97 | }; 98 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/EmptyMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Empty ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "RosMessageBase.h" 12 | #include "EmptyMsg.generated.h" 13 | 14 | //============================================================================== 15 | // CLASS DECLARATION 16 | //============================================================================== 17 | 18 | UCLASS(BlueprintType) 19 | class UNREALROS_API UEmptyMsg : public URosMessageBase 20 | { 21 | 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | //-------------------------------------------------------------------------- 27 | // Name: UEmptyMsg constructor 28 | // Description: Default constructor. 29 | //-------------------------------------------------------------------------- 30 | UEmptyMsg() : URosMessageBase("std_msgs/Empty") 31 | { 32 | 33 | }; 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: UEmptyMsg destructor 37 | // Description: Default destructor. 38 | //-------------------------------------------------------------------------- 39 | ~UEmptyMsg() override 40 | { 41 | 42 | } 43 | 44 | private: 45 | 46 | 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Float32Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Float32 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Float32Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UFloat32Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UFloat32Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UFloat32Msg() : URosMessageBase("std_msgs/Float32") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UFloat32Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UFloat32Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(float& data) 75 | { 76 | data = m_data; 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(float data) 86 | { 87 | m_data = data; 88 | } 89 | 90 | private: 91 | 92 | float m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Float32MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Float32MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Float32MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UFloat32MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UFloat32MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UFloat32MultiArrayMsg() : URosMessageBase("std_msgs/Float32MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UFloat32MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UFloat32MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data = m_data; 91 | } 92 | 93 | //-------------------------------------------------------------------------- 94 | // Name: set_contents 95 | // Description: Sets the contents of the ROS message. 96 | // Arguments: - data: message data 97 | //-------------------------------------------------------------------------- 98 | UFUNCTION(BlueprintCallable, Category = "ROS") 99 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 100 | { 101 | m_layout = layout; 102 | m_data = data; 103 | } 104 | 105 | private: 106 | 107 | // Specification of data layout 108 | UMultiArrayLayoutMsg* m_layout; 109 | 110 | // Array of data 111 | TArray m_data; 112 | 113 | }; 114 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Float64Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Float64 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Float64Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UFloat64Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UFloat64Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UFloat64Msg() : URosMessageBase("std_msgs/Float64") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UFloat64Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UFloat64Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(float& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(float data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | double m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Float64MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Float64MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Float64MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UFloat64MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UFloat64MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UFloat64MultiArrayMsg() : URosMessageBase("std_msgs/Float64MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UFloat64MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UFloat64MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/HeaderMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Header ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "RosMessageBase.h" 12 | #include "HeaderMsg.generated.h" 13 | 14 | //============================================================================== 15 | // CLASS DECLARATION 16 | //============================================================================== 17 | 18 | UCLASS(BlueprintType) 19 | class UNREALROS_API UHeaderMsg : public URosMessageBase 20 | { 21 | 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | //-------------------------------------------------------------------------- 27 | // Name: UHeaderMsg constructor 28 | // Description: Default constructor. 29 | //-------------------------------------------------------------------------- 30 | UHeaderMsg() : URosMessageBase("std_msgs/Header") 31 | { 32 | 33 | }; 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: UHeaderMsg destructor 37 | // Description: Default destructor. 38 | //-------------------------------------------------------------------------- 39 | ~UHeaderMsg() override 40 | { 41 | 42 | } 43 | 44 | //-------------------------------------------------------------------------- 45 | // Name: get_json 46 | // Description: Gets the JSON object corresponding to the message. 47 | // Returns: JSON object corresponding to the message. 48 | //-------------------------------------------------------------------------- 49 | json get_json() override 50 | { 51 | json json; 52 | json["seq"] = m_seq; 53 | json["stamp"]["secs"] = m_secs; 54 | json["stamp"]["nsecs"] = m_nsecs; 55 | json["frame_id"] = m_frame_id; 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | m_seq = json["seq"]; 67 | m_secs = json["stamp"]["secs"]; 68 | m_nsecs = json["stamp"]["nsecs"]; 69 | m_frame_id = json["frame_id"].get(); 70 | } 71 | 72 | //-------------------------------------------------------------------------- 73 | // Name: get_contents 74 | // Description: Gets the contents of the ROS message. 75 | // Arguments: - data: message data 76 | //-------------------------------------------------------------------------- 77 | UFUNCTION(BlueprintPure, Category = "ROS") 78 | void get_contents(int& seq, int& sec, int& nsec, FString& frame_id) 79 | { 80 | seq = static_cast(m_seq); 81 | sec = static_cast(m_secs); 82 | nsec = static_cast(m_nsecs); 83 | frame_id = FString(m_frame_id.c_str()); 84 | } 85 | 86 | //-------------------------------------------------------------------------- 87 | // Name: set_contents 88 | // Description: Sets the contents of the ROS message. 89 | // Arguments: - data: message data 90 | //-------------------------------------------------------------------------- 91 | UFUNCTION(BlueprintCallable, Category = "ROS") 92 | void set_contents(int seq, int secs, int nsecs, FString frame_id) 93 | { 94 | m_seq = static_cast(seq); 95 | m_secs = static_cast(secs); 96 | m_nsecs = static_cast(nsecs); 97 | m_frame_id = std::string(TCHAR_TO_UTF8(*frame_id)); 98 | } 99 | 100 | private: 101 | 102 | uint32 m_seq; 103 | int32 m_secs; 104 | int32 m_nsecs; 105 | std::string m_frame_id; 106 | 107 | }; 108 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int16Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int16 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Int16Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UInt16Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UInt16Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UInt16Msg() : URosMessageBase("std_msgs/Int16") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UInt16Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UInt16Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | int16_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int16MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int16MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Int16MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UInt16MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UInt16MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UInt16MultiArrayMsg() : URosMessageBase("std_msgs/Int16MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UInt16MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UInt16MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int32Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int32 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Int32Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UInt32Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UInt32Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UInt32Msg() : URosMessageBase("std_msgs/Int32") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UInt32Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UInt32Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | int32_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int32MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int32MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Int32MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UInt32MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UInt32MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UInt32MultiArrayMsg() : URosMessageBase("std_msgs/Int32MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UInt32MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UInt32MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int64Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int64 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Int64Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UInt64Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UInt64Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UInt64Msg() : URosMessageBase("std_msgs/Int64") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UInt64Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UInt64Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | int64_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int64MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int64MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Int64MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UInt64MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UInt64MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UInt64MultiArrayMsg() : URosMessageBase("std_msgs/Int64MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UInt64MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UInt64MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int8Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int8 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "Int8Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UInt8Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UInt8Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UInt8Msg() : URosMessageBase("std_msgs/Int8") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UInt8Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UInt8Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | int8_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/Int8MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Int8MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "Int8MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UInt8MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UInt8MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UInt8MultiArrayMsg() : URosMessageBase("std_msgs/Int8MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UInt8MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UInt8MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/MultiArrayDimensionMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/MultiArrayDimension ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "MultiArrayDimensionMsg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UMultiArrayDimensionMsg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UMultiArrayDimensionMsg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UMultiArrayDimensionMsg() : URosMessageBase("std_msgs/MultiArrayDimension") 33 | { 34 | 35 | }; 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UMultiArrayDimensionMsg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UMultiArrayDimensionMsg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["label"] = std::string(TCHAR_TO_UTF8(*m_label)); 55 | json["size"] = m_size; 56 | json["stride"] = m_stride; 57 | return json; 58 | } 59 | 60 | //-------------------------------------------------------------------------- 61 | // Name: from_json 62 | // Description: Populates the message fields from the given JSON object. 63 | // Arguments: - json: JSON object to populate message fields from 64 | //-------------------------------------------------------------------------- 65 | void from_json(json json) override 66 | { 67 | std::string label_string = json["label"]; 68 | m_label = FString(label_string.c_str()); 69 | m_size = json["size"]; 70 | m_stride = json["stride"]; 71 | } 72 | 73 | //-------------------------------------------------------------------------- 74 | // Name: get_contents 75 | // Description: Gets the contents of the ROS message. 76 | // Arguments: - data: message data 77 | //-------------------------------------------------------------------------- 78 | UFUNCTION(BlueprintPure, Category = "ROS") 79 | void get_contents(FString& label, int& size, int& stride) 80 | { 81 | label = m_label; 82 | size = static_cast(m_size); 83 | stride = static_cast(m_stride); 84 | } 85 | 86 | //-------------------------------------------------------------------------- 87 | // Name: set_contents 88 | // Description: Sets the contents of the ROS message. 89 | // Arguments: - data: message data 90 | //-------------------------------------------------------------------------- 91 | UFUNCTION(BlueprintCallable, Category = "ROS") 92 | void set_contents(FString label, int size, int stride) 93 | { 94 | m_label = label; 95 | m_size = static_cast(size); 96 | m_stride = static_cast(stride); 97 | } 98 | 99 | private: 100 | 101 | // Label of given dimension 102 | FString m_label = ""; 103 | 104 | // Size of given dimension(in type units) 105 | uint32 m_size = 0; 106 | 107 | // Stride of given dimension 108 | uint32 m_stride = 0; 109 | 110 | }; 111 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/MultiArrayLayoutMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/MultiArrayLayout ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayDimensionMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "MultiArrayLayoutMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UMultiArrayLayoutMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UMultiArrayLayoutMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UMultiArrayLayoutMsg() : URosMessageBase("std_msgs/MultiArrayLayout") 36 | { 37 | m_dim.Add(NewObject()); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UMultiArrayLayoutMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UMultiArrayLayoutMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | 57 | json json; 58 | 59 | auto dim_array = json::array(); 60 | for (int i = 0; i < m_dim.Num(); ++i) 61 | dim_array.push_back(m_dim[i]->get_json()); 62 | 63 | json["dim"] = dim_array; 64 | json["data_offset"] = m_data_offset; 65 | 66 | return json; 67 | 68 | } 69 | 70 | //-------------------------------------------------------------------------- 71 | // Name: from_json 72 | // Description: Populates the message fields from the given JSON object. 73 | // Arguments: - json: JSON object to populate message fields from 74 | //-------------------------------------------------------------------------- 75 | void from_json(json json_message) override 76 | { 77 | 78 | json dim_array = json_message["dim"]; 79 | TArray dim; 80 | for (const auto& item : dim_array) 81 | { 82 | UMultiArrayDimensionMsg* new_dim = NewObject(); 83 | new_dim->from_json(item); 84 | dim.Push(new_dim); 85 | } 86 | 87 | m_dim = dim; 88 | m_data_offset = json_message["data_offset"]; 89 | 90 | } 91 | 92 | //-------------------------------------------------------------------------- 93 | // Name: get_contents 94 | // Description: Gets the contents of the ROS message. 95 | // Arguments: - data: message data 96 | //-------------------------------------------------------------------------- 97 | UFUNCTION(BlueprintPure, Category = "ROS") 98 | void get_contents(TArray& dim, int& data_offset) 99 | { 100 | dim = m_dim; 101 | data_offset = static_cast(m_data_offset); 102 | } 103 | 104 | //-------------------------------------------------------------------------- 105 | // Name: set_contents 106 | // Description: Sets the contents of the ROS message. 107 | // Arguments: - data: message data 108 | //-------------------------------------------------------------------------- 109 | UFUNCTION(BlueprintCallable, Category = "ROS") 110 | void set_contents(TArray dim, int data_offset) 111 | { 112 | m_dim = dim; 113 | m_data_offset = static_cast(data_offset); 114 | } 115 | 116 | private: 117 | 118 | // Array of dimension properties 119 | TArray m_dim; 120 | 121 | // Padding elements at front of data 122 | uint32 m_data_offset = 0; 123 | 124 | }; 125 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/StringMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/String ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | // ROS message base class 11 | #include "RosMessageBase.h" 12 | 13 | // UE4 imports 14 | #include "CoreMinimal.h" 15 | #include "StringMsg.generated.h" 16 | 17 | //============================================================================== 18 | // CLASS DECLARATION 19 | //============================================================================== 20 | 21 | UCLASS(BlueprintType) 22 | class UNREALROS_API UStringMsg : public URosMessageBase 23 | { 24 | 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | //-------------------------------------------------------------------------- 30 | // Name: UStringMsg constructor 31 | // Description: Default constructor. 32 | //-------------------------------------------------------------------------- 33 | UStringMsg() : URosMessageBase("std_msgs/String") 34 | { 35 | 36 | }; 37 | 38 | //-------------------------------------------------------------------------- 39 | // Name: UStringMsg destructor 40 | // Description: Default destructor. 41 | //-------------------------------------------------------------------------- 42 | ~UStringMsg() override 43 | { 44 | 45 | } 46 | 47 | //-------------------------------------------------------------------------- 48 | // Name: get_json 49 | // Description: Gets the JSON object corresponding to the message. 50 | // Returns: JSON object corresponding to the message. 51 | //-------------------------------------------------------------------------- 52 | json get_json() override 53 | { 54 | json json; 55 | json["data"] = std::string(TCHAR_TO_UTF8(*m_data)); 56 | return json; 57 | } 58 | 59 | //-------------------------------------------------------------------------- 60 | // Name: from_json 61 | // Description: Populates the message fields from the given JSON object. 62 | // Arguments: - json: JSON object to populate message fields from 63 | //-------------------------------------------------------------------------- 64 | void from_json(json json) override 65 | { 66 | std::string data_string = json["label"]; 67 | m_data = FString(data_string.c_str()); 68 | } 69 | 70 | //-------------------------------------------------------------------------- 71 | // Name: get_contents 72 | // Description: Gets the contents of the ROS message. 73 | // Arguments: - data: message data 74 | //-------------------------------------------------------------------------- 75 | UFUNCTION(BlueprintPure, Category = "ROS") 76 | void get_contents(FString& data) 77 | { 78 | data = m_data; 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: set_contents 83 | // Description: Sets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintCallable, Category = "ROS") 87 | void set_contents(FString data) 88 | { 89 | m_data = data; 90 | } 91 | 92 | private: 93 | 94 | FString m_data; 95 | 96 | }; -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/TimeMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/Time ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "RosMessageBase.h" 12 | #include "TimeMsg.generated.h" 13 | 14 | //============================================================================== 15 | // CLASS DECLARATION 16 | //============================================================================== 17 | 18 | UCLASS(BlueprintType) 19 | class UNREALROS_API UTimeMsg : public URosMessageBase 20 | { 21 | 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | //-------------------------------------------------------------------------- 27 | // Name: UTimeMsg constructor 28 | // Description: Default constructor. 29 | //-------------------------------------------------------------------------- 30 | UTimeMsg() : URosMessageBase("std_msgs/Time") 31 | { 32 | 33 | }; 34 | 35 | //-------------------------------------------------------------------------- 36 | // Name: UTimeMsg destructor 37 | // Description: Default destructor. 38 | //-------------------------------------------------------------------------- 39 | ~UTimeMsg() override 40 | { 41 | 42 | } 43 | 44 | //-------------------------------------------------------------------------- 45 | // Name: get_json 46 | // Description: Gets the JSON object corresponding to the message. 47 | // Returns: JSON object corresponding to the message. 48 | //-------------------------------------------------------------------------- 49 | json get_json() override 50 | { 51 | json json; 52 | json["data"]["secs"] = m_secs; 53 | json["data"]["nsecs"] = m_nsecs; 54 | return json; 55 | } 56 | 57 | //-------------------------------------------------------------------------- 58 | // Name: from_json 59 | // Description: Populates the message fields from the given JSON object. 60 | // Arguments: - json: JSON object to populate message fields from 61 | //-------------------------------------------------------------------------- 62 | void from_json(json json) override 63 | { 64 | m_secs = json["data"]["secs"]; 65 | m_nsecs = json["data"]["nsecs"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& secs, int& nsecs) 75 | { 76 | secs = static_cast(m_secs); 77 | nsecs = static_cast(m_nsecs); 78 | } 79 | 80 | //-------------------------------------------------------------------------- 81 | // Name: set_contents 82 | // Description: Sets the contents of the ROS message. 83 | // Arguments: - data: message data 84 | //-------------------------------------------------------------------------- 85 | UFUNCTION(BlueprintCallable, Category = "ROS") 86 | void set_contents(int secs, int nsecs) 87 | { 88 | m_secs = static_cast(secs); 89 | m_nsecs = static_cast(nsecs); 90 | } 91 | 92 | private: 93 | 94 | int32_t m_secs; 95 | int32_t m_nsecs; 96 | 97 | }; 98 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt16Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt16 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "UInt16Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UUInt16Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UUInt16Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UUInt16Msg() : URosMessageBase("std_msgs/UInt16") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UUInt16Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UUInt16Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | uint16_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt16MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt16MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "UInt16MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UUInt16MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UUInt16MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UUInt16MultiArrayMsg() : URosMessageBase("std_msgs/UInt16MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UUInt16MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UUInt16MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt32Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt32 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "UInt32Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UUInt32Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UUInt32Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UUInt32Msg() : URosMessageBase("std_msgs/UInt32") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UUInt32Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UUInt32Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | uint32_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt32MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt32MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "UInt32MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UUInt32MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UUInt32MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UUInt32MultiArrayMsg() : URosMessageBase("std_msgs/UInt32MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UUInt32MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UUInt32MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt64Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt64 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "UInt64Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UUInt64Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UUInt64Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UUInt64Msg() : URosMessageBase("std_msgs/UInt64") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UUInt64Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UUInt64Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | uint64_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt64MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt64MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "UInt64MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UUInt64MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UUInt64MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UUInt64MultiArrayMsg() : URosMessageBase("std_msgs/UInt64MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UUInt64MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UUInt64MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt8Msg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt8 ROS message and its interface with 5 | // JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // UE4 imports 13 | #include "CoreMinimal.h" 14 | #include "UInt8Msg.generated.h" 15 | 16 | //============================================================================== 17 | // CLASS DECLARATION 18 | //============================================================================== 19 | 20 | UCLASS(BlueprintType) 21 | class UNREALROS_API UUInt8Msg : public URosMessageBase 22 | { 23 | 24 | GENERATED_BODY() 25 | 26 | public: 27 | 28 | //-------------------------------------------------------------------------- 29 | // Name: UUInt8Msg constructor 30 | // Description: Default constructor. 31 | //-------------------------------------------------------------------------- 32 | UUInt8Msg() : URosMessageBase("std_msgs/UInt8") 33 | { 34 | 35 | } 36 | 37 | //-------------------------------------------------------------------------- 38 | // Name: UUInt8Msg destructor 39 | // Description: Default destructor. 40 | //-------------------------------------------------------------------------- 41 | ~UUInt8Msg() override 42 | { 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------------- 47 | // Name: get_json 48 | // Description: Gets the JSON object corresponding to the message. 49 | // Returns: JSON object corresponding to the message. 50 | //-------------------------------------------------------------------------- 51 | json get_json() override 52 | { 53 | json json; 54 | json["data"] = m_data; 55 | return json; 56 | } 57 | 58 | //-------------------------------------------------------------------------- 59 | // Name: from_json 60 | // Description: Populates the message fields from the given JSON object. 61 | // Arguments: - json: JSON object to populate message fields from 62 | //-------------------------------------------------------------------------- 63 | void from_json(json json) override 64 | { 65 | m_data = json["data"]; 66 | } 67 | 68 | //-------------------------------------------------------------------------- 69 | // Name: get_contents 70 | // Description: Gets the contents of the ROS message. 71 | // Arguments: - data: message data 72 | //-------------------------------------------------------------------------- 73 | UFUNCTION(BlueprintPure, Category = "ROS") 74 | void get_contents(int& data) 75 | { 76 | data = static_cast(m_data); 77 | } 78 | 79 | //-------------------------------------------------------------------------- 80 | // Name: set_contents 81 | // Description: Sets the contents of the ROS message. 82 | // Arguments: - data: message data 83 | //-------------------------------------------------------------------------- 84 | UFUNCTION(BlueprintCallable, Category = "ROS") 85 | void set_contents(int data) 86 | { 87 | m_data = static_cast(data); 88 | } 89 | 90 | private: 91 | 92 | uint8_t m_data; 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /Source/UnrealROS/Public/std_msgs/UInt8MultiArrayMsg.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Unreal ROS Plugin 3 | // 4 | // Description: Defines the std_msgs/UInt8MultiArray ROS message and its 5 | // interface with JSON. 6 | //============================================================================== 7 | #pragma once 8 | 9 | // ROS message base class 10 | #include "RosMessageBase.h" 11 | 12 | // Message dependencies 13 | #include "MultiArrayLayoutMsg.h" 14 | 15 | // UE4 imports 16 | #include "CoreMinimal.h" 17 | #include "UInt8MultiArrayMsg.generated.h" 18 | 19 | //============================================================================== 20 | // CLASS DECLARATION 21 | //============================================================================== 22 | 23 | UCLASS(BlueprintType) 24 | class UNREALROS_API UUInt8MultiArrayMsg : public URosMessageBase 25 | { 26 | 27 | GENERATED_BODY() 28 | 29 | public: 30 | 31 | //-------------------------------------------------------------------------- 32 | // Name: UUInt8MultiArrayMsg constructor 33 | // Description: Default constructor. 34 | //-------------------------------------------------------------------------- 35 | UUInt8MultiArrayMsg() : URosMessageBase("std_msgs/UInt8MultiArray") 36 | { 37 | m_layout = NewObject(); 38 | }; 39 | 40 | //-------------------------------------------------------------------------- 41 | // Name: UUInt8MultiArrayMsg destructor 42 | // Description: Default destructor. 43 | //-------------------------------------------------------------------------- 44 | ~UUInt8MultiArrayMsg() override 45 | { 46 | 47 | } 48 | 49 | //-------------------------------------------------------------------------- 50 | // Name: get_json 51 | // Description: Gets the JSON object corresponding to the message. 52 | // Returns: JSON object corresponding to the message. 53 | //-------------------------------------------------------------------------- 54 | json get_json() override 55 | { 56 | json json; 57 | json["layout"] = m_layout->get_json(); 58 | for (auto item : m_data) 59 | json["data"].push_back(item); 60 | return json; 61 | } 62 | 63 | //-------------------------------------------------------------------------- 64 | // Name: from_json 65 | // Description: Populates the message fields from the given JSON object. 66 | // Arguments: - json: JSON object to populate message fields from 67 | //-------------------------------------------------------------------------- 68 | void from_json(json json) override 69 | { 70 | 71 | UMultiArrayLayoutMsg* layout = NewObject(); 72 | layout->from_json(json["layout"]); 73 | m_layout = layout; 74 | 75 | m_data.Empty(); 76 | for (auto item : json["data"]) 77 | m_data.Push(item); 78 | 79 | } 80 | 81 | //-------------------------------------------------------------------------- 82 | // Name: get_contents 83 | // Description: Gets the contents of the ROS message. 84 | // Arguments: - data: message data 85 | //-------------------------------------------------------------------------- 86 | UFUNCTION(BlueprintPure, Category = "ROS") 87 | void get_contents(UMultiArrayLayoutMsg*& layout, TArray& data) 88 | { 89 | layout = m_layout; 90 | data.Empty(); 91 | for (size_t i = 0; i < m_data.Num(); i++) 92 | data.Add(static_cast(m_data[i])); 93 | } 94 | 95 | //-------------------------------------------------------------------------- 96 | // Name: set_contents 97 | // Description: Sets the contents of the ROS message. 98 | // Arguments: - data: message data 99 | //-------------------------------------------------------------------------- 100 | UFUNCTION(BlueprintCallable, Category = "ROS") 101 | void set_contents(UMultiArrayLayoutMsg* layout, TArray data) 102 | { 103 | m_layout = layout; 104 | m_data.Empty(); 105 | for (size_t i = 0; i < data.Num(); i++) 106 | m_data.Add(static_cast(data[i])); 107 | } 108 | 109 | private: 110 | 111 | // Specification of data layout 112 | UMultiArrayLayoutMsg* m_layout; 113 | 114 | // Array of data 115 | TArray m_data; 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /Source/UnrealROS/UnrealROS.Build.cs: -------------------------------------------------------------------------------- 1 | 2 | using UnrealBuildTool; 3 | 4 | public class UnrealROS : ModuleRules 5 | { 6 | public UnrealROS(ReadOnlyTargetRules Target) : base(Target) 7 | { 8 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 9 | 10 | PublicIncludePaths.AddRange( 11 | new string[] { 12 | // ... add public include paths required here ... 13 | } 14 | ); 15 | 16 | 17 | PrivateIncludePaths.AddRange( 18 | new string[] { 19 | // ... add other private include paths required here ... 20 | } 21 | ); 22 | 23 | 24 | PublicDependencyModuleNames.AddRange( 25 | new string[] 26 | { 27 | "Core", 28 | // ... add other public dependencies that you statically link with here ... 29 | } 30 | ); 31 | 32 | 33 | PrivateDependencyModuleNames.AddRange( 34 | new string[] 35 | { 36 | "CoreUObject", 37 | "Engine", 38 | "Slate", 39 | "SlateCore", 40 | "Sockets", 41 | "Networking" 42 | // ... add private dependencies that you statically link with here ... 43 | } 44 | ); 45 | 46 | 47 | DynamicallyLoadedModuleNames.AddRange( 48 | new string[] 49 | { 50 | // ... add any modules that your module loads dynamically here ... 51 | } 52 | ); 53 | } 54 | } -------------------------------------------------------------------------------- /UnrealROS.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "0.1", 5 | "FriendlyName": "Unreal Engine ROS Plugin", 6 | "Description": "Provides a ROS message publish/subscribe interface over TCP using the rosbridge protocol.", 7 | "Category": "ROS", 8 | "CreatedBy": "Abyss Robotics", 9 | "CreatedByURL": "https://github.com/AbyssRobotics/UnrealROS", 10 | "DocsURL": "https://github.com/AbyssRobotics/UnrealROS", 11 | "MarketplaceURL": "", 12 | "SupportURL": "https://github.com/AbyssRobotics/UnrealROS", 13 | "CanContainContent": true, 14 | "IsBetaVersion": true, 15 | "Installed": false, 16 | "Modules": [ 17 | { 18 | "Name": "UnrealROS", 19 | "Type": "Runtime", 20 | "LoadingPhase": "PreLoadingScreen" 21 | } 22 | ] 23 | } --------------------------------------------------------------------------------