Search Unity

Nao Robot and Unity3d

Discussion in 'Scripting' started by joduffy, May 11, 2014.

  1. joduffy

    joduffy

    Joined:
    Jul 30, 2011
    Posts:
    34
    Hi Guys,

    What I am trying to do is get the Nao Robot working inside of unity3d.

    Here is a link to the Nao:


    They use python, c++, java and .net as options for programming for the Nao.

    Here is a link to their docs on python scripting:
    https://community.aldebaran-robotics.com/doc/1-14/dev/python/index.html#python-introduction

    When I try and use their .net2 stuff I get the following error though:

    MissingMethodException: Method contains unsupported native code
    <Module>.<CrtImplementationDetails>.LanguageSuppor t.Initialize (<CrtImplementationDetails>.LanguageSupport* )
    <Module>..cctor ()

    Here is the code using C# and Playmaker:

    Code (csharp):
    1.  
    2. // (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
    3.  
    4. using UnityEngine;
    5. using System;
    6. using System.Runtime.InteropServices;
    7. using HutongGames.PlayMaker;
    8. using Aldebaran.Proxies;
    9.  
    10. namespace HutongGames.PlayMaker.Actions
    11. {
    12.  
    13.     [ActionCategory("Nao")]
    14.     [Tooltip("Gets the Nao to say something.")]
    15.     public class NaoTalk : FsmStateAction
    16.     {
    17.         public FsmString naoIPAddress = "10.0.1.2";
    18.         public FsmInt port = 9559;
    19.         public FsmString naoSpeech = "Hello Human";
    20.  
    21.         public override void OnEnter()
    22.         {
    23.             NaoSpeak();
    24.             Finish();
    25.         }
    26.  
    27.         private void NaoSpeak()
    28.         {
    29.             TextToSpeechProxy tts = new TextToSpeechProxy(naoIPAddress.Value, port.Value);
    30.             tts.say(naoSpeech.Value);
    31.         }
    32.  
    33.     }
    34.  
    35. }
    I did look online and it seems I have to use P/Invoke. But it looked like I would have to alter the existing code for the Nao to get it to work before I can use its functions in unity3d.

    I am also trying IronPython to see if I can get the python nao code to work. Unfortunately my experience with python is limited. I did get a package off the asset store and the developer replied to my email which is awesome.

    I just thought I would ask the Unity community to see if they can help me out. I just thought it would be cool to have the Nao working inside of Unity3d. Then you can do all sorts of applications and games with it. Such as augmented reality interaction etc.
     
  2. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Hey,

    You have made any progress on this?
     
  3. joduffy

    joduffy

    Joined:
    Jul 30, 2011
    Posts:
    34
    Hey dude,

    I talked to the Nao guys but they don't support Unity so in the end I ended up making a server and just using Http requests back and forth to control the Nao.
     
  4. Jean-Michel585

    Jean-Michel585

    Joined:
    Dec 9, 2014
    Posts:
    7
    Hi Joduffy,

    I would also connect to the NAO via Unity
    I think using the command Network.Connect()
    Is this the right way?
    Have you succeeded in controlling NAO?
    Do you have a piece of code?

    Thank you in advance
     
    gfaline likes this.
  5. joduffy

    joduffy

    Joined:
    Jul 30, 2011
    Posts:
    34
    Hi Dude,

    Its been a while since I worked on the project. I did manage to get it working in the end:



    I can try and find the project and take a look how I did it.
     
    gfaline likes this.
  6. gskhaled

    gskhaled

    Joined:
    Feb 20, 2020
    Posts:
    1
    Were you able to find the project to tell us more about it?
    Thank you.