I am trying publish height but the data out is zero
Code:
#include "ros/ros.h"
#include <sensor_msgs/PointCloud2.h>
#include <std_msgs/UInt32.h>
int height =1;
void pointCallback(const sensor_msgs::PointCloud2 msg)
{
ROS_INFO("Height is: [%i]", msg.height);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::UInt32>("point_c", 1000);
ros::Subscriber sub = n.subscribe("/points_raw", 1000, pointCallback);
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
std_msgs::UInt32 msg;
msg.data = height;
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
Maybe a conversion issue? height is declared as int and msg.data is an unsigned int. Have you tried declaring height as usinged int?
thanks its work now another question , if I am using rosbag play is it right to give the height a value ?