Hydro: Unable to subscribe to topic : installation or coding ? [closed]
I have simplified the problem I am having. The callback below is never called. rosnode infor robot_jntcmd_to_jntst on my node name says there are no subscriptions. Yet there are no erros in the logs.
The publisher works fine and rostopic list the topic as well as echo topic.
include <string>
include <ros/ros.h>
include <std_msgs/String.h>
void stateCallback(const std_msgs::String msg)
{
ROS_INFO("Here in callback");
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "robot_jntcmd_to_jntst");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("/rrbot/joint1_position_controller/state", 1000);
n.subscribe("/rrbot/joint1_position_controller/state", 10, stateCallback);
std_msgs::String msg;
std::stringstream ss;
ss << "hello world ";
msg.data = ss.str();
while(true) {
chatter_pub.publish(msg);
ros::spinOnce();
}
ROS_INFO("Ended ");
return 0;
}