Announcement

Collapse
No announcement yet.

[Free][Windows only] UE4Duino 2 - Arduino (COM port) communication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    I´m having trouble running UE4Duino. I created a new project and put ue4Duino (correct version) inside Plugins Folder. When I try to open the project it says "failed to load plugin ue4duino because module could not loaded" And the project closes. I tried with version 4.23.1 and also 4.24.1 (I downloaded the two engine versions)
    Click image for larger version  Name:	Imagem1.png Views:	7 Size:	36.7 KB ID:	1729841

    UPDATE:
    I managed to solve it. If someone is experiencing the same, try this:
    1. Check if Visual Studio is installed with "game development with C++".
    2. Create a unreal blank project with C++ and not Blueprint
    3. Create Plugins Folder under the project folder and put inside all ue4duino files without Binaries folder (delete it).
    4. Wait until the unreal project load and select rebuild plugin, when asked.
    5. After that, copy this ue4duino folder with your recompiled binaries to whatever project you want, including VR templates using only blueprints.
      that is it!
    Last edited by johnpaullima; 03-10-2020, 08:39 AM.

    Leave a comment:


  • replied
    Got it, thanks for the proposition I will try to do it cause I only know C# for now lol, I see so much potential with it, like including of VR controller support made with Arduino in UE4 directly, without the need of SteamVR and Windows driver USB setup, the dream
    Last edited by Haeath; 02-27-2020, 01:38 PM.

    Leave a comment:


  • replied
    Originally posted by Haeath View Post
    Cool project.

    Do you plan to add the HID protocol support too ?

    I wrote this to be able to do that in Arduino-side: https://www.codeproject.com/Tips/125...g-HID-Protocol

    And I am using this: https://www.codeproject.com/Articles...ices-using-HID for PC-side

    But I wonder if we can bypass it and do it in UE4 directly with your method.
    That's very interesting!
    Well, lately I've been super busy with work, so I try to, at least, keep the plugin's binaries and code up to date with new UE4 versions. But if you implement that in the plugin, do a pull request to the Git repo and I'd gladly make it a part of it.
    Although, it looks like something only very advanced users would try, with the replacement of Arduino libraries and all.

    Leave a comment:


  • replied
    RVillani

    Thank you. I did not know that. My stuff builds now.

    Leave a comment:


  • replied
    Cool project.

    Do you plan to add the HID protocol support too ?

    I wrote this to be able to do that in Arduino-side: https://www.codeproject.com/Tips/125...g-HID-Protocol

    And I am using this: https://www.codeproject.com/Articles...ices-using-HID for PC-side

    But I wonder if we can bypass it and do it in UE4 directly with your method.
    Last edited by Haeath; 02-17-2020, 11:03 AM.

    Leave a comment:


  • replied
    Originally posted by COMET-35 View Post
    Hello RVillani,
    I was trying to include the Serial.h file in a custom c++ class but I keep getting this error.
    Error C1083 Cannot open include file: 'Serial.h': No such file or directory
    I did make sure to add the path of the header file to my VC++ Directories include directories.in my project properties. Unfortunately Visual Studio still can't find the header file.
    I am using the latest version of UE4Duino.
    Any help would be appreciated. Thank you and have a nice day.
    You don't want to change the project settings. Those will be overwritten when you do Generate Project Files (and we always have to do it again every once in a while).
    What you need to do in order to use the plugin in C++ code is to add it to your module's dependencies, in its Build.cs file.

    For instance, if your project is called MyProject, it'll be Source\MyProject\MyProject.Build.cs.
    On that file, add "UE4Duino" to your PrivateDependencyModuleNames. So, if UE4Duino is the first module you're adding there, it'll look like
    Code:
    PrivateDependencyModuleNames.AddRange(new string[] { "UE4Duino" });
    Unreal Build Tool will then understand you want to use the UE4Duino module on your project's main module and automatically know where to include and link stuff from.
    Besides that, you need to have the plugin in a Plugins folder and enabled in your project.

    Leave a comment:


  • replied
    Hello RVillani,

    I was trying to include the Serial.h file in a custom c++ class but I keep getting this error.

    Error C1083 Cannot open include file: 'Serial.h': No such file or directory

    I did make sure to add the path of the header file to my VC++ Directories include directories.in my project properties. Unfortunately Visual Studio still can't find the header file.

    I am using the latest version of UE4Duino.

    Any help would be appreciated. Thank you and have a nice day.

    Leave a comment:


  • replied
    Great, thanks for the tips, RVillani!

    Leave a comment:


  • replied
    Originally posted by DickKickem. View Post
    Code:
    float floatVal = 23.56;
    byte *b = (byte *)&floatVal;
    
    Serial.write(0xFE);
    
    int i;
    for (i = 0; i < 5; i ++){
    Serial.write(b[i]);
    }
    That's cool! Thanks!
    I suggest two improvements:
    1. use two control bytes, to make sure a single byte from the float doesn't get interpreted as a control byte with the same value. Two in a row would be harder to happen.
    2. on the for, check for i < 4. Right now you are trying to read until b[4], which is an invalid index for 4 bytes. I don't know how Arduino recovers from that, but it would be a crash on PC.

    Leave a comment:


  • replied
    I don't know if anyone has posted this yet, but I've been trying to get reliable data from Arduino, to no avail.

    Then, I stumbled upon RVillani's idea of having a protocol and made a similar setup. Hopefully, it'll help someone.

    On the Arduino, you need to add a "control" byte which tells UE where the data (float, int, etc.) starts:

    Code:
    Serial.write(0xFE);
    After this, convert your variable into an array of bytes:

    Code:
    float floatVal = 23.56;
    byte *b = (byte *)&floatVal;
    
    Serial.write(0xFE);
    
    int i;
    for (i = 0; i < 5; i ++){   
        Serial.write(b[i]);
    }
    Then, in UE, you check for the control byte, then reassemble everything (minus the control byte):

    Click image for larger version

