ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This works:

# definition in header
std::vector<physics::JointPtr> joints;
ros::Publisher rosPub;
std::unique_ptr<ros::NodeHandle> rosNode;

# initialization
this->rosNode.reset(new ros::NodeHandle( node_name ));
this->rosPub = this->rosNode->advertise<std_msgs::Float32MultiArray>("/velocity",1);

# callback function
std_msgs::Float32MultiArray msg;
msg.data.push_back( this->joints[0]->GetVelocity(0) );
msg.data.push_back( this->joints[1]->GetVelocity(0) );
msg.data.push_back( this->joints[2]->GetVelocity(0) );

this->rosPub.publish(msg);