Robotics StackExchange | Archived questions

Odometry Publisher not working when running gazebo fortress through code

I'm running gazebo by creating a new Server and then calling the RunOnce method to step forward my simulation:

#include "simulation.hh"
#include <stdexcept>
#include <ignition/gazebo/ServerConfig.hh>
#include <ignition/gazebo/Server.hh>

using namespace ignition::gazebo;

void Simulation::start() {
    ServerConfig config;
    config.SetSdfFile(_sdfPath);
    _server = new Server(config);
};

void Simulation::step() {
    if(_server)
        _server->RunOnce(false);
    else 
        throw std::runtime_error("Simulation not started: call start first!");
};

My sdf file includes an Odometry publisher. Using this setup it never publishes anything, but if I just run gazebo from the terminal it publishes fine. Everything else is working using my setup. Is there something that the OdometryPublisher depends on that won't be started with this setup?

My sdf file looks something like this:

<sdf version="1.5">
    <world name="rl_world">
        <include>
            <uri>/path/to/terrain.sdf</uri>
        </include>
        <include>
            <uri>/path/to/robot.urdf</uri>
        </include>
        <plugin filename="libignition-gazebo6-contact-system" name="ignition::gazebo::systems::Contact" />
        <plugin filename="libignition-gazebo6-physics-system" name="ignition::gazebo::systems::Physics" />
        <plugin filename="libignition-gazebo6-scene-broadcaster-system" name="ignition::gazebo::systems::SceneBroadcaster" />
    </world>
</sdf>

and robot.urdf includes:

<gazebo>
    <plugin
        filename="libignition-gazebo6-joint-state-publisher-system.so"
        name="ignition::gazebo::systems::JointStatePublisher">
    </plugin>
    <plugin //hoping to replace this with odometry publisher
        filename="libignition-gazebo6-pose-publisher-system"
        name="ignition::gazebo::systems::PosePublisher">
        <publish_nested_model_pose>true</publish_nested_model_pose>
        <publish_link_pose>false</publish_link_pose>
    </plugin>
    <plugin
        filename="libignition-gazebo6-odometry-publisher-system"
        name="ignition::gazebo::systems::OdometryPublisher">
        <dimensions>3</dimensions>
        <odom_publish_frequency>2000</odom_publish_frequency>
    </plugin>

    <plugin
        filename="libignition-gazebo6-joint-position-controller-system"
        name="ignition::gazebo::systems::JointPositionController">
        <joint_name>joint_1</joint_name>
        <p_gain>50</p_gain>
        <i_gain>5</i_gain>
        <d_gain>0.5</d_gain>
        <topic>/world/rl_world/model/robot/joint/joint_1/cmd_pos</topic>
    </plugin>
</gazebo>

Asked by Lestes on 2023-07-01 04:44:35 UTC

Comments

Answers

Nevermind - this looks to one of those things that I can't get working for days but then the moment I ask for help it starts working for no reason!

If it keeps working consistently I'll close this question.

Asked by Lestes on 2023-07-01 05:05:40 UTC

Comments