Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Change ROS_IP Address to build

Discussion in 'Robotics' started by Kam0ss, Oct 19, 2021.

  1. Kam0ss

    Kam0ss

    Joined:
    Mar 11, 2021
    Posts:
    4
    Hello,

    I am trying to build a project with a different ROS_IP Address than 127.0.0.1 because my ROS node is running on another computer.
    It works when I press Play but I can't find where to change that in the Build Settings (if that's even where I am supposed to change it).

    Thank you !
    Kam0ss
     
  2. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Hi, this setting is in the Robotics/Ros Settings menu.
    Alternatively you can place a ROSConnection component in your scene and change the setting there.
     
  3. Kam0ss

    Kam0ss

    Joined:
    Mar 11, 2021
    Posts:
    4
    Hi,

    I have modified the setting in the Robotics/ROS Settings menu but the parameter doesn't seem to stick.
    And I get this error while changing the Address :
    upload_2021-10-19_13-57-37.png

    And I just noticed this comment in the code in the file mentionned in the error :
    upload_2021-10-19_13-59-5.png
    So I guess, I'll have to wait for a future update ? Or is there a way I can do it myself ?


    [EDIT]

    I added the ROSConnection script in my ROSConnection component, I didn't realize I could do it this way before, thanks !

    I seem to have two ROS connections :
    upload_2021-10-19_14-26-28.png

    I will test it later as I don't have the second computer with ROS and will let you know if everything works !

    Thank you !
     
    Last edited: Oct 19, 2021
  4. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Hi, I'll make a ticket to clean up that commented out code, but it shouldn't cause any problems - it's the next line PrefabUtility.SavePrefabAsset(prefab.gameObject) that actually saves the data.

    I'm not sure why you're getting the error that you're getting - HUDPanel is certainly a MonoBehaviour. It suggests to me that your project is failing to compile; are you getting any other errors in your console?
     
  5. Kam0ss

    Kam0ss

    Joined:
    Mar 11, 2021
    Posts:
    4
    I edited my post before seeing your answer, I think it will work.

    I don't have any other error and this error happens just when I am typing the new address, and it stops when I am done typing.
     
  6. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Interesting. I would guess you're getting two ros connections because you're calling ROSConnection.GetOrCreateInstance very early in the startup process, maybe during an Awake function? If you move that to a Start function it should work.
    (The ROSConnection in your scene will register itself as the global ROSConnection during its Awake, which happens before Start. After that has happened, calling GetOrCreateInstance will return the one from the scene, instead of creating a new one. Actually, thanks for bringing this to my attention, I'll make it work better.)
     
  7. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Ok, I see why the error is appearing; the HudPanel class is defined in a file called HUDPanel.cs, and under certain conditions Unity is case sensitive about that.
     
  8. Kam0ss

    Kam0ss

    Joined:
    Mar 11, 2021
    Posts:
    4
    It looks like it's working and I have just one connection, the other day must have been just a bug.

    Thanks for the help !