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

Revision history [back]

click to hide/show revision 1
initial version

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?

click to hide/show revision 2
fix format

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="">

-----  
#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;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?