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

List sourced workspaces

asked 2021-09-19 10:17:10 -0600

wl gravatar image

updated 2021-09-19 10:44:28 -0600

I'm experimenting with shell plugins, dynamically updating command line prompt.

Currently I'm running Zsh + OhMyZsh + powerlevel10k

I've managed to add ROS2 distro name and ROS2 domain ID to the command prompt. That was easy: I've added a shell function looking at environment vars ROS_DISTRO and ROS_DOMAIN_ID:

function prompt_my_ros2_env() {
    if [[ -v ROS_DISTRO ]]; then
        local ros_domain_id=""
        if [[ -v ROS_DOMAIN_ID ]]; then
            ros_domain_id="[$ROS_DOMAIN_ID]"
        fi

        p10k segment -t "$ROS_DISTRO$ros_domain_id"
    fi
}
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=my_ros2_env

Now I wonder, is it possible to create a list of sourced ROS2 workspaces?

I can see that some environment variables change after execution of source ./install/local_setup.zsh command, for example AMENT_PREFIX_PATH, PYTHONPATH, LD_LIBRARY_PATH. But sourcing one workspace adds several directories to almost each of them.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-09-19 13:02:12 -0600

Kenji Miyake gravatar image

I'm not sure whether this would help you, but if you use colcon, COLCON_PREFIX_PATH can be used to know sourced workspaces.

edit flag offensive delete link more

Comments

Indeed, this variable contains the list of of sourced workspaces. Thank you! Unfortunately, my initial idea is not very useful, because this list occupies a lot of space, I'm not sure how to compress it and if I need it at all.

wl gravatar image wl  ( 2021-09-23 11:16:19 -0600 )edit
0

answered 2021-09-19 10:24:12 -0600

flo gravatar image

I don't know why you need to know how many workspaces are sourced?

To give you a bit of a background knowledge from my understanding, the number of entries in i.e. AMENT_PREFIX_PATH are the number of packages you have successfully build and sourced from either your workspace or also packages that you have installed through apt packaging managers. This is used afaik for checking if a package is installed and where to find the include-folder/headers for building on top of those.

Is your workflow that you have n-workspaces and by that want to check if your shell is ready to go to ros2 run <package> ? Would probably more fun to dynamically check the package.xml for the run_depend of your desired package and see if everything is already included in the AMENT_PREFIX_PATH. Or make some traffic ligth that checks if the packages you want to use (based on a file in Home..) are already included..?

Eitherway, sounds fun what you are doing.

But this is just me thinking out loud.. :)

edit flag offensive delete link more

Comments

1

Currently I've got only one workspace, and maybe add one more in the future. The issue I'm solving is to provide a visual indication that everything required is sourced. However, it can be easily solved by adding shell alias, sourcing everything at once.

wl gravatar image wl  ( 2021-09-19 10:39:50 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-19 10:17:10 -0600

Seen: 618 times

Last updated: Sep 19 '21