[ros-users] [Discourse.ros.org] [Next Generation ROS] Mixed python/cpp Ament package

Sidd ros.discourse at gmail.com
Mon Mar 13 18:19:28 UTC 2017




Okay, this is what I have right now. My package has the following structure - 

    - my_pkg
        - CMakeLists.txt
        - package.xml
        - src
            - talker.cpp
        - my_pkg
            - __init__.py
            - listener.py
        - setup.py

My CMakeLists.txt looks like this -
    
    cmake_minimum_required(VERSION 3.5)
    
    project(my_pkg)
    
    if(NOT WIN32)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic")
    endif()
    
    find_package(ament_cmake REQUIRED)
    find_package(ament_cmake_python REQUIRED)
    find_package(rclcpp REQUIRED)
    find_package(std_msgs REQUIRED)
    find_package(python_cmake_module REQUIRED)
    find_package(PythonExtra MODULE)
    
    ament_python_install_package(${PROJECT_NAME})
    
    add_executable(${PROJECT_NAME}_talker src/talker.cpp)
    ament_target_dependencies(${PROJECT_NAME}_talker rclcpp std_msgs)
    
    install(TARGETS
      ${PROJECT_NAME}_talker
      DESTINATION bin
    )
    
    ament_package()
    
My `setup.py` looks like this - 
from setuptools import setup, Extension

    setup(
        name='my_pkg',
        version='0.0.0',
        packages=[],
        py_modules=[
            'my_pkg.listener',],
        install_requires=['setuptools'],
        author='user',
        author_email='user at gmail.com',
        maintainer='user
        maintainer_email='user at gmail.com',
        keywords=['ROS'],
        classifiers=[
            'Intended Audience :: Developers',
            'License :: OSI Approved :: Apache Software License',
            'Programming Language :: Python',
            'Topic :: Software Development',
        ],
        description='Mixed Ament package  for python and cpp files.',
        license='Apache License, Version 2.0',
        test_suite='test',
        entry_points={
            'console_scripts': [
                'my_pkg_listener = my_pkg.listener:main',
            ],
        },
    )

I am able to compile the package, and generate an executable for `my_pkg_talker`. 
However `ament` fails to recognize the `setup.py` and install a target for the python node. Is there something else I need to do specifically for ament to recognize the existence of a `setup.py` and run it?






---
[Visit Topic](https://discourse.ros.org/t/mixed-python-cpp-ament-package/1452/9) or reply to this email to respond.




More information about the ros-users mailing list