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.