Using Num.msg from Beginner tutorial
Please modify or guide me to where I can learn to modify the talker.cpp and listener.cpp given in the beginner_tutorials to send the message Num.msg defined in the same series of tutorials. This is to help understand how to use complex msgs later on.
I replaced the example code by the following lines wherever I felt was necessary but this is not getting compiled.
talker.cpp
#include "beginner_tutorials/Num.h"
ros::Publisher chatter_pub = n.advertise<beginner_tutorials::Num>("chatter", 1000);
beginner_tutorials::Num num;
// std::stringstream ss;
// ss <<"hello world" << count;
num = 123456789;
ROS_INFO("%d",num);
chatter_pub.publish(num);
listener.cpp
#include "beginner_tutorials/Num.h"
void chatterCallback(const beginner_tutorials::ConstPtr &num)
{
ROS_INFO("I heard: [%d]", num->data);
}
Also please suggest a way to understand the Num.h, std_msgs/String.h file generated by ROS, if it is to be understood at the first place to use ROS.
What is the error message?
In function ‘int main(int, char**)’: /home/catkin_ws/src/beginner_tutorials/src/talker.cpp:25:7: error: no match for ‘operator=’ (operand types are ‘beginner_tutorials::Num’ and ‘int’) num = 123456789;
one of the error messages, the first one.
Thanks for editing my question.