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

Build fails if ROS 2 setup script has been sourced #60

Closed
RussellJoyce opened this issue May 6, 2021 · 3 comments
Closed

Build fails if ROS 2 setup script has been sourced #60

RussellJoyce opened this issue May 6, 2021 · 3 comments

Comments

@RussellJoyce
Copy link
Contributor

RussellJoyce commented May 6, 2021

  • Hardware description: ESP32
  • RTOS: FreeRTOS / ESP-IDF v4.2.1
  • Installation type: micro_ros_espidf_component
  • Version or commit hash: foxy

Steps to reproduce the issue

Building the micro-ROS component after sourcing the ROS 2 setup scripts into the environment causes the build to fail while compiling builtin_interfaces.
Running idf.py build for a second time then fails with fatal error: rcl/rcl.h: No such file or directory.

E.g. the following fails during build, but will work fine if the first line is excluded:

. /opt/ros/foxy/setup.zsh
export IDF_PATH=/home/russell/esp/esp-idf-v4.2.1
. $IDF_PATH/export.sh
git clone https://github.com/micro-ROS/micro_ros_espidf_component.git
cd micro_ros_espidf_component/examples/int32_publisher
idf.py set-target esp32
idf.py build

Additional information

This has briefly been covered previously in #1, and I suspect it could have also been the cause of the unexplained problems described in #53 (although that build might have just failed for some other reason).

While somehow changing the build scripts to work while the ROS 2 environment is present would obviously be best, for now just mentioning explicitly in the README that the environment should be clean and the ROS setup script should not be sourced before running the build would be good.

I'm sure I'm not the only person who sources the ROS scripts in their .zshrc file (or equivalent), or might assume that they should be present when working with anything ROS related, which sometimes makes it more of an explicit task to not source the scripts, rather than the other way around.

@pablogs9
Copy link
Member

pablogs9 commented May 7, 2021

Cool, I understand. IMO two actions can be taken:

  1. Add a line in the readme warning about that
  2. Is there any way of checking if the ROS 2 environment is enabled? Maybe we can make a check here

Would you mind making a contribution PR for this?

Thanks a lot!

@RussellJoyce
Copy link
Contributor Author

Thanks for your reply.

I agree - both of those seem like reasonable actions, but I guess the second would be better.
I'll take a look at trying to implement it when I get a chance.

@RussellJoyce
Copy link
Contributor Author

Unsetting AMENT_PREFIX_PATH and removing the ROS bin directory from PATH before the colcon build seems to get things working, at least in my environment. I don't think the other variables set up by the ROS setup script have any effect here, so can probably just be left as they are.

The best way I can think of to fix PATH is just to remove /opt/ros/$(ROS_DISTRO)/bin from it, which obviously won't work if the user has ROS installed anywhere else, but it seems safer than replacing the entire PATH variable with a fixed string.
Given there will still a possibility of having issues if the string substitution doesn't match, it could also be worth mentioning in the README to try a clean environment if the build fails.

I'll create a PR now that makes this change in the Makefile, hopefully in a way that won't break anything else!

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

No branches or pull requests

2 participants