How to build a circuit in gazebo [Update visuals at runtime]
Hi all, I am trying to build a circuit in Gazebo but I don't know how I can manage this task. In particular I don't know if I have to Necessarily create a .world file or I can just create a texture for example. I have an image of this circuit and also I can have a gis file, could these files help me? Someone had already faced with this kind of work?
Thanks in advance.
[copied from comments by moderator] I am sorry if I was so inaccurate. I am using Gazebo7 without ROS and I am writing some code for path plannig in autonomous cars scenario. As clarified today by my Ph.D. tutor I just have to update the ground plane texture at runtime. More in detail: I have a module that using Gazebo messages (I don't already know which ones) sends at certain time intervals an image that represents the actual state of the road (for example lanes) and I just want that Gazebo draws for me the new road
UPDATE
Hi all and Hi Peter, I tried to do do what you said but I am not sure that I have done the right things (in fact it doesn't work).
Actually I started from the tutorial at http://gazebosim.org/tutorials?tut=cu... to manage the messages and from your code to update the model.
More precisely:
1: I build a world in which I put a ground model with the texture that I have to modify at runtime.
2: I used all the code that I linked to manage the message exchange but in the function create() I put the code of my interest. I used this function because it seems that is the function that performs the operation when a message arrives. I modified the function in the following way (I commented the initFile because I don't know the perfect meaning and I don't know how to use it and if I have to use it):
public: void create(CollisionMapRequestPtr &msg)
{
std::cout << "Received message" << std::endl;
modelSDF.reset(new sdf::SDF);
std::cout << "After Reset"<<std::endl;
// sdf::initFile("root.sdf", modelSDF);
sdf::readFile("~/.gazebo/models/my_ground_plane/model.sdf", modelSDF);
std::cout<< "After reading"<<std::endl;
world->InsertModelSDF(*modelSDF);
std::cout << "After inserting"<<std::endl;
}
Obviously the prints are useful just for debug. As to me it seems to be reasonable.
3:I send a message as shown in the tutorial and before to send it I change the image that I would like use as new texture (is an image exchange so I change the file but I use the same name).
4: I receive the following output (wrong and I have texture no update):
Subscribing to: ~/collision_map/command
[Err] [Scene.cc:2927] Light [sun] not found. Use topic ~/factory/light to spawn a new light.
Received message
After Reset
Error [parser.cc:286] Error finding file [~/.gazebo/models/my_ground_plane/model.sdf].
After reading
After ...
What tutorials have you tried? What version of Gazebo are you using? Did you try searching for similar questions on this forum? What is the technical problem with Gazebo that is not working for you?
also, just curious what is the motivation for doing this?
I am sorry if I was so inaccurate. I am using Gazebo7 without ROS and I am writing some code for path plannig in autonomous cars scenario. As clarified today by my Ph.D. tutor I just have to update the ground plane texture at runtime. More in detail: I have a module that using Gazebo messages (I don't already know which ones) sends at certain time intervals an image that represents the actual state of the road (for example lanes) and I just want that Gazebo draws for me the new road.
I think we thought you mean electrical circuit...
Do you need to update collision models? or only visual elements
I need to update only visual elements. I need just to update road visualization updating lanes for example