Gazebo | Ignition | Community
Ask Your Question
0

Opening a text file through a plugin

asked 2016-02-17 04:05:17 -0500

pap-x gravatar image

updated 2016-02-17 04:08:42 -0500

I'm trying to open a text file through a plugin to get timestamps and positions for keyframes of a model animation. I'm opening the file using ifstream(). Unfortunately no matter where I place the text file it won't be opened by the plugin. What can I do?

edit retag flag offensive close merge delete

Comments

Have you tried using the file's full path? Does that work?

chapulina gravatar imagechapulina ( 2016-02-17 09:12:33 -0500 )edit

Yeap! Full path did work, thank you! (Had tried that already but I was missing something probably)

pap-x gravatar imagepap-x ( 2016-02-18 01:14:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-02-17 09:25:35 -0500

debz gravatar image

Hi,

I also use an external file for my current project. Here is the code:

std::ifstream f(path.c_str(), std::ios::in);

Here, path is a std::string object. Be ware that the path is relative to the folder where you run gazebo, NOT relative to the folder of your plugin. If you know exactly where you run gazebo, then adapt your path or you can use an absolute path, as chapulina said.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-02-17 04:05:17 -0500

Seen: 227 times

Last updated: Feb 17 '16