0
$\begingroup$

I am developing a package for the ROS, in fact it is a package of resources / models for the Gazebo, and I need with the presence of this package in the Workspace of Catking, to be automatically set the variable GAZEBO_MODEL_PATH for this package.

I could intervene in the file ~/catkin_mygazebo_ws/devel/setup.sh, adding the path to variable.

but first I would like to know if there is any way to do it by another more specialized route to Catkin.

Thankful.

$\endgroup$
0
$\begingroup$

After some tests and following suggestions in the reference links at the end of this answer, I came up with the following solution:

Let's assume you need to add the path to new gazebo templates when developing your packages, so create a directory called env_hooks in your template package folder.

Enter the directory and create a configuration file with the extension specified for each shell (.bash, .zsh, tcsh). This file can have any name, in the case I will use models_env. , change <shell_string> to the extension representing the shell, each file must be the required variables configuration according to the shell.

Now edit the CMakeLists.txt file and add the following directive to the end:

catkin_add_env_hooks (models_env SHELLS bash tcsh zsh DIRECTORY $ {CMAKE_CURRENT_SOURCE_DIR} / env-hooks)

For example, for the Bash shell, I edited my models_env.bash file and put:

#! /bin/bash
echo "*******"
echo "Preparing specific variables for the gazebo_model package"
echo "*******"

_CATKIN_ENV_HOOKS_PATH = $ (catkin locate arr_gazebo_models)
export GAZEBO_MODEL_PATH = "$ {_ CATKIN_ENV_HOOKS_PATH} / models: $ {GAZEBO_MODEL_PATH}"

References:

https://docs.ros.org/api/catkin/html/user_guide/environment.html https://docs.ros.org/api/catkin/html/dev_guide/generated_cmake_api.html#catkin_add_env_hooks

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.