lgsvl / simulator

A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Other
2.27k stars 780 forks source link

Import URDF files #31

Closed ajithkrishnan closed 5 years ago

ajithkrishnan commented 5 years ago

Hi, I am working on a project where i have to import an existing rover model (complete with meshes, joints and tf tree in the form of urdf files) into the existing simulation.

Is there an out of the box way to do this? I am relatively new to Unity and would like to avoid having to design the rover from scratch inside the Engine itself.

EDIT: I am using Ubuntu 16.04

Thanks.

hadiTab commented 5 years ago

@ajithkrishnan at the moment there is no simple way to import a rover model over using the URDF. You would unfortunately need to either model the rover or find an existing model elsewhere and import it. The positions of the sensors can be easily modified to match your URDF, however, things like the distance between the wheels, steering angle, wheel diameter, etc. would need also need to match your URDF if you intend on simulating the vehicle motion accurately.

ajithkrishnan commented 5 years ago

@hadiTab Thanks for responding. I have found that Unity has a URDF Importer in its Asset Store that runs on Linux. Hopefully that should work for now.

As a side note, could you give instructions on how to read/write sensor data in Unity? I would like to publish msgs like PointCloud2, Odometry and Twist messages onto ROS topics so as to process them in ROS or visualize in RVIZ.

EDIT: I have seen that bootstrap.sh launches the roscore and publishes onto some rostopics (like /apollo/control/pad of type pb_msgs/PadMessage. I would like to some sensors inside the editor and have them publish onto a topic like this.

hadiTab commented 5 years ago

@ajithkrishnan we have not tested the URDF importer for Unity yet. Let us know how it goes!

The sensors on the vehicle are currently publishing to rostopics. For example, the lidar message is published on a PointCloud2 message type. The topic names and message types we are using are based on requirements by apollo and autoware.

For example, look at the source code for the IMU sensor. This only appears in the vehicle specified for Apollo and publishes a message of type pb_msgs/Imu. This message type is defined in the Ros namespace, in Assets/Scripts/Ros/PbMsgs.cs. If you, for example, wish to publish imu messages using the Sensor_msgs/Imu, you would need to define this message type in a similar manner and modify ImuSensor.cs to publish this message type.

I suggest you look at components already in the simulator which publish to get a better idea. They will be under Assets/Scripts/. For example, GpsDevice.cs or CanBus.cs.

ajithkrishnan commented 5 years ago

@hadiTab URDF Importer works out of the box. So i would recommend using it. Just make sure to convert your xacros files (if any) to urdf, since URDF Importer doesn't support xacro files.

Thank you for the info regarding the sensors. Will take a look into it as soon as i am done importing a working car model into the simulator.

hadiTab commented 5 years ago

@ajithkrishnan thanks that is good to know! I'll make sure to check it out shortly.

I'll close this issue for now since it seems to be solved. Feel free to reopen it if needed.