Rosanswers logo

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){
        ros::init(argc,argv, "orientation_node");
        ros::NodeHandle nh;
        ros::Rate loop_rate(1);
        bag.open("test.bag", rosbag::bagmode::Write);
                angles.yaw = 123.1;
                angles.phi = 456.4;
                bag.write("test_topic", ros::Time::now(), angles);
        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:


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


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

Originally posted by tylernaes on ROS Answers with karma: 23 on 2017-08-02

Post score: 0


1 Answer 1


Rosanswers logo

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

See if #q235337 answers your question.

Originally posted by gvdhoorn with karma: 86574 on 2017-08-02

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.