Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solved it!

The problem was the wrong type of argument to the callback. i.e. ConstSonarPtr.

I did a gz topic -i <topic-name> and found that the msg type is actually ConstSonarStampedPtr.

$ gz topic -i /gazebo/mtp_world/mtp_robot/left_sonar/mtp_sonar_sensor_left/sonar
Type: gazebo.msgs.SonarStamped

Publishers:
        192.168.1.4:39483

Subscribers:
    192.168.1.4:39483

FInally had to make the following changes to the cb callback to get the range values:

private: void cb(ConstSonarStampedPtr &_msg) {
    if (_msg == NULL) {
        return;
    }
    gazebo::msgs::Sonar sonarMsg = _msg->sonar();
    std::cout << "Range: " << sonarMsg.range() << std::endl;
}

Thanks to a post here somewhere I found gz topic -i <topic-name>.

Solved it!

The problem was the wrong type of argument to in the callback. callback function cb. i.e. ConstSonarPtr.

I did a gz topic -i <topic-name> and found that the msg type is actually ConstSonarStampedPtr.

$ gz topic -i /gazebo/mtp_world/mtp_robot/left_sonar/mtp_sonar_sensor_left/sonar
Type: gazebo.msgs.SonarStamped

Publishers:
        192.168.1.4:39483

Subscribers:
    192.168.1.4:39483

FInally had to make the following changes to the cb callback to get the range values:

private: void cb(ConstSonarStampedPtr &_msg) {
    if (_msg == NULL) {
        return;
    }
    gazebo::msgs::Sonar sonarMsg = _msg->sonar();
    std::cout << "Range: " << sonarMsg.range() << std::endl;
}

Thanks to a post here somewhere somewhere, I found about gz topic -i <topic-name>. and was able to solve the problem.