osrf/car_demo

Publish Wheels Speeds and Steering Angle on a ROS topic : gzserver crashes

Closed this issue · 1 comments

Hi all,

I would like to briefly modify the PriusHybridPlugin to make it publish on a separate ROS topic front wheels speeds and steering angle.

What I have tried so far is:

  1. Add
    public: ros::Publisher sensorsPub;
    public: std_msgs::MultiArrayLayout layout;
    public: std_msgs::Float32MultiArray sensors_msg;
    to public declarations of the class PriusHybridPluginPrivate

  2. Add
    this->dataPtr->sensorsPub = nh.advertise<std_msgs::Float32MultiArray>("/prius/sensors",10);
    this->dataPtr->layout.dim[0].label = "sensors_values";
    this->dataPtr->layout.dim[0].size = 2;
    this->dataPtr->layout.dim[0].stride = 2;
    this->dataPtr->layout.data_offset = 0;
    this->dataPtr->sensors_msg.layout = this->dataPtr->layout;
    in the constructor of the plugin.

  3. Add
    #include <std_msgs/Float32MultiArray.h>
    #include <std_msgs/MultiArrayLayout.h>
    at the beginning of the PriusHybridPlugin.hh file

  4. Finally, add
    this->dataPtr->sensors_msg.data[0] = (dPtr->flSteeringAngle+dPtr->frSteeringAngle)/2;
    this->dataPtr->sensors_msg.data[1] = (dPtr->flWheelAngularVelocity+dPtr->frWheelAngularVelocity)/2;
    this->dataPtr->sensorsPub.publish(this->dataPtr->sensors_msg);
    in the function Update(), after all the values have been read.

However, when I launch the simulation, gazebo immediately crashes with no more explanation than
[gazebo-2] process has died [pid 122, exit code 139] which means I have a segmentation violation somewhere, but I can't find where.

Thank you for your help
Cheers,
Guillaume

Please ask for help on answers.ros.org following our support guideline: http://wiki.ros.org/Support

When you ask, I'd strongly recommend linking to a forked repository with your failure reproducably represented exactly. Otherwise it's hard to know if there's a transcription error in your description or in the attempted reproduction.