Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images resources searched with a local path #51

Closed
11 tasks done
David-Estevez opened this issue May 20, 2016 · 7 comments
Closed
11 tasks done

Images resources searched with a local path #51

David-Estevez opened this issue May 20, 2016 · 7 comments

Comments

@David-Estevez
Copy link
Collaborator

David-Estevez commented May 20, 2016

Images resources searched with a local path (use ResourceFinder instead).

@jgvictores juansays: segfault if not found

EDIT: list of files with local paths

  • testMockupAudioManager.cpp
  • testSDLAudioManager.cpp
  • DeadScreen.cpp
  • testDeadScreen.cpp
  • testDeadState.cpp
  • InitScreen.cpp
  • testGameScreen.cpp
  • testGameState.cpp
  • testRdMockupImageManager.cpp
  • testRdProcessorImageEventListener.cpp
  • testRobotDevastation.cpp
@David-Estevez
Copy link
Collaborator Author

@jgvictores which is the default folder in which the resources are installed / looked for?

For instance, which folder corresponds to the following piece of code?

yarp::os::ResourceFinder rf;
rf.findFileByName("../sounds/RobotDevastationBSO.mp3")

@jgvictores
Copy link
Member

yarp::os::ResourceFinder is a rather complex, as seen in robotology/yarp#336, which points to "the painful details http://wiki.icub.org/wiki/YARP_ResourceFinder"

Apart from that piece of code, two intermediate important of lines from robotDevastation/main.cpp affect ResourceFinder. Combined, this results in:

yarp::os::ResourceFinder rf;
rf.setDefaultContext("robotDevastation");
rf.setDefaultConfigFile("robotDevastation.ini");
rf.findFileByName("../sounds/RobotDevastationBSO.mp3");

The yarp_install CMake directive copies/installs the files so they can be found by the ResourceFinder. Following the RobotDevastationBSO.mp3 example, the relevant lines of robotDevastation/share/sound/CMakeLists.txt are:

set(appname sounds)
file(GLOB mp3s ${CMAKE_CURRENT_SOURCE_DIR}/*.mp3)
yarp_install(FILES ${mp3s} DESTINATION ${RD_CONTEXTS_INSTALL_DIR}/${appname})

On my configuration, yarp_install copies/installs the files so they can be found by the ResourceFinder relative to robotDevastation/build/share/rd/contexts/robotDevastation or /usr/local/share/rd/contexts/robotDevastation/ (note that this is where the robotDevastation.ini file the third line of cpp above specifies lies).

@David-Estevez
Copy link
Collaborator Author

@jgvictores Fonts are currently accessed though their absolute path (i.e:

const std::string rd::DeadScreen::FONT_PATH = "/usr/share/fonts/truetype/freefont/FreeMono.ttf";

)

Is this ok or does it involve any risks?

@jgvictores
Copy link
Member

const std::string rd::DeadScreen::FONT_PATH = "/usr/share/fonts/truetype/freefont/FreeMono.ttf";

Looks totally dangerous and non-portable. If size and license are not an issue, I'd at least think of distributing it with robotDevastation.

@David-Estevez
Copy link
Collaborator Author

Everything fixed in 00f62ce

@David-Estevez
Copy link
Collaborator Author

Path should be something like "../images/image.png"

@David-Estevez
Copy link
Collaborator Author

Fixed in fa4dd65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants