Ask Your Question
0

bag file not created from launched node

asked 2017-08-02 14:30:23 -0500

tylernaes gravatar image

Hello, I am having trouble creating a .bag file from a node when that node is executed from a launch file. However, when I execute the node by itself using rosrun, it does create the .bag file. details are below:

I have a package called "motor_driver" and in the src folder in this package I have the .cpp file orientation.cpp This creates the executable node orientation_node . Here is the .cpp file:

#include "ros/ros.h"   //provides standard ROS functions
#include "rosbag/bag.h"
#include "iostream"  //not sure if needed.
#include "string"    //needed for using std::string
#include "motor_driver/orientations.h"
#include "ros/console.h"
#include "stdlib.h"
#include "orientation.h"
#include "adjustment.h"

float roll, pitch, yaw;
float phi;

Orientation orientation;
Adjustment current;
motor_driver::orientations angles;
rosbag::Bag bag;

int main(int argc, char** argv){
        sleep(5);
        ros::init(argc,argv, "orientation_node");
        ros::NodeHandle nh;
        ros::Rate loop_rate(1);
        bag.open("test.bag", rosbag::bagmode::Write);
        while(ros::ok()){
                angles.yaw = 123.1;
                angles.phi = 456.4;
                bag.write("test_topic", ros::Time::now(), angles);
                loop_rate.sleep();
        }
        bag.close();
        ros::shutdown();
        return 0;
}

When I do run this node using: rosrun motor_driver orientation_node it creates the test.bag file

However, I have a launch file that launches this node but the test.bag file is not created. Here is my launch file:

<launch>

  <node pkg="motor_driver"   name="orientation_node"  type="orientation_node" output="screen">
  </node>

</launch>

Does anyone know why the .bag file is not created when launching the node from a .launch file?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-02 15:06:51 -0500

gvdhoorn gravatar image

The bag file is most likely created, but not in the location you expect (ie: cwd).

See if #q235337 answers your question.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-08-02 14:30:23 -0500

Seen: 49 times

Last updated: Aug 02 '17