Name:	Annotation-20200212-121724.png
Views:	140
Size:	159.6 KB
ID:	1720239

    Everything works like a charm, no more garbled data.
    Hope this helps!

    Leave a comment:


  • replied
    For some reason, Ahmedck can't post here. So here is his question. I hope someone can help him.

    Hello i just want help with my school project as i dont have alot of time left i need to move the character inside unreal engine with the help of arduino and i am not able to do so i tried every way i could but i really dont understand how to link the character so it moves , i never used arduino i tried to find tutorials from all over the internet but i really dont understand how they link there unreal characters with i followed the tutorial provided by RVillani and the port got opened but i couldn't move the character i was hoping that someone here could help me out with this and provide me with some blueprint or arduino as i am already approaching the deadline

    Leave a comment:


  • replied
    Ahmedck Comkiled95 faos1970 Guys, the forums are bugged and I can't see your DMs. It looks like you can't see mine as well.
    So please, if it's not something private, send your messages here. You'll also help others with the same questions.
    Otherwise you can send-me an e-mail here

    Leave a comment:


  • replied
    Ok Ok. I had a hard time getting this plugin to work in a final build. But I did it and now I want to help.

    Here is MY step by step succes formula:

    Have the right visiual studio installed!

    1. Download the plugin (for your Ue4 version).
    2. Make a plugins folder inside your project.
    3. Place the plugin inside the plugins folder of your project.
    4. Start your project.
    5. Activate your plugin in the edit/plugins window.
    6. restart UE4
    7. Make something usefull with the plugin as shown in previous posts. Dont forget to close the port on endgame!!
    8. Go to edit/plugins ue4duino, You should see a package button.
    9. Package the plugin inside your ENGINE/plugins folder (this is somehow needed to get the versions matching (took me ages to get this right)).
    10. I repeat!! The plugin is now in your engine folder. The folder were your engine is installed (not your project folder).
    11. Delete the plugin inside your projects folder. Else you get same key stuff errors when building.
    12. Start Ue4, everything should work fine now with the plugin inside your engine folder.
    13. Package,Cook, build, compile or use pak files (no clue what all these words mean)
    14. Forget 13. just Package for win 64 developemen dont use pak files (you want to check something)
    15. You endup with a WindowsNoEditor/Engine/Plugins/Ue4Duino/UE4Duino.Uplgin file

    Double click "projectname"/Saved/StagedBuids/WindowsNoEditor/"Your project-shortcut"

    Now everything should work!

    I am not a coder so maybe I talk out of my ...

    Please correct me when wrong!

    Hope it helps someone.

    Greetings Games_master_Jodan.
    Last edited by game_master_jodan; 02-09-2020, 09:06 AM.

    Leave a comment:


  • replied
    Originally posted by HysiK View Post
    Hi all UE4Duino users and really thanks for your great work [MENTION=30654]RVillani[/MENTION] .
    I am testing some arduino + blueprint codes without success so far and I kindly ask for help.
    [ATTACH=CONFIG]152467[/ATTACH][ATTACH=CONFIG]152468[/ATTACH]
    Those images are my Arduino code and my blueprint code, I do not know what I am doing wrong my main goal is sending from UE4 string ON to Arduino and Arduino must read it and activate 2 digital pins.
    EDIT: LogTemp:Error: Failed to open port COM3. Error: 00000006 this is what I have achieved, COM port is not opening neither working. Have tried so far, 3 differents usb ports + hub (2 ad 3.0).
    Any help? Really thanks and best regards!
    Have you checked if you use the right port inside your device manager? arduino tools port? your timeout time is 5 (seems short to me). Have you printed something succesfully inside the arduin API with the serial plotter? I use this:
    void loop(){


    #define RELAY1 6

    #define RELAY2 7

    #define RELAY3 8

    #define RELAY4 9

    long mydata = 0;




    void setup()

    {

    // Initialise the Arduino data pins for OUTPUT

    Serial.begin(2400);
    Serial.setTimeout(10);

    pinMode(RELAY1, OUTPUT);

    pinMode(RELAY2, OUTPUT);

    pinMode(RELAY3, OUTPUT);

    pinMode(RELAY4, OUTPUT);

    }



    void loop(){

    while (Serial.available() == 0) {}
    mydata = Serial.parseInt();
    if (mydata == 10){digitalWrite(RELAY1,LOW);}
    if (mydata == 11){digitalWrite(RELAY1,HIGH);}
    if (mydata == 20){digitalWrite(RELAY2,LOW);}
    if (mydata == 21){digitalWrite(RELAY2,HIGH);}
    if (mydata == 30){digitalWrite(RELAY3,LOW);}
    if (mydata == 31){digitalWrite(RELAY3,HIGH);}
    if (mydata == 40){digitalWrite(RELAY4,LOW);}
    if (mydata == 41){digitalWrite(RELAY4,HIGH);}
    }


    Trying to help (I am not a specialist), so Hope it helps

    Greatings Games_master_jodan
    Last edited by game_master_jodan; 02-07-2020, 07:36 PM.

    Leave a comment:


  • replied
    Originally posted by Ahmedck View Post
    RVillani i used UE4duino plugin i just wanna ask that if i need to move a third person character do i have to do coding at both ends or just open the port ? like i really dont understand how to move a third person character should i code in arduino IDE or inside unreal engine character blueprint or inside level blueprint ?
    The only logic you should do in Arduino is to send input to the PC. Think of it as if you were creating a generic controller to use in any game. It should output things like "analogX=-0.5; analogY=0.23".

    Then, in Unreal, you code to make it understand that "controller" input. I'd do that in a Blueprint that doesn't need to know about your specific character. It just outputs the inputs from Arduino. That way, you could use that Blueprint for any project with your custom Arduino controller.

    Then, after that is set up, you create a GameMode Blueprint, a PlayerController Blueprint and a Character/Pawn Blueprint.
    Make the GameMode's default classes be your custom PlayerController and Character Blueprints. Then, on your PlayerController, you use the inputs Blueprint to send commands to your Character Blueprint. Your Character Blueprint will have functions like "MoveForward", "Jump" etc, and the Player Controller calls those functions on it when the correct inputs come from the Arduino Blueprint. This way, your Character is not tied to one specific type of control, only your PlayerController is. And your PlayerController could be replaced by another one that controls your Character using different inputs. Or even control more Characters via possession/unpossession.

    That's why there's this pattern of GameMode, PlayerController and Pawn in Unreal. To make things independent of each other and easily reusable.

    If you don't care about being organized, you could just make everything I just said in the Character Blueprint, but if you'd like to reuse it some day on another project, with a totally different character, you will curse your past self for it haha

    Leave a comment:

Working...
X