Gazebo | Ignition | Community
Ask Your Question

rezenders's profile - activity

2021-07-22 11:11:16 -0500 received badge  Notable Question (source)
2021-07-22 11:11:16 -0500 received badge  Popular Question (source)
2021-05-05 14:12:12 -0500 received badge  Famous Question (source)
2021-05-05 14:12:12 -0500 received badge  Notable Question (source)
2021-05-05 14:12:12 -0500 received badge  Popular Question (source)
2021-04-15 08:45:19 -0500 commented question Switchable light on a link as a child

Any updates on this?

2021-02-21 20:03:49 -0500 received badge  Notable Question (source)
2021-02-21 12:17:04 -0500 received badge  Famous Question (source)
2020-12-17 06:42:14 -0500 marked best answer Is it possible to directly use a model from ignitionrobotics.org in gazebo9?

I want to include in a gazebo9 world file a model that is available in ignitionrobotics.org using only the link generated in the website, is it possible?

Something like:

<include>
      <uri>
      https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch
      </uri>
</include>
<include>
      <uri>
      https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female
      </uri>
</include>

When I do this I get the error:

[Err] [FuelModelDatabase.cc:255] Unable to download model[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch]
[Wrn] [SystemPaths.cc:464] File or path does not exist [""] [https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch]
[Err] [FuelModelDatabase.cc:255] Unable to download model[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female]
[Wrn] [SystemPaths.cc:464] File or path does not exist [""] [https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female]
Error Code 11 Msg: Unable to find uri[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch]
Error Code 10 Msg: Invalid uri[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch]. Should be model://https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/hatch
Error Code 11 Msg: Unable to find uri[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female]
Error Code 10 Msg: Invalid uri[https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female]. Should be model://https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Survivor Female
2020-12-17 06:42:05 -0500 received badge  Notable Question (source)
2020-12-17 06:09:36 -0500 received badge  Editor (source)
2020-12-17 06:09:36 -0500 edited question Error openning model with .dae meshes : what(): bad lexical cast: source type value could not be interpreted as target

Error openning model with .dae meshes : what(): bad lexical cast: source type value could not be interpreted as target

2020-12-17 06:05:38 -0500 asked a question Error openning model with .dae meshes : what(): bad lexical cast: source type value could not be interpreted as target

Error openning model with .dae meshes : what(): bad lexical cast: source type value could not be interpreted as target

2020-11-16 10:57:29 -0500 asked a question Can't change visual mesh initial position

Can't change visual mesh initial position I have created a simple model for a supermarket using a .dae file and added it

2020-07-14 13:23:24 -0500 marked best answer Segmentation fault when publishing to a topic while the ModelPlugin which subscribes to this topic is deleted

I am using two gazebo plugins, VictimPlugin and LifeBuoyPlugin. The VictimPlugin subscribes to a topic to get a bool that is used by timerThreadFunction, which sleeps for a predefined amount of time and when it awakes if this bool is true it deletes the gazebo model associated to the plugin. The LifeBuoyPlugin publishes this bool which indicates if the model should be deleted or not.

The problem is that sometimes when LifeBuoyPlugin is trying to publish and VictimPlugin is deleted a segmentation fault happens, the gdb log is:

#0  0x00007ffff5dbcfa0 in __GI___pthread_mutex_lock (mutex=0x110) at ../nptl/pthread_mutex_lock.c:65
#1  0x00007fffbc942fa0 in ros::Publication::hasSubscribers() () at /opt/ros/melodic/lib/libroscpp.so
#2  0x00007fffbc933296 in ros::TopicManager::publish(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::function<ros::SerializedMessage ()> const&, ros::SerializedMessage&) () at /opt/ros/melodic/lib/libroscpp.so
#3  0x00007ffeb85d92e5 in void ros::Publisher::publish<std_msgs::Bool_<std::allocator<void> > >(std_msgs::Bool_<std::allocator<void> > const&) const ()
    at /home/gus/Documents/git/jason_ros_ws/devel/lib/liblifebuoy.so
#4  0x00007ffeb85d653c in gazebo::LifeBuoyPlugin::OnRosMsg(boost::shared_ptr<gazebo_msgs::ModelStates_<std::allocator<void> > const> const&) () at /home/gus/Documents/git/jason_ros_ws/devel/lib/liblifebuoy.so

VictimPlugin code:

#include <thread>
#include <chrono>
#include <mutex>

#include <gazebo/transport/Node.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/physics/Model.hh>
#include <ignition/math/Pose3.hh>

#include "ros/ros.h"
#include "std_msgs/Bool.h"
#include "ros/callback_queue.h"
#include "ros/subscribe_options.h"

namespace gazebo{
  class VictimPlugin : public ModelPlugin{
  private:
    gazebo::transport::NodePtr node;
    std::unique_ptr<ros::NodeHandle> rosNode;

    ros::Subscriber rosSub;
    ros::CallbackQueue rosQueue;
    std::thread rosQueueThread;

    bool drowning = true;

    physics::ModelPtr model;

    int drowning_time_ = 0;
    std::thread timer_thread_;
    std::mutex mtx;

    void timerThreadFunction(){
      std::this_thread::sleep_for(
        std::chrono::milliseconds(this->drowning_time_));

      std::lock_guard<std::mutex> guard(mtx);

      if(this->drowning){
        gazebo::transport::PublisherPtr request_pub = this->node->Advertise<msgs::Request>("~/request");
        msgs::Request *msg = msgs::CreateRequest("entity_delete", this->model->GetName());
        request_pub->Publish(*msg);
        delete msg;
      }
    }

    void QueueThread(){
      static const double timeout = 0.01;
      while (this->rosNode->ok())
      {
        this->rosQueue.callAvailable(ros::WallDuration(timeout));
      }
    }

  public:
    VictimPlugin() : ModelPlugin(){}
    ~VictimPlugin(){
      rosQueue.clear();
      rosQueue.disable();
      rosNode->shutdown();
      rosQueueThread.join();
      timer_thread_.join();
    }

    void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf){
      model = _model;

      this->node = boost::make_shared<gazebo::transport::Node>();
      this->node->Init();

      if (!_sdf->HasElement("drowningTime")){
        this->drowning_time_ = 5000;
        ROS_DEBUG("Victim plugin missing <drowningTime>, default to 5000ms");
      }else{
        this->drowning_time_ = _sdf->Get<int>("drowningTime");
      }

      if (!ros::isInitialized()){
        ROS_FATAL_STREAM("A ROS node for Gazebo has not been initialized, unable to load plugin. "
          << "Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
        return;
      }
      this->rosNode.reset(new ros::NodeHandle("victim"));

      ros::SubscribeOptions so =
        ros::SubscribeOptions::create<std_msgs::Bool>(
          "/victim/"+this->model->GetName(),
          1,
          boost::bind(&VictimPlugin::OnRosMsg, this, _1),
          ros::VoidPtr(), &this->rosQueue);

      this->rosSub = this->rosNode->subscribe(so);

      this->rosQueueThread =
        std::thread(std::bind(&VictimPlugin::QueueThread, this));

      this->timer_thread_ =
        std::thread(std::bind(&VictimPlugin::timerThreadFunction, this));
    }

    void OnRosMsg(const std_msgs::BoolConstPtr &_msg){
      std::lock_guard<std::mutex> guard(mtx);
      this->drowning = _msg->data;
    }
  };
  GZ_REGISTER_MODEL_PLUGIN(VictimPlugin)
}

LifeBuoyPlugin ... (more)

2020-07-14 13:23:13 -0500 answered a question Segmentation fault when publishing to a topic while the ModelPlugin which subscribes to this topic is deleted

Setting so.transport_hints = ros::TransportHints().unreliable(); solved this ros::SubscribeOptions so = ros::Su

2020-07-14 12:20:17 -0500 asked a question Segmentation fault when publishing to a topic while the ModelPlugin which subscribes to this topic is deleted

Segmentation fault when publishing to a topic while the ModelPlugin which subscribes to this topic is deleted I am using

2020-07-13 09:01:30 -0500 received badge  Supporter (source)
2020-07-13 09:01:24 -0500 marked best answer Delete a model from within its own modelPlugin

I wrote a ModelPlugin to delete the model to which it is attached after a certain period of time. The problem is that when the model is deleted, gazebo stops working, it just freezes.

Plugin code:

#include <ignition/math/Pose3.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/physics/Model.hh>
#include "gazebo_msgs/DeleteModel.h"
#include "ros/ros.h"
#include <thread>
#include <chrono>


namespace gazebo{
  class VictimPlugin : public ModelPlugin{
  private:
    physics::ModelPtr model;

    int drowning_time_ = 0;
    std::thread timer_thread_;

    void timerThreadFunction(){
      std::this_thread::sleep_for(
        std::chrono::milliseconds(this->drowning_time_));

      gazebo_msgs::DeleteModel del_model;
      del_model.request.model_name = this->model->GetName();
      ros::service::call("/gazebo/delete_model", del_model);

   }

  public:
    VictimPlugin() : ModelPlugin(){}
    ~VictimPlugin(){
      timer_thread_.join();
    }

    void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf){
      model = _model;

      if (!_sdf->HasElement("drowningTime")){
        this->drowning_time_ = 5000;
        ROS_DEBUG("Victim plugin missing <drowningTime>, default to 5000ms");
      }else{
        this->drowning_time_ = _sdf->Get<int>("drowningTime");
      }

      this->timer_thread_ =
        std::thread(std::bind(&VictimPlugin::timerThreadFunction, this));
    }
  };
  GZ_REGISTER_MODEL_PLUGIN(VictimPlugin)
}

I am adding the model to the world file like this:

<include>
  <name>victim_randy</name>
  <pose>7 17.5 0.1 -1.57 0 0</pose>
  <uri>model://rescue_randy</uri>
  <plugin name="victim" filename="libvictim.so">
    <drowningTime>5000</drowningTime>
  </plugin>
</include>

I am using gazebo version 9.13.1

2020-07-13 09:01:24 -0500 received badge  Scholar (source)
2020-07-13 09:01:22 -0500 commented answer Delete a model from within its own modelPlugin

That makes sense, it worked. Thank you!

2020-07-13 08:47:04 -0500 received badge  Popular Question (source)
2020-07-10 13:03:52 -0500 asked a question Delete a model from within its own modelPlugin

Delete a model from within its own modelPlugin I wrote a ModelPlugin to delete the model to which it is attached after a

2020-07-10 12:48:25 -0500 commented question Gazebo not updating visual position in gzclient

I have the same problem, any updates on this? For my case, it is not a solution to use <static>false</static>

2020-07-10 12:36:29 -0500 received badge  Enthusiast
2020-06-16 13:37:00 -0500 commented answer programmatically turning off a camera

When I use sensor->SetActive(false); I have to call it several times before the change takes effect, should it be li

2020-05-30 17:50:06 -0500 commented question Shadows are permanently painted onto my Collada mesh visuals. Why and can I remove them?

Have you found a solution to this?

2020-05-22 05:40:16 -0500 received badge  Popular Question (source)
2020-05-14 16:20:11 -0500 asked a question Is it possible to directly use a model from ignitionrobotics.org in gazebo9?

Is it possible to directly use a model from ignitionrobotics.org in gazebo9 I want to include in a gazebo9 world file a