Gazebo | Ignition | Community
Ask Your Question

Luigi's profile - activity

2017-12-28 05:32:30 -0500 received badge  Taxonomist
2016-11-14 12:01:08 -0500 received badge  Famous Question (source)
2016-11-14 12:01:08 -0500 received badge  Notable Question (source)
2015-03-12 04:22:01 -0500 received badge  Popular Question (source)
2014-06-23 16:45:57 -0500 received badge  Famous Question (source)
2014-06-22 10:33:49 -0500 asked a question Read message without callback

hi,

i want to ask if there is a method to read the last message published on a topic directly without using a callback.

Thanks for any help!

2014-05-15 09:16:54 -0500 received badge  Notable Question (source)
2014-03-28 11:27:07 -0500 commented answer Problem with echo of a message

I have tried but it doesn't change anything, moreover I tried with an integrated message in Gazebo and it keep giving me back the same warning (and didn't send me back the original message). In your opinion, are there any other errors?

2014-03-28 11:26:23 -0500 received badge  Popular Question (source)
2014-03-23 16:08:56 -0500 asked a question Problem with echo of a message

Hello,

I'm trying to do an echo of a message between gazebo and a external application with a custom message. I have no problem sending messages from the application to gazebo, but i can't return the message, and everytime that i try i receive this warning:

Warning [Publisher.cc:144] Queue limit reached for topic /gazebo/default/physics/contacts, deleting message. This warning is printed only once.

i don't understand what is the problem, if anyone has a solution i'll be very gratefull

here is the external application:

#include <iostream>
#include <sdf/sdf.hh>

#include "gazebo/gazebo.hh"
#include "gazebo/common/common.hh"
#include "gazebo/math/Vector3.hh"
#include "gazebo/transport/transport.hh"
#include "gazebo/physics/physics.hh"
#include "gazebo/msgs/msgs.hh"

#include "call_answer.pb.h"

#define MAX_WAITING 1500 //tempo espresso in centesimi di secondo 

using namespace std;


typedef const boost::shared_ptr<const call_answer_msgs::msgs::Response> AnswerPtr;

void StampData(AnswerPtr &_msg);

int main(int argc, char * argv[])
{
    call_answer_msgs::msgs::Request request;

        request.set_answ(20);

    // Initialize transport 
    gazebo::transport::init();
    // Create our node for communication
    gazebo::transport::NodePtr node(new gazebo::transport::Node());
    node->Init();
    // Start transport
    gazebo::transport::run();
    //invio la richiesta di temperatura
    cout << "invio richiesta..." << endl;
    gazebo::transport::PublisherPtr Req;
    Req = node->Advertise<call_answer_msgs::msgs::Request>("~/MyRequest");
    Req->WaitForConnection();
    Req->Publish(request);

        // Listen to Gazebo world_stats topic
    gazebo::transport::SubscriberPtr sub = node->Subscribe("~/MyAnswer", StampData);
        // Busy wait loop...replace with your own code as needed.
    int i=0;
    while (true && i < MAX_WAITING){ 
            i++;
            gazebo::common::Time::MSleep(10);
        }

        // Make sure to shut everything down
    gazebo::transport::fini();
    return 0;
}

void StampData(AnswerPtr &_msg)
{
    cout << _msg->resp() << endl;
}

here the gazebo's plugin:

  #include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <sdf/sdf.hh>


#include <gazebo/gazebo.hh>
#include "gazebo/physics/physics.hh"
#include "gazebo/common/common.hh"
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/transport.hh"


#include "call_answer.pb.h"


namespace gazebo
{
  typedef const boost::shared_ptr<const call_answer_msgs::msgs::Request> ConstRequestPtr;

  class MySensor : public ModelPlugin
  {
    transport::NodePtr node;    //Nodo per la connessione
    transport::SubscriberPtr commandSubscriber;

    public: void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
    {
         physics::WorldPtr world = _model->GetWorld();
        //inizializzo il nodo
        node = transport::NodePtr(new transport::Node());
        node->Init(world->GetName());
        std::cout << std::endl; 
        std::cout << "Subscribing to: " << "~/MyRequest" << std::endl;
        commandSubscriber = node->Subscribe("~/MyRequest", &MySensor::create,this);


    }//fine load


    public: void create(ConstRequestPtr &msg)
   {    
        std::cout << std::endl;
        std::cout << "è arrivato il messaggio: "<< msg->answ() << std::endl;        
        double val = msg->answ();

        //invio il messaggio a ROS/eseguibile esterno

      call_answer_msgs::msgs::Response answer;

        answer.set_resp(val);

        std::cout << std::endl;

        std::cout << "i'm here 1" << std::endl;     
        gazebo::transport::PublisherPtr tmprRes;
        std::cout << "i'm here 2" << std::endl; 
    tmprRes = node->Advertise<call_answer_msgs::msgs::Response>("~/MyAnswer", 100);
        std::cout << "i'm here 3" << std::endl; 
        tmprRes->WaitForConnection();
        tmprRes->Publish(answer);
        //      }
        //else {
        //  std::cout << "messaggio non inviato" << std::endl;
          //  }

  }//fine create

  };
  GZ_REGISTER_MODEL_PLUGIN(MySensor)
}
2013-11-13 05:32:22 -0500 received badge  Famous Question (source)
2013-10-30 08:27:41 -0500 received badge  Notable Question (source)
2013-09-30 08:41:28 -0500 received badge  Popular Question (source)
2013-09-30 08:41:26 -0500 answered a question How to simulate Temperature and create an office room

Thanks. I have another question: is there any other solution to create an office room starting from a greyscale image without the use of the tag <image> and <heightmap>?

2013-09-25 04:18:13 -0500 asked a question How to simulate Temperature and create an office room

1)i want to create a room from a greyscale image, i have seen two methods using gazebo: with the tag <heightmap> but with this i can't apply a texture to the side of the wall, but only from the hight, and with the tag <image> but this doesn't work, and i don't undertand why, the sdf file is:

<?xml version="1.0" ?>

<sdf version="1.4"> <world name="default">

<!-- A global light source -->
<include>
  <uri>model://sun</uri>
  <pos>0 0 20</pos>
</include>

<include> <uri>model://ground_plane</uri> </include>

<!-- a box to undertand if the world open something-->  
<model name="box1">
  <pose>0 0 1 0 0 0</pose>
  <link name="link">
    <collision name="collision">
      <geometry> <box> <size>2 2 2</size> </box> </geometry>
    </collision>
    <visual name="visual">
      <geometry> <box> <size>2 2 2</size> </box> </geometry>
      <material>
        <ambient>1 0 0 1</ambient>
        <diffuse>1 0 0 1</diffuse>
      </material>
    </visual>
  </link>
</model>

<!-- -->
<model name="image_map">
  <static>true</static>
  <pose> 0 0 0 0 0 0</pose>
  <link name="link">
    <collision name="collision">
      <geometry>
    <image>
                <uri>file://media/materials/textures/room4.jpg</uri>
                <scale>20</scale>
        <threshold>200</threshold>                  
        <height>3</height>
        <granularity>1</granularity>
        </image>
      </geometry>
    </collision>

    <visual name="visual"> 
      <geometry>
        <image>
                <uri>file://media/materials/textures/room4.jpg</uri>
                <scale>20</scale>
        <threshold>200</threshold>                  
        <height>3</height>
        <granularity>1</granularity>
        </image> 
      </geometry>
    </visual>

  </link>
</model>

</world> </sdf>

2) i want to simulate a physics element like the temperature in environment and to relevate it with a sensor, is this thing possible to do? are there any projects available?

thank you for your answer