ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
As there is no answer, I am sharing how I solved it back then.
I decided to create a shell script to handle the screenshots. During the execution, ROS node (C++ program) calls the shell file with a system call:
string path_str = ros::package::getPath("package_name");
string cmd_str = path_str+"/src/capture_screenshot.sh";
// add path and name arguments
cmd_str += " -p " + path_str + "/output";
cmd_str += " -n " + name_str;
// call the script program
system(cmd_str.c_str());
Shell script parses the arguments to create output file's path and captures Gazebo's screen:
# read arguments etc...
mkdir -p ${OUTPUT_PATH}
# take the screenshot
import -window Gazebo "${OUTPUT_PATH}/${OUTPUT_NAME}.jpg"
You can use additional arguments to tell script to create a new folder or not. Hope it will be helpful.