subscribe to arduino message
Hello all,
My arduino send geometry twist message about robot path on /robotpath
topic, when i type rostopic echo /robotpath
i see the values (x,y,theta)
change, but my subscribe node on ros read just the first value when it runs and hold it. I need to build a path controller for my project.
Thanks a lot.
my code is:
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
class robocont
{
public:
robocont();
private:
void roboCallback(const geometry_msgs::Twist::ConstPtr& robotpath);
ros::NodeHandle nh_controller;
ros::Subscriber robo_sub;
};
robocont::robocont()
{
robo_sub = nh_controller.subscribe<geometry_msgs::Twist>("/robotpath", 1000, &robocont::roboCallback, this);
}
void robocont::roboCallback(const geometry_msgs::Twist::ConstPtr& robotpath)
{
while(nh_controller.ok()){
ROS_INFO("Robot Postion:(%.2f, %.2f. %.2f)" ,robotpath->linear.x, robotpath->linear.y, robotpath->angular.z);
}
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "odometry_Control");
robocont odometry_Control;
ros::spin();
}