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

Question How to publish tf from unity

Discussion in 'Robotics' started by vermahrithik10, Jan 19, 2022.

  1. vermahrithik10

    vermahrithik10

    Joined:
    Jan 10, 2022
    Posts:
    12
    I have successfully imported my robot urdf to unity. Now, I want to know How to publish all robot frame from unity to ros.
    I also check Robotics-Nav2-SLAM-Example, I read about ROSTransformTreePublisher.
    So, I also copied Clock,TimeStamp,TransformExtensions,TransformTreeNode,ROSTransformTreePublisher c# scripts in my scripts folder. But this has some compilation error. I don't understand how to solve this:
    upload_2022-1-19_17-14-11.png

    Or is there another way to publish robot tf_tree from unity to ros.
    Please help me
     

    Attached Files:

  2. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    It looks like you're trying to use some code that was written for ROS2, but you haven't enabled the ROS2 compiler flag in the Robotics/ROS settings menu.
    (Specifically, Header messages have one fewer field in ROS2, which is why you're getting the error about "no argument given" - in ROS1 the HeaderMsg constructor expects an extra argument. There are also some data type differences in the Time and Duration messages, which will be causing the int/uint error.)
     
  3. vermahrithik10

    vermahrithik10

    Joined:
    Jan 10, 2022
    Posts:
    12
    @LaurieUnity Thanks for the reply. Is there a way to use this files for ros 1 ? Or maybe any way to publish tf_tree in ros1 from unity.
     
  4. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Sure, it should be fairly simple to get this code working under ROS1 - just fix the compile errors. Pass that extra argument to the HeaderMsg constructor (it's the first argument, "seq" - you can just pass 0), and add an (int) cast to stop it complaining about the uint/int mismatch.
     
  5. mig_seixas

    mig_seixas

    Joined:
    Jul 30, 2021
    Posts:
    2
    Hi, using ROSTransforTreePublisher to publish some tf I'm facing this problem, gi below.

    my tf tree is: odom=>base_footprint=>base_link=>(camera_link, imu_link, lidar_link)

    Odom tf is fixed and it's OK.

    The misbehavior are the robot's tf, when simulation is running and the robot is moving they get wrong position or getting wrong velocity.

    The base_footprint, base_link and the sensor's tf should moving together.

     
  6. AutoAICU

    AutoAICU

    Joined:
    May 17, 2023
    Posts:
    1
    @mig_seixas did you find the reason for this? and the way to solve it?