Hello, I have a university project and I have to read the data from the laser and to create a control signal to the wheels using the laser data. The cpp code and CMakeList file are shown bellow. I use rqt_graph command to visualize the nodes, unfortunately i can't see the topic `/base_controller/command`, i don't have a connection to the wheels. However, i use `rostopic type /base_controller/command` and see the published message type, additionally i use the command `rostopic list` and the topic `/base_controller/command` is viziable. Could you tell me where might be the problem? In my opinion the CMakeList file is wrong.
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sensor_msgs/LaserScan.h"
#include "geometry_msgs/Twist.h"
class SubscribeAndPublish
{
public:
SubscribeAndPublish()
{
sub = n.subscribe("scan", 50, &SubscribeAndPublish::chatterCallback, this);
pub = n.advertise ("/base_controller/command", 50);
}
void chatterCallback(const sensor_msgs::LaserScan::ConstPtr& laser)
{
ROS_INFO("*");
geometry_msgs::Twist msg;
ROS_INFO("I heard1: [%f]",laser->ranges[100]);
if (laser->ranges[100]<1)
{
ROS_INFO("--");
msg.linear.x=-0.5;
ROS_INFO_STREAM("Com: "<
↧