Hello !
I have a problem that states "Read a rosbag, to parse a topic, that is passed as an input argument"
How do I pass the input argument using "rosrun" in the command line terminal?
My code snippet:
#include
#include i
#include
using namespace std;
void topicCallBack(const sensor_msgs::PointCloud2::ConstPtr&msg)
{
cout<<"Reading message of type PointCloud2\n"<header;
if(msg->width)
cout<< "\nInpoint Cloud\nwidth is"<width;
//THIS LINE WILL NOT WORK AS MSG IS OF TYPE POINT CLOUD
if(msg->transforms.transform.translation)
cout<< " reading message of type TF\n";
}
int main(int argc, char **argv)
{
ros::init(argc, argv,"parser");
ros::NodeHandle nh;
//intializing the subscriber
ros::Subscriber sub = nh.subscribe("/camera/depth/points",1000, topicCallBack);
ros::spin();
return 0;
}
Here I have given my topic name as "/camera/depth/points" which publishes the message of type sensor_msgs/PointCloud2. But in my command line terminal, if I pass the topic name as "/tf", how do I ask it to publish the message of type tf/tfMessage because the subscriber is of type PointCloud2?
In total, I have three topics that publish messages of type PointCloud2, tf, odom messages. But I am not able to see, how to pass different topic names in the command line argument and publish the respective message type
Thanks!
↧