Gazebo | Ignition | Community
Ask Your Question
0

Odometry Publisher not working when running gazebo fortress through code [closed]

asked 2023-07-01 04:44:35 -0500

Lestes gravatar image

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>
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Lestes
close date 2023-07-02 14:54:24.267575

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-01 05:05:40 -0500

Lestes gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-01 04:44:35 -0500

Seen: 225 times

Last updated: Jul 01 '23