Gazebo | Ignition | Community
Ask Your Question
0

Gazebo Fortress Custom plugins causing scene to not load

asked 2023-07-28 01:09:59 -0600

Ubuntu 22.04

Gazebo: Ignition Fortress

gazebo plugin: 1

Context, I've been trying to get a force sensor plugin working in gazebo fortress, however all the ones I've found are either for gazebo classic, or just fail to run with little documentation (an issue that plagues a lot of modern gazebo imo). my next solution was to create a custom plugin that solved my needs.

Currently I've created the example system plugin following the Gazebo API guides on creating system plugins. and after spending some time figuring out that you need to set the gazebo plugin path I've got a plugin that builds in cmake correctly and is loaded by gazebo. however once it loads it prevents the scene from being created, leaving me with a blank window.

Here are the relevant files

World file (including plugin)

<sdf version='1.9'>
<world name='default'>
<physics name='1ms' type='ignored'>
  <max_step_size>0.001</max_step_size>
  <real_time_factor>1</real_time_factor>
  <real_time_update_rate>1000</real_time_update_rate>
</physics>

<include>
  <uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Ground Plane</uri>
</include>
<gravity>0 0 0</gravity>
<magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
<atmosphere type='adiabatic' />
<scene>
  <ambient>0.4 0.4 0.4 1</ambient>
  <background>0.7 0.7 0.7 1</background>
  <shadows>true</shadows>
</scene>
<light name='sun' type='directional'>
  <pose>0 0 10 0 -0 0</pose>
  <cast_shadows>true</cast_shadows>
  <intensity>1</intensity>
  <direction>-0.5 0.1 -0.9</direction>
  <diffuse>0.8 0.8 0.8 1</diffuse>
  <specular>0.2 0.2 0.2 1</specular>
  <attenuation>
    <range>1000</range>
    <linear>0.01</linear>
    <constant>0.90000000000000002</constant>
    <quadratic>0.001</quadratic>
  </attenuation>
  <spot>
    <inner_angle>0</inner_angle>
    <outer_angle>0</outer_angle>
    <falloff>0</falloff>
  </spot>
</light>
<plugin
filename="libSampleSystem.so"
name="sample_system::SampleSystem">

</plugin> </world> </sdf>

gazebo_plugin.hpp:

 #ifndef _GAZEBO_SAMPLE_SYSTEM_PLUGIN_
 #define _GAZEBO_SAMPLE_SYSTEM_PLUGIN_

 #include <ignition/gazebo/System.hh>
 #include <ignition/plugin/Register.hh>
 namespace sample_system
 { 

class SampleSystem: public ignition::gazebo::System, 
    public ignition::gazebo::ISystemPostUpdate, 
    // public ignition::gazebo::ISystemPreUpdate, 
    // public ignition::gazebo::ISystemUpdate,
    public ignition::gazebo::ISystemConfigure
{
    public:
        SampleSystem();
        ~SampleSystem() override;

        void PostUpdate(const ignition::gazebo::UpdateInfo &_info, const ignition::gazebo::EntityComponentManager &_ecm) override;
        // void PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) override;
        // void Update(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) override;
        void Configure(const ignition::gazebo::Entity &_entity,
            const std::shared_ptr<const sdf::Element> & _sdf,
            ignition::gazebo::EntityComponentManager &_ecm,
            ignition::gazebo::EventManager &/*_eventMgr*/);
    private:
        ignition::gazebo::Entity linkEntity;
};
}
IGNITION_ADD_PLUGIN(
sample_system::SampleSystem,
ignition::gazebo::System,
// sample_system::SampleSystem::ISystemPreUpdate,
// sample_system::SampleSystem::ISystemUpdate,
sample_system::SampleSystem::ISystemPostUpdate
)
IGNITION_ADD_PLUGIN_ALIAS(sample_system::SampleSystem,"ignition::gazebo::systems::SampleSystem")
#endif

Gazebo_Plugin.cpp:

#include "gazebo_system_plugin.hpp"
#include <ignition/gazebo/Model.hh>
#include <ignition/gazebo/Util.hh>
using namespace sample_system;
using namespace ignition::gazebo::v6;

SampleSystem::SampleSystem(){

}
SampleSystem::~SampleSystem(){

}
void SampleSystem::Configure(const Entity &_entity,
const std::shared_ptr<const sdf::Element> & _sdf,
EntityComponentManager &_ecm,
EventManager &/*_eventMgr*/
){
}

void SampleSystem::PostUpdate(const UpdateInfo &_info,
const EntityComponentManager &_ecm){
// ignmsg << "SampleSystem::PostUpdate - " << _info.simTime.count() << std::endl;
// I have commented this out so that the ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-08-08 20:04:14 -0600

The solution to this is given in the following resolved git issue. but ultimately its that when you load a custom plugin, gazebo then doesn't load any of the default plugins, requiring you to manually add them to your world sdf file as well.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-28 01:01:49 -0600

Seen: 173 times

Last updated: Aug 08 '23