Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 475

Rosbags saving empty messages

$
0
0
I am trying to record data from data from a Razor 9DOF imu, Hokuyo LIDAR and a ZED camera. The code compiles and runs fine but it is saving empty messages to the rosbag file. I have tried printing data in at different points and it wont. Can you tell me what my code is missing and why the messages are empty? I am running ROS kinetic 1.12.14 on Ubuntu 16.04 on an Nvidia Jetson TX2. #include #include #include #include #include #include sensor_msgs::Imu imu_msg; sensor_msgs::LaserScan scan; sensor_msgs::Image msgr; sensor_msgs::Image msgl; /** * Call back functio for Imu. Argument is a pointer to the recieved message */ void imuCallback(const sensor_msgs::Imu &imu_msg) { } /** * Call back functio for lidar. Argument is a pointer to the recieved message */ void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { } /** * Subscriber callbacks. The argument of the callback is a constant pointer to the received message */ void imageRightRectifiedCallback(const sensor_msgs::Image &msgr) { } void imageLeftRectifiedCallback(const sensor_msgs::Image &msgl) { } int main(int argc, char** argv){ ros::init(argc, argv, "talker"); ros::NodeHandle n; rosbag::Bag bag; // create a bag named bag bag.open("data.bag", rosbag::bagmode::Write); //open bag and create a file to save to. ros::Subscriber imu_sub = n.subscribe("imu_data", 1000, imuCallback); // subscribes to the imu and start the callback function ros::Subscriber sub = n.subscribe("/scan", 1000, scanCallback); // subscribes to the lidar and start the callback function // subscribes to the zed and get the right image and start the callback function ros::Subscriber subRightRectified = n.subscribe("/zed/right/image_rect_color", 10, imageRightRectifiedCallback); // subscribes to the zed and get the left image and start the callback function ros::Subscriber subLeftRectified = n.subscribe("/zed/left/image_rect_color", 10, imageLeftRectifiedCallback); while(ros::ok()){ bag.write("imu", ros::Time::now(), imu_msg); // sending msg into the bag bag.write("lidar", ros::Time::now(), scan); bag.write("ZED_RightImage", ros::Time::now(), msgr); bag.write("ZED_LeftImage", ros::Time::now(), msgl); ROS_INFO("Recording data..."); ros::spinOnce(); } bag.close(); return 0; }

Viewing all articles
Browse latest Browse all 475

Trending Articles