PickNikRobotics / generate_parameter_library

Declarative ROS 2 Parameters
BSD 3-Clause "New" or "Revised" License
230 stars 43 forks source link

Python cmake example not working #175

Closed Timple closed 6 months ago

Timple commented 6 months ago

Minimal reproducable dockerfile:

FROM ros:iron
SHELL [ "/bin/bash", "-c" ]
RUN git clone https://github.com/PickNikRobotics/generate_parameter_library /root/catkin_ws/src/generate_parameter_library
RUN apt-get update -qq && rosdep update && rosdep install --from-paths /root/catkin_ws/src --ignore-src -r -y
WORKDIR /root/catkin_ws
RUN source /opt/ros/iron/setup.bash && colcon build --packages-up-to cmake_generate_parameter_module_example
RUN source install/setup.bash && python3 src/generate_parameter_library/example_cmake_python/cmake_generate_parameter_module_example/minimal_publisher.py --ros-args --params-file src/generate_parameter_library/example_python/config/implementation.yaml

Especially the installation in ./install/cmake_generate_parameter_module_example/local/lib/python3.10/dist-packages/cmake_generate_parameter_module_example/admittance_parameters.py looks suspicious as typical python modules are installed in the same path with /local.

Any ideas @pac48 ?

pac48 commented 6 months ago

@Timple I believe the install location for Python was changed between Humble and Python. So I will have to add a check to see what version of ROS is sourced and then change the path. It will probably take some investigation. This is the line that probably needs to change: https://github.com/PickNikRobotics/generate_parameter_library/blob/42c8f8a0591a2cc5993e8bac554b6594dd1425dd/generate_parameter_library/cmake/generate_parameter_library.cmake#L119

Timple commented 6 months ago

Thank you for looking into this! I can confirm that this line works in iron:

 set(PARAM_HEADER_FILE ${CMAKE_INSTALL_PREFIX}/lib/${PYTHON_VERSION}/site-packages/${PROJECT_NAME}/${LIB_NAME}.py)

-local/ dist=site

Reading the changelog, there seems to be an ament_get_python_install_dir function: https://github.com/ament/ament_cmake/pull/387/files Perhaps that one can be used.

pac48 commented 6 months ago

@Timple I used the ament_get_python_install_dir macro and tested it in the dockerfile and it worked. This is the PR https://github.com/PickNikRobotics/generate_parameter_library/pull/178