ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to convert txt file with x y coordinates to Gazebo map

asked 2021-07-04 20:59:57 -0500

jabroni gravatar image

Hey,

I have a text file with a series of x,y coordinates that I use for a configuration which stores positions of boxes. My goal is to take these x y coordinates, import them to gazebo, and place boxes in those locations. However, I am unsure on how to start this. I am fairly new to the Gazebo platform so any point in the right direction would be great :)

Cheers.

Note: I am using Gazebo 11.6.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-05 11:53:28 -0500

shonigmann gravatar image

This is perhaps a more suitable question for gazebo answers.

Since you've tagged the question with ROS1, maybe you're looking for a way to do this with ROS?

Lightweight no-ROS solution (python/Gazebo): A lightweight option would be to write a quick python script that parses your text file and creates/modifies a .world file by adding <include> tags for your N boxes, and starts gazebo with that world file. I think this is the best approach if your environment doesn't change often and you don't mind closing gazebo between loading different text files.

Alternative approach (Gazebo/ROS): Similarly, you could write a python script that interfaces with gazebo_ros_pkgs' spawn_model script, to read your text file and dynamically spawn the boxes into the environment. You could run this script once in your launch file and it would set your environment up for you at launch. Con: each call to spawn_model spins up a process so it is a bit slower than creating a world file with the box locations predefined, especially if you have a large number of boxes. Again this is only really for cases where the boxes are in one location for the duration of the simulation.

Final approach - Changing box locations of pre-spawned boxes (Gazebo/ROS) - my recommendation if you want to change box locations while gazebo is still running: if you want to load new text files without killing the Gazebo server, you might want to consider having an initial .world file with all of the boxes preloaded (e.g. if you know you will always have less than 100 boxes), then using the Gazebo-ROS interface to simply set their poses. You'll have to keep track of names/indices but prespawning the models will make this faster than the previous approach and a bit more dynamic as well.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-07-04 20:58:44 -0500

Seen: 309 times

Last updated: Jul 05 '21