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

Set up similar ros1&2 image publisher python nodes #1

Open
lucasw opened this issue Sep 27, 2023 · 5 comments
Open

Set up similar ros1&2 image publisher python nodes #1

lucasw opened this issue Sep 27, 2023 · 5 comments

Comments

@lucasw
Copy link
Owner

lucasw commented Sep 27, 2023

catkin_create_pkg ros1_example_pkg

(no --no-comments yet, manually delete the comment lines in package.xml and CMakeLists.txt)

ros2 pkg create --build-type ament_python ros2_example_pkg
@lucasw
Copy link
Owner Author

lucasw commented Sep 27, 2023

No issues having a mixed workspace in ros1, catkin gracefully skips over the ros2 one:

[build] Warning: Skipping package `ros2_example_pkg` because it has an unsupported package build type: `ament_python`                                                                                                     

But in ros2:

--- stderr: ros1_example_pkg                                                               
Traceback (most recent call last):
  File "/home/lucasw/ros/ros2_iron_misc/build/ros1_example_pkg/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/lucasw/ros/ros2_iron_misc/build/ros1_example_pkg/devel/env.sh')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/catkin/environment_cache.py", line 63, in generate_environment_script
    env_after = ast.literal_eval(output.decode('utf8'))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 1
    ROS_DISTRO was set to 'iron' before. Please make sure that the environment does not mix paths from different distributions.
               ^^^
SyntaxError: invalid syntax
CMake Error at /usr/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/home/lucasw/ros/ros2_iron_misc/build/ros1_example_pkg/catkin_generated/generate_cached_setup.py")
  returned error code 1
Call Stack (most recent call first):
  /usr/share/catkin/cmake/all.cmake:221 (safe_execute_process)
  /usr/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)

So skip it:

colcon build --symlink-install --packages-skip ros1_example_pkg

(can that be made persistent?)

Only get this deprecation warning:

--- stderr: ros2_example_pkg                   
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:146: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(

@lucasw
Copy link
Owner Author

lucasw commented Sep 27, 2023

rosmsg show Image

ros2 equivalent:

ros2 interface show sensor_msgs/msg/Image

@lucasw
Copy link
Owner Author

lucasw commented Sep 27, 2023

Forgot to install rqt_image_view? Didn't really forget, it just wasn't in ros2 repos yaml.

lucasw/ros_from_src#29

@lucasw
Copy link
Owner Author

lucasw commented Sep 28, 2023

export COLCON_DEFAULTS_FILE=$HOME/ros/colcon_defaults.yaml
{
    "build": {
        "symlink-install": true,
        "cmake-args": [
          "-DCMAKE_BUILD_TYPE=Release",
        ],
        "packages-skip": [
          "ros1_example_pkg",
        ],
    }
}

-> can use plain colcon build:

colcon build

@lucasw
Copy link
Owner Author

lucasw commented Sep 29, 2023

There doesn't appear to be a ros2 AnyMsg, but can get the message class like this:

    msg_class = get_msg_class(node, topic, blocking=True, include_hidden_topics=True)
    if msg_class is None:
        node.destroy_node()
        return
        
    rt = ROSTopicBandwidth(node, window_size)
    node.create_subscription(
        msg_class,
        topic,
        rt.callback, 
        qos_profile_sensor_data,
        raw=True
    )   

ros2topic/ros2topic/verb/bw.py

@lucasw lucasw changed the title Set up similar ros1&2 image publisher nodes Set up similar ros1&2 image publisher python nodes Oct 15, 2023
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

1 participant