PART 1: UE4Duino Plugin
This instruction will be about how to "make friends" UE4 and Arduino, so the goal is to read data from Arduino into UE project to process it and write it back.
I found amazing plugin UE4Duino which allows to connect your Arduino to UE ( Thanks a lot to grizly32). For now UE4Duino is available for UE 4.10 and previous versions, so we are waiting this plugin for UE 4.11.
Installation:
All you need is to download UE4Duino for your UE4 version and unpack it into Plugins folder in your project folder (there is no Plugins folder in your project folder by defaul, so just create it). I put this plugin into engine folder and it works fine for me. But grizly32 recommends to put it into main project folder. I don't see any difference for now.
Description:
UE4Duino use a COM port which Arduino board is connected to.
So you need to set port number in "PortNum" and "BaudRate" fields of "OpenSerial" node and connect it with a "EventBeginPlay" node in a Blueprint (I did it in FirstPersonCharacter Blueprint).
Be sure that Arduino IDE does not use this port, I mean Serial Monitor or Serial Plotter is closed, otherwise you can't read data in UE4. And on the contrary, Arduino IDE can't read data from board while this port is open in UDK. So the best way is to use "CloseSerial" node connected with "EventEndPlay" node. By this way UE open a port when you start your project and close it when you stop a project.
Once a COM port is open it is time to read data from Arduino board. To do it, you should connect "ReadSerial" node to, for example "EventTick" node. Return value is String, and I converted it into Float to make some calculations on received data.
The same way with "WriteSerial" node. You can transmit data to Arduino board from other nodes connected to "WriteData" or you can set it in the field.
To sum up, UE4Duino is pretty easy to use plugin and it works perfect.
I noticed UE4 didn't receive any data from my board when it was connected to PC after UE4 have been ran. So firstly connect Arduino board and then run UE4.
Комментариев нет:
Отправить комментарий