ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

problems in writing to a file

asked 2015-01-29 12:17:43 -0500

vinoth_murali gravatar image

Hi All, I am using rospython to create a node..

I wanted to write an image file in the current working directory.

In my node in the begining I mentioned the path of the current working directory

path_to_write = str('~/current working directory path')

before writing to the file I use current_path = os.path.dirname(os.path.abspath(__file__)) rospy.loginfo(current_path)

and then I write the image file as

if current_path in path_to_write: print("I am Here") cv2.imwrite('file_name.png') else: pass

But when I run this using roslaunch I am able to get 1. my current_path which is same as the path_to_write 2. I am here

but when I go to my current directory, I find the file is not written. can any body help me out in this issue.?

I have all my imports here

import os import rospy import sys import numpy as np import cv2 from cv_bridge import CvBridge

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-03-09 02:21:50 -0500

The image files by default will get stored in the /home/user/.ros if you are using linux. If you want to save file to your desired dir, either set$ROS_HOME variable with desired directory path and in launch file add cwd=ROS_HOME within the <node> tag.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-29 12:17:43 -0500

Seen: 292 times

Last updated: Mar 09 '21