I use the following function to create box in the gazebo world. It is here, but why it is not visible? I can not see it, but sure it is in the gazebo world with name and position information.
The step:
1.I download the object.urdf
2. I use : rosrun gazebo urdf2model -f object.urdf -o object.model
3. Based on the talker program package, I add the gazebo package
-----
#include <gazebo/SpawnModel.h>
#include <gazebo/urdf2gazebo.h>
#include<iostream>
#include<fstream>
#include <tf/transform_datatypes.h>
The in the function I define the following:
gazebo::SpawnModel sm;
std::ifstream ifs;
ifs.open("object.model");
sm.request.model_name = "box";
ifs >> sm.request.model_xml;
sm.request.initial_pose.position.x = 4.0;
sm.request.initial_pose.position.y = 4.0;
sm.request.initial_pose.position.z = 1.0;
sm.request.initial_pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
sm.request.reference_frame = "";
ros::service::call( "/gazebo/spawn_gazebo_model", sm );
So I do not why we can not see it but it is in the gazebo world?