ros2 / rviz

ROS 3D Robot Visualizer
BSD 3-Clause Clear License
291 stars 209 forks source link

Python API #640

Open BasVolkers opened 3 years ago

BasVolkers commented 3 years ago

Hi, im looking to migrate my package to ROS2. This package uses the python_bindings of rviz in ROS1. Are these also available somewhere for ROS2? I can't seem to find them.

clalancette commented 3 years ago

We don't currently have Python bindings available for the ROS 2 version of RViz. I've assigned the issue to one of the rviz maintainers in ROS 2 to take a look at the feasibility of doing so. Likely this will need community contribution to do so, as it isn't on our current roadmap.

jacobperron commented 3 years ago

I don't know much about the Python bindings in ROS 1, but it looks like we are generating the Python API from the C++ code with shiboken and/or sip. So I think doing something similar should be feasible for ROS 2.

For anyone who is willing to tackle this, I'd rather see shiboken used for Python API generation over sip. This is mainly because of licensing (shiboken is LGPL, while sip is GPL). Furthermore, IIUC, Qt has officially adopted shiboken as well. It looks like the shiboken generator was disabled a long time ago in ROS 1, but I guess it doesn't mean much for ROS 2, since the C++ code is very different.

Another option for exposing a Python API could be to use pybind11. FWIW, we are using pybind11 for rosbag2 Python bindings and are currently in progress of refactoring rclpy to use pybind11.

This needs someone to take a deeper look, but I'd expect we might have an easier time using shiboken considering it actively being used by other Qt-based projects.

EricCousineau-TRI commented 3 years ago

See also: https://gitlab.kitware.com/autopybind11/autopybind11/-/blob/55f7b955a65622414ebd961325779e3c404c3e13/README.rst#alternatives-comparison

hellantos commented 2 years ago

I have made a first attempt with shiboken here: https://github.com/ipa-cmh/rviz/tree/add-python-bindings It builds... Still some work and testing to though. Will open a PR when I am a little further along.

friackazoid commented 1 year ago

Hello, I want to port one python software to ROS2 and that is required python bindings for RVIZ. Can I help with this PR? what is required for the merge?

hellantos commented 1 year ago

@friackazoid there is #889 which works under circumstances. There is still a build dependency problem which I have only been able to solve for local build with python_qt_binding in same workspace. Also to merge Windows support is required. I have no idea where to start and test that.

I have a more recent version that we use in some internal projects - still throws a lot of warnings durign build, but works. Honestly, my funding for this activity got scrapped, so I cannot pursue it further right now. I will try and push the latest working version I have to #889.

Also check out https://github.com/ros-visualization/python_qt_binding/issues/114 which documents my effort to update python_qt_bindings.

KKSTB commented 1 year ago

Thanks for your nice effort @ipa-cmh.

I would like to try VisualizationFramePy in my program. I downloaded the latest PR: https://github.com/ipa-cmh/rviz/tree/f324c63a5035c2351ddf599fe75e1995119ea89c

I tried to build it in this environment: OS: Ububtu 22.04 ROS: iron Build command: colcon build --merge-install --allow-overriding rviz2 rviz_default_plugins

But I am stuck at this colcon_cmake exception:

--- stderr: rviz_python_bindings
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/colcon_core/executor/init.py", line 91, in call rc = await self.task(*args, *kwargs) File "/usr/lib/python3/dist-packages/colcon_core/task/init.py", line 93, in call return await task_method(args, **kwargs) File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_cmake/build.py", line 59, in build rc = await extension.build( File "/usr/lib/python3/dist-packages/colcon_cmake/task/cmake/build.py", line 87, in build rc = await self._reconfigure(args, env) File "/usr/lib/python3/dist-packages/colcon_cmake/task/cmake/build.py", line 182, in _reconfigure buildfile = get_buildfile(cmake_cache) File "/usr/lib/python3/dist-packages/colcon_cmake/task/cmake/init.py", line 112, in get_buildfile if 'Ninja' in generator: TypeError: argument of type 'NoneType' is not iterable

At colcon_cmake/task/cmake/build.py", line 182, it indicates there is some sort of build environment reconfigure failure causing a non-zero return code (as indicated by the comments in colcon_cmake/task/cmake/build.py).

The colcon code: https://github.com/colcon/colcon-cmake/blob/6c4985ba4cc0020ffbb4d2f357387917db1f121f/colcon_cmake/task/cmake/build.py#L182C14-L182C47 https://github.com/colcon/colcon-cmake/blob/6c4985ba4cc0020ffbb4d2f357387917db1f121f/colcon_cmake/task/cmake/__init__.py#L112C8-L112C42

I have installed python3_pyside2 and python3_qtpy (though not by rosdep, but by apt install python3-qtpy libpyside2-dev libshiboken2-dev python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtnetwork python3-pyside2.qtprintsupport python3-pyside2.qtsvg python3-pyside2.qttest python3-pyside2.qtwidgets python3-pyside2.qtxml shiboken2 as indicated in https://github.com/ros/rosdistro/blob/master/rosdep/python.yaml)

Not sure what build environment is further required. Thanks.

KKSTB commented 1 year ago

I tried hard locating the problem using the verbose build command: VERBOSE=1 colcon build --merge-install --allow-overriding rviz2 rviz_default_plugins --event-handlers console_cohesion+ --cmake-args -DCMAKE_VERBOSE_MAKEFILE=ON

and is able to locate the exception location (caused by ament_get_recursive_properties() at https://github.com/ipa-cmh/rviz/blob/f324c63a5035c2351ddf599fe75e1995119ea89c/rviz_python_bindings/CMakeLists.txt#L50).

I substituted ament_get_recursive_properties() with older version of include_dirs method in rviz_python_bindings CMakeLists.txt instead (https://github.com/ipa-cmh/rviz/blob/05f5a746b472aeadf2d58bb2c51b2198a8327b96/rviz_python_bindings/CMakeLists.txt#L83)

However, there is still a missing cmake function shiboken_generator_ext() at https://github.com/ipa-cmh/rviz/blob/f324c63a5035c2351ddf599fe75e1995119ea89c/rviz_python_bindings/CMakeLists.txt#L82.

Then I found this: https://github.com/ipa-cmh/python_qt_binding/tree/dd8e43fca94f4cd3f88952d4093270047da4c7cf.

After adding the last puzzle, the project can be built.

And I found I can further build with iron rviz2, by simply adding VisualizationFrame() to rviz_common (https://github.com/ros2/rviz/pull/889/commits/3e03e3070e18182526dd628864deae9872fe9ed5)

hellantos commented 1 year ago

@KKSTB sorry mate, I was on vacation and it has been some time I worked on this, currently the funding has gone away again. I think I have a version somewhere that will build directly, but it is not very nicely done and still produces a lot of errors.

In general, I had quite some problems with making this build stably, because the build cache and install folders usually contain some stuff that will make you miss some errors when doing changes.

In the end, we are not using rviz2 for end-user interfaces anymore. We now switched to nicegui. https://github.com/zauberzeug/nicegui

KKSTB commented 1 year ago

Hi nice to hear from you @ipa-cmh.

I try to use the successfully built rviz_python_bindings in a freshly created ROS2 python package with an empty pyside window. It displays an empty window as intended, but it crashes with segmentation fault once I add a line to import rviz_shiboken:

Current thread 0x00007fc09e05e740 (most recent call first):
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1176 in create_module
  File "<frozen importlib._bootstrap>", line 571 in module_from_spec
  File "<frozen importlib._bootstrap>", line 674 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1078 in _handle_fromlist
  File "/home/kk/.local/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/__feature__.py", line 142 in _import
...

Hope that there would be help on how to solve this issue.

hellantos commented 1 year ago

Try the following for import, that is how I have it in our project.

import qtpy
from qtpy.QtGui import *
from qtpy.QtCore import *

try:
    from qtpy.QtWidgets import *
except ImportError:
    pass
from rviz import YamlConfigReader, VisualizationFrame, Config, rviz_common

You can than do the following:

with open("parameters.yml", "w") as outfile:
  yaml.dump(param_file, outfile, default_flow_style=False)
frame = VisualizationFrame(str(Path("parameters.yml").absolute()))
frame.setApp(app)
frame.setSplashPath("")
frame.initialize()
sleep(3.0)
frame.loadDisplayConfig(file)

Finally you'll have to add the frame to your layout.

KKSTB commented 1 year ago

Thanks for your quick reply. I found that it is my system installation problem.

I found that if I use Qt classes in python_qt_binding that all rqt plugins are using, I still have to pip3 install PySide2 even though I have apt installed the pyside2 components.

If I freshly create ROS2 python package without following rqt plugin example, and use qtpy just as your example did, then the pip3 PySide2 is not required.

After pip uninstalling pyside2 there is no crash when importing. Will continue trying. Thanks @ipa-cmh!

KKSTB commented 1 year ago

Your example is very essential. I found that I have to call frame.setApp(app) in order to run it (where app is a QApplication), otherwise it crashes with code -11. ROS1 version of VisualizationFrame does not need this to run.

I think the major trouble is the difficulty to debug the issue. It often crashes with exit code -11 or causes segmentation fault without indicating the reason if configuration is not followed strictly (e.g. 1: pyside compatibility problem with python_qt_binding. 2: the need to call frame.setApp(app)).

KKSTB commented 1 year ago

There is yet another problem. Even though I can display the VisualizationFrame using my ROS2 package, the 3D screen is flashing. If I ros2 run rviz2 rviz2 directly there is no flashing problem.

Minimal code of my ROS2 package:

import os
import sys
import rviz

from qtpy.QtWidgets import QApplication

from ament_index_python.packages import get_package_share_directory

def main():
    app = QApplication(sys.argv)
    rviz_frame = rviz.VisualizationFrame()
    rviz_frame.setApp(app)
    rviz_frame.setSplashPath("")
    rviz_frame.initialize(os.path.join(get_package_share_directory('test_gui'), 'resource', 'default.rviz'))
    rviz_frame.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

I believe it is not related to python API problem, since it also flashes if I embed rviz using the QWindow.fromWinId() method (https://github.com/awesomebytes/rqt_embed_window/blob/60ce21132a5d6a18cea674bb15e7c6a2dcfedf13/src/rqt_embed_window/RqtEmbedWindow.py#L130).

But in case someone has a solution it is very welcome.

hellantos commented 1 year ago

Your example is very essential. I found that I have to call frame.setApp(app) in order to run it (where app is a QApplication), otherwise it crashes with code -11. ROS1 version of VisualizationFrame does not need this to run.

This is caused by an API change of the underlying c++-Code. There is also the issue that you have to pass in a smart node pointer to the constructor of VisualizationFrame now. Therefore, there is now some helper code necessary.

I think the major trouble is the difficulty to debug the issue. It often crashes with exit code -11 or causes segmentation fault without indicating the reason if configuration is not followed strictly (e.g. 1: pyside compatibility problem with python_qt_binding. 2: the need to call frame.setApp(app)).

Overall the whole wrapping part is pretty complex and if you have pyside and pyqt installed there is also often confusion about the version that is used. Generally, I would only use and work on the wrapper if you really need it. Otherwise stick with C++ for now.

KKSTB commented 1 year ago

Python is much easier and much faster to develop for average user. Also ROS1 has rviz python binding, so its normal to expect ROS2 to have it too.

I tried to embed a C++ version of rviz_common::VisualizationFrame. Unfortunately it seems to work fine without flashing.

#include <qt5/QtWidgets/QApplication>
#include <qt5/QtWidgets/QMainWindow>

#include "rclcpp/rclcpp.hpp"

#include <rviz_common/visualization_frame.hpp>
#include "rviz_common/ros_integration/ros_client_abstraction.hpp"
#include "rviz_common/ros_integration/ros_node_abstraction.hpp"

int main(int argc, char* argv[])
{
//  rclcpp::init(argc, argv);

//  RCLCPP_INFO(rclcpp::get_logger("my_logger"), "start");

  QApplication app(argc, argv);

  QMainWindow window = QMainWindow();

  std::unique_ptr<rviz_common::ros_integration::RosClientAbstraction> ros_client_abstraction_ = std::make_unique<rviz_common::ros_integration::RosClientAbstraction>();
  rviz_common::ros_integration::RosNodeAbstractionIface::WeakPtr rviz_ros_node_ = ros_client_abstraction_->init(argc, argv, "rviz", false);
  rviz_common::VisualizationFrame rviz_frame(rviz_ros_node_);
  rviz_frame.setApp(&app);
  rviz_frame.setSplashPath("");
  rviz_frame.initialize(rviz_ros_node_);

  window.setCentralWidget(&rviz_frame);
  window.show();

  RCLCPP_INFO(rclcpp::get_logger("my_logger"), "exec");

  int ret = app.exec();

  ros_client_abstraction_->shutdown();

//  rclcpp::shutdown();

  return ret;
}

I also modified visualizer_frame_py.cpp so that rviz_python_bindings can be built without having to modify rviz2 source, and built with ROS2 iron without rviz2 source. Unfortunately this doesn't fix the flash issue.

#include "rviz_python_bindings/visualizer_frame_py.hpp"

using namespace rviz_common;

VisualizerFramePy::VisualizerFramePy(QWidget * parent)
: VisualizationFrame(rviz_common::ros_integration::RosNodeAbstractionIface::WeakPtr(), parent)
{
  ros_client_abstraction_ = std::make_unique<rviz_common::ros_integration::RosClientAbstraction>();
  rviz_ros_node_ = ros_client_abstraction_->init(0, nullptr, "rviz", false);
}

VisualizerFramePy::~VisualizerFramePy()
{
  ros_client_abstraction_->shutdown();
}

bool VisualizerFramePy::node_ok()
{
  return ros_client_abstraction_->ok();
}

void VisualizerFramePy::initialize(
  const QString & display_config_file)
{
  VisualizationFrame::initialize(rviz_ros_node_, display_config_file);
}

I tried with / without nvidia card as well. Since QWindow.fromWinId() (with PyQt5 at that time, not pyside) also has flash problem, I think the problem is some rviz internal problem induced by the use of python.

KKSTB commented 1 year ago

I found that in pyside environment, ogre_render_window_->windowMovedOrResized()(https://github.com/ros2/rviz/blob/7a2a6bc2e9cd8df996d7f320ef8c166638691d47/rviz_rendering/src/rviz_rendering/ogre_render_window_impl.cpp#L273C9-L273C23) raises RenderWindow::exposeEvent()(https://github.com/ros2/rviz/blob/7a2a6bc2e9cd8df996d7f320ef8c166638691d47/rviz_rendering/src/rviz_rendering/render_window.cpp#L191C5-L191C5), which in turn calls RenderWindowImpl::resize(), resulting in infinite loop of events causing flash problem.

Whereas in C++ environment, ogre_render_window_->windowMovedOrResized() does not raise RenderWindow::exposeEvent().

If I comment impl_->resize() inside RenderWindow::exposeEvent(), then there is no flash, but the window size on startup becomes wrong.

KKSTB commented 1 year ago

The window size problem is related to the if condition inside resize event. After completely removing isExposed() condition and exposeEvent() there is no flash problem and initial size problem.

KKSTB commented 1 year ago

I am trying to build the rviz shiboken bindings on Win10. I am doing it in a VM.

After resolving several problems (ROS2 directory path, shiboken2_generator installation, environment variables, typesystem-paths, path splitter, etc) I am still stuck at making shiboken generator to work on Win10.

Running Shiboken generator for rviz_shiboken Python bindings... qt.shiboken: (typesystem) Duplicate type entry: 'QMessageLogContext' (typesystem) clang_parseTranslationUnit2(0x0, cmd[127]=-fms-compatibility-version=19 -Wno-microsoft-enum-value -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -Wno-constant-logical-operand -std=c++17 -IC:/dev/ros2_ws/install/include/rviz_rendering -IC:/ProgramData/chocolatey/lib/eigen/include -IC:/ci/ws/install/opt/rviz_assimp_vendor/include -IC:/ci/ws/install/include/geometry_msgs -IC:/Python38/lib/site-packages/numpy/core/include -IC:/ci/ws/install/include/pluginlib -IC:/ci/ws/install/include/rclcpp -IC:/ci/ws/install/include/sensor_msgs -IC:/ci/ws/install/include/std_msgs -IC:/ci/ws/install/include/tf2 -IC:/ci/ws/install/include/tf2_geometry_msgs -IC:/ci/ws/install/include/tf2_ros -IC:/ci/ws/install/include/urdf -IC:/ci/ws/install/opt/yaml_cpp_vendor/include -IC:/ci/ws/install/include/rviz_common -IC:/ci/ws/install/opt/rviz_assimp_vendor/include -IC:/ProgramData/chocolatey/lib/eigen/include -IC:/ci/ws/install/include/resource_retriever -IC:/ci/ws/install/include/ament_index_cpp -IC:/dev/ros2_ws/install/include/rviz_rendering -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE -IC:/ci/ws/install/opt/rviz_ogre_vendor/include/OGRE -IC:/ci/ws/install/include/rclcpp -IC:/ci/ws/install/include/ament_index_cpp -IC:/ci/ws/install/include/libstatistics_collector -IC:/ci/ws/install/include/rcl -IC:/ci/ws/install/include/rcpputils -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/builtin_interfaces -IC:/Python38/lib/site-packages/numpy/core/include -IC:/ci/ws/install/include/rosgraph_msgs -IC:/ci/ws/install/include/rosidl_typesupport_cpp -IC:/ci/ws/install/include/rosidl_typesupport_c -IC:/ci/ws/install/include/rosidl_runtime_cpp -IC:/ci/ws/install/include/rcl_yaml_param_parser -IC:/ci/ws/install/include/statistics_msgs -IC:/ci/ws/install/include/tracetools -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/rosidl_dynamic_typesupport -IC:/ci/ws/install/include/rosidl_runtime_c -IC:/ci/ws/install/include/rmw -IC:/ci/ws/install/include/rosidl_typesupport_interface -IC:/ci/ws/install/include/builtin_interfaces -IC:/Python38/lib/site-packages/numpy/core/include -IC:/ci/ws/install/include/service_msgs -IC:/ci/ws/install/include/rosidl_runtime_c -IC:/ci/ws/install/include/rosidl_typesupport_interface -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/rosidl_runtime_cpp -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp -IC:/ci/ws/install/include/rosidl_typesupport_c -IC:/ci/ws/install/include/rmw -IC:/ci/ws/install/include/rosidl_typesupport_cpp -IC:/ci/ws/install/include/rcl_interfaces -IC:/ci/ws/install/include/builtin_interfaces -IC:/Python38/lib/site-packages/numpy/core/include -IC:/ci/ws/install/include/geometry_msgs -IC:/ci/ws/install/include/service_msgs -IC:/ci/ws/install/include/action_msgs -IC:/ci/ws/install/include/rosidl_runtime_c -IC:/ci/ws/install/include/rosidl_typesupport_interface -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/rosidl_runtime_cpp -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp -IC:/ci/ws/install/include/rosidl_typesupport_c -IC:/ci/ws/install/include/rmw -IC:/ci/ws/install/include/rosidl_typesupport_cpp -IC:/ci/ws/install/include/tf2_msgs -IC:/ci/ws/install/include/ament_index_cpp -IC:/ci/ws/install/include/class_loader -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/rcpputils -IC:/ProgramData/chocolatey/lib/tinyxml2/include -IC:/ci/ws/install/include/service_msgs -IC:/Python38/lib/site-packages/numpy/core/include -IC:/ci/ws/install/include/rosidl_runtime_c -IC:/ci/ws/install/include/rosidl_typesupport_interface -IC:/ci/ws/install/include/rcutils -IC:/ci/ws/install/include/rosidl_runtime_cpp -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c -IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp -IC:/ci/ws/install/include/rosidl_typesupport_c -IC:/ci/ws/install/include/rmw -IC:/ci/ws/install/include/rosidl_typesupport_cpp -IC:/ci/ws/install/include/rcpputils -IC:/ci/ws/install/include/rosidl_typesupport_introspection_c -IC:/ci/ws/install/include/rosidl_typesupport_introspection_cpp -IC:/ci/ws/install/include/type_description_interfaces -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc -IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE -IC:/dev/ros2_ws/src/rviz_python_bindings/include -IC:/Python38/Lib/site-packages/PySide2/include C:/Users/vboxuser/AppData/Local/Temp/global_FzgQiP.hpp "-DQT_ANNOTATE_ACCESS_SPECIFIER(a)=attribute((annotate(#a)))" "-DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#VA_ARGS__),#type);") libclang: crash detected during parsing: { 'source_filename' : '(null)' 'command_line_args' : ['clang', '-fms-compatibility-version=19', '-Wno-microsoft-enum-value', '-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH', '-Wno-constant-logical-operand', '-std=c++17', '-IC:/dev/ros2_ws/install/include/rviz_rendering', '-IC:/ProgramData/chocolatey/lib/eigen/include', '-IC:/ci/ws/install/opt/rviz_assimp_vendor/include', '-IC:/ci/ws/install/include/geometry_msgs', '-IC:/Python38/lib/site-packages/numpy/core/include', '-IC:/ci/ws/install/include/pluginlib', '-IC:/ci/ws/install/include/rclcpp', '-IC:/ci/ws/install/include/sensor_msgs', '-IC:/ci/ws/install/include/std_msgs', '-IC:/ci/ws/install/include/tf2', '-IC:/ci/ws/install/include/tf2_geometry_msgs', '-IC:/ci/ws/install/include/tf2_ros', '-IC:/ci/ws/install/include/urdf', '-IC:/ci/ws/install/opt/yaml_cpp_vendor/include', '-IC:/ci/ws/install/include/rviz_common', '-IC:/ci/ws/install/opt/rviz_assimp_vendor/include', '-IC:/ProgramData/chocolatey/lib/eigen/include', '-IC:/ci/ws/install/include/resource_retriever', '-IC:/ci/ws/install/include/ament_index_cpp', '-IC:/dev/ros2_ws/install/include/rviz_rendering', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE', '-IC:/ci/ws/install/opt/rviz_ogre_vendor/include/OGRE', '-IC:/ci/ws/install/include/rclcpp', '-IC:/ci/ws/install/include/ament_index_cpp', '-IC:/ci/ws/install/include/libstatistics_collector', '-IC:/ci/ws/install/include/rcl', '-IC:/ci/ws/install/include/rcpputils', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/builtin_interfaces', '-IC:/Python38/lib/site-packages/numpy/core/include', '-IC:/ci/ws/install/include/rosgraph_msgs', '-IC:/ci/ws/install/include/rosidl_typesupport_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_c', '-IC:/ci/ws/install/include/rosidl_runtime_cpp', '-IC:/ci/ws/install/include/rcl_yaml_param_parser', '-IC:/ci/ws/install/include/statistics_msgs', '-IC:/ci/ws/install/include/tracetools', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/rosidl_dynamic_typesupport', '-IC:/ci/ws/install/include/rosidl_runtime_c', '-IC:/ci/ws/install/include/rmw', '-IC:/ci/ws/install/include/rosidl_typesupport_interface', '-IC:/ci/ws/install/include/builtin_interfaces', '-IC:/Python38/lib/site-packages/numpy/core/include', '-IC:/ci/ws/install/include/service_msgs', '-IC:/ci/ws/install/include/rosidl_runtime_c', '-IC:/ci/ws/install/include/rosidl_typesupport_interface', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/rosidl_runtime_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_c', '-IC:/ci/ws/install/include/rmw', '-IC:/ci/ws/install/include/rosidl_typesupport_cpp', '-IC:/ci/ws/install/include/rcl_interfaces', '-IC:/ci/ws/install/include/builtin_interfaces', '-IC:/Python38/lib/site-packages/numpy/core/include', '-IC:/ci/ws/install/include/geometry_msgs', '-IC:/ci/ws/install/include/service_msgs', '-IC:/ci/ws/install/include/action_msgs', '-IC:/ci/ws/install/include/rosidl_runtime_c', '-IC:/ci/ws/install/include/rosidl_typesupport_interface', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/rosidl_runtime_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_c', '-IC:/ci/ws/install/include/rmw', '-IC:/ci/ws/install/include/rosidl_typesupport_cpp', '-IC:/ci/ws/install/include/tf2_msgs', '-IC:/ci/ws/install/include/ament_index_cpp', '-IC:/ci/ws/install/include/class_loader', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/rcpputils', '-IC:/ProgramData/chocolatey/lib/tinyxml2/include', '-IC:/ci/ws/install/include/service_msgs', '-IC:/Python38/lib/site-packages/numpy/core/include', '-IC:/ci/ws/install/include/rosidl_runtime_c', '-IC:/ci/ws/install/include/rosidl_typesupport_interface', '-IC:/ci/ws/install/include/rcutils', '-IC:/ci/ws/install/include/rosidl_runtime_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_c', '-IC:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp', '-IC:/ci/ws/install/include/rosidl_typesupport_c', '-IC:/ci/ws/install/include/rmw', '-IC:/ci/ws/install/include/rosidl_typesupport_cpp', '-IC:/ci/ws/install/include/rcpputils', '-IC:/ci/ws/install/include/rosidl_typesupport_introspection_c', '-IC:/ci/ws/install/include/rosidl_typesupport_introspection_cpp', '-IC:/ci/ws/install/include/type_description_interfaces', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc', '-IC:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE', '-IC:/dev/ros2_ws/src/rviz_python_bindings/include', '-IC:/Python38/Lib/site-packages/PySide2/include', 'C:/Users/vboxuser/AppData/Local/Temp/global_FzgQiP.hpp', '-DQT_ANNOTATE_ACCESS_SPECIFIER(a)=attribute((annotate(#a)))', '-DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#__VA_ARGS),#type);'], 'unsaved_files' : [], 'options' : 66, } CUSTOMBUILD : (typesystem) Could not parse -DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#__VA_ARGS__),#type);, error code: 2 [C:\dev\ros2_ws\build\rviz_python_bindings\rviz_shiboken.vcxproj] Keeping temporary file: C:\Users\vboxuser\AppData\Local\Temp\global_FzgQiP.hpp shiboken: Error running ApiExtractor. Command line: --generatorSet=shiboken --enable-pyside-extensions --language-level=c++17 --include-paths=C:/dev/ros2_ws/install/include/rviz_rendering;C:/ProgramData/chocolatey/lib/eigen/include;C:/ci/ws/install/opt/rviz_assimp_vendor/include;C:/ci/ws/install/include/geometry_msgs;C:/Python38/lib/site-packages/numpy/core/include;C:/ci/ws/install/include/pluginlib;C:/ci/ws/install/include/rclcpp;C:/ci/ws/install/include/sensor_msgs;C:/ci/ws/install/include/std_msgs;C:/ci/ws/install/include/tf2;C:/ci/ws/install/include/tf2_geometry_msgs;C:/ci/ws/install/include/tf2_ros;C:/ci/ws/install/include/urdf;C:/ci/ws/install/opt/yaml_cpp_vendor/include;C:/ci/ws/install/include/rviz_common;C:/ci/ws/install/opt/rviz_assimp_vendor/include;C:/ProgramData/chocolatey/lib/eigen/include;C:/ci/ws/install/include/resource_retriever;C:/ci/ws/install/include/ament_index_cpp;C:/dev/ros2_ws/install/include/rviz_rendering;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE;C:/ci/ws/install/opt/rviz_ogre_vendor/include/OGRE;C:/ci/ws/install/include/rclcpp;C:/ci/ws/install/include/ament_index_cpp;C:/ci/ws/install/include/libstatistics_collector;C:/ci/ws/install/include/rcl;C:/ci/ws/install/include/rcpputils;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/builtin_interfaces;C:/Python38/lib/site-packages/numpy/core/include;C:/ci/ws/install/include/rosgraph_msgs;C:/ci/ws/install/include/rosidl_typesupport_cpp;C:/ci/ws/install/include/rosidl_typesupport_c;C:/ci/ws/install/include/rosidl_runtime_cpp;C:/ci/ws/install/include/rcl_yaml_param_parser;C:/ci/ws/install/include/statistics_msgs;C:/ci/ws/install/include/tracetools;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/rosidl_dynamic_typesupport;C:/ci/ws/install/include/rosidl_runtime_c;C:/ci/ws/install/include/rmw;C:/ci/ws/install/include/rosidl_typesupport_interface;C:/ci/ws/install/include/builtin_interfaces;C:/Python38/lib/site-packages/numpy/core/include;C:/ci/ws/install/include/service_msgs;C:/ci/ws/install/include/rosidl_runtime_c;C:/ci/ws/install/include/rosidl_typesupport_interface;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/rosidl_runtime_cpp;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_c;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp;C:/ci/ws/install/include/rosidl_typesupport_c;C:/ci/ws/install/include/rmw;C:/ci/ws/install/include/rosidl_typesupport_cpp;C:/ci/ws/install/include/rcl_interfaces;C:/ci/ws/install/include/builtin_interfaces;C:/Python38/lib/site-packages/numpy/core/include;C:/ci/ws/install/include/geometry_msgs;C:/ci/ws/install/include/service_msgs;C:/ci/ws/install/include/action_msgs;C:/ci/ws/install/include/rosidl_runtime_c;C:/ci/ws/install/include/rosidl_typesupport_interface;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/rosidl_runtime_cpp;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_c;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp;C:/ci/ws/install/include/rosidl_typesupport_c;C:/ci/ws/install/include/rmw;C:/ci/ws/install/include/rosidl_typesupport_cpp;C:/ci/ws/install/include/tf2_msgs;C:/ci/ws/install/include/ament_index_cpp;C:/ci/ws/install/include/class_loader;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/rcpputils;C:/ProgramData/chocolatey/lib/tinyxml2/include;C:/ci/ws/install/include/service_msgs;C:/Python38/lib/site-packages/numpy/core/include;C:/ci/ws/install/include/rosidl_runtime_c;C:/ci/ws/install/include/rosidl_typesupport_interface;C:/ci/ws/install/include/rcutils;C:/ci/ws/install/include/rosidl_runtime_cpp;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_c;C:/ci/ws/install/include/rosidl_typesupport_fastrtps_cpp;C:/ci/ws/install/include/rosidl_typesupport_c;C:/ci/ws/install/include/rmw;C:/ci/ws/install/include/rosidl_typesupport_cpp;C:/ci/ws/install/include/rcpputils;C:/ci/ws/install/include/rosidl_typesupport_introspection_c;C:/ci/ws/install/include/rosidl_typesupport_introspection_cpp;C:/ci/ws/install/include/type_description_interfaces;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtWidgets;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtGui;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtCore;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/mkspecs/win32-msvc;C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/include/QtANGLE;C:/dev/ros2_ws/src/rviz_python_bindings/include;C:/Python38/Lib/site-packages/PySide2/include --typesystem-paths=C:/Python38/Lib/site-packages/PySide2/typesystems --output-directory=C:/dev/ros2_ws/build/rviz_python_bindings C:/dev/ros2_ws/src/rviz_python_bindings/conf/global.hpp C:/dev/ros2_ws/src/rviz_python_bindings/conf/typesystem.xml C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\dev\ros2_ws\build\rviz_python_bindings\CMakeFiles\626b5e82e431108ec5b24d43613cd5ca\rviz_shiboken_module_wrapper.cpp.rule;C:\dev\ros2_ws\src\rviz_python_bindings\CMakeLists.txt' exited with code 1. [C:\dev\ros2_ws\build\rviz_python_bindings\rviz_shiboken.vcxproj]

I notice there are some strange args near the end ('-DQT_ANNOTATE_ACCESS_SPECIFIER(a)=__attribute__((annotate(#a)))', '-DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#__VA_ARGS__),#type);'), but dont know where are they coming from and they didnt exist in the actual command in Command line: --generatorSet=shiboken output.

@ipa-cmh are you familiar with shiboken2_generator and libclang?

KKSTB commented 1 year ago

I ran shiboken2.exe directly to look into the problem. It was due to compatibility with MSVC v142/latest (https://github.com/KDAB/KDDockWidgets/issues/114).

After installing MSVC v142/v14.26 on top of v142/latest and adding -vcvars_ver=14.26 in the x64 Native Tools Command Prompt shortcut, there is some output. It will then further ask for missing header (e.g. console_bridge_INCLUDE_DIRS).

Finally shiboken2.exe crashes with no output for any #include involving rclcpp / any #include inside rclcpp. It is difficult to proceed any further with no output.

So unless rviz adds a wrapper class / abstraction interface to completely hide rclcpp, there is little hope for rviz to support shiboken python binding on Win10 (i.e. only Ubuntu works).