ika-rwth-aachen / mqtt_client

ROS / ROS 2 C++ Node for bi-directionally bridging messages between ROS and MQTT
MIT License
172 stars 40 forks source link

Error when downloading mqtt bridge for ROS2. #44

Open rehman257800 opened 9 months ago

rehman257800 commented 9 months ago

When im trying to build workspace using this command "colcon build --packages-up-to mqtt_client --cmake-args -DCMAKE_BUILD_TYPE=Release" for ROS2.

Im getting this error "colcon build --packages-up-to mqtt_client --cmake-args -DCMAKE_BUILD_TYPE=Release Starting >>> mqtt_client_interfaces --- stderr: mqtt_client_interfaces
CMake Error at /opt/ros/foxy/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:60 (message): execute_process(/home/aexlab/anaconda3/bin/python3 -m rosidl_adapter --package-name mqtt_client_interfaces --arguments-file /home/aexlab/ros2_ws/src/build/mqtt_client_interfaces/rosidl_adapterargumentsmqtt_client_interfaces.json --output-dir /home/aexlab/ros2_ws/src/build/mqtt_client_interfaces/rosidl_adapter/mqtt_client_interfaces --output-file /home/aexlab/ros2_ws/src/build/mqtt_client_interfaces/rosidl_adapter/mqtt_client_interfaces.idls) returned error code 1:

AttributeError processing template 'msg.idl.em'

Traceback (most recent call last):

File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/resource/__init__.py", line 51, in evaluate_template
  em.BUFFERED_OPT: True,

AttributeError: module 'em' has no attribute 'BUFFERED_OPT'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/aexlab/anaconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main
  return _run_code(code, main_globals, None,
File "/home/aexlab/anaconda3/lib/python3.9/runpy.py", line 87, in _run_code
  exec(code, run_globals)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/__main__.py", line 19, in <module>
  sys.exit(main())
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/main.py", line 53, in main
  abs_idl_file = convert_to_idl(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/__init__.py", line 19, in convert_to_idl
  return convert_msg_to_idl(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/msg/__init__.py", line 39, in convert_msg_to_idl
  expand_template('msg.idl.em', data, output_file, encoding='iso-8859-1')
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/resource/__init__.py", line 23, in expand_template
  content = evaluate_template(template_name, data)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_adapter/resource/__init__.py", line 69, in evaluate_template
  _interpreter.shutdown()

AttributeError: 'NoneType' object has no attribute 'shutdown'

Call Stack (most recent call first): /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:130 (rosidl_adapt_interfaces) CMakeLists.txt:14 (rosidl_generate_interfaces)


Failed <<< mqtt_client_interfaces [2.66s, exited with code 1]

Summary: 0 packages finished [3.53s] 1 package failed: mqtt_client_interfaces 1 package had stderr output: mqtt_client_interfaces 1 package not processed" ,

I even tried to use this "sudo apt install ros-galactic-mqtt-client" but got this error

" [sudo] password for aexlab: Reading package lists... Done Building dependency tree
Reading state information... Done E: Unable to locate package ros-galactic-mqtt-client". i dont know why is this happening. I was able to clone the repositary but can not build it.

lreiher commented 9 months ago

Looks like you are trying to build for ROS 2 Foxy (although you are then trying to install it for ROS 2 Galactic?!). Either way, please have a look here: https://github.com/ika-rwth-aachen/mqtt_client/issues/27#issuecomment-1620651162

rehman257800 commented 9 months ago

I was able to download the mqtt client on ros humble. but now when i am trying to connect with mqtt broker im getting this error

"phr7rng@RNG-C-001N7:~/ros_ws$ roslaunch mqtt_client standalone.launch

Traceback (most recent call last): File "/usr/bin/roslaunch", line 34, in import roslaunch File "/usr/lib/python3/dist-packages/roslaunch/init.py", line 62, in from .scriptapi import ROSLaunch File "/usr/lib/python3/dist-packages/roslaunch/scriptapi.py", line 42, in import roslaunch.parent File "/usr/lib/python3/dist-packages/roslaunch/parent.py", line 54, in import roslaunch.server File "/usr/lib/python3/dist-packages/roslaunch/server.py", line 80, in from rosgraph_msgs.msg import Log ImportError: cannot import name 'Log' from 'rosgraph_msgs.msg' (/opt/ros/humble/local/lib/python3.10/dist-packages/rosgraph_msgs/msg/init.py)"

i also tried this command "phr7rng@RNG-C-001N7:~/ros_ws$ ros2 launch mqtt_client standalone.launch.ros2.xml

ros2: command not found"

lreiher commented 9 months ago

Something is not right with your ROS installation.

You said you installed it for ROS 2 Humble. But then you proceed to use "roslaunch", which is ROS 1. "ros2 launch" on the other hand, which is ROS 2, isn't installed at all.

Please consider wiping everything ROS-related and properly reinstalling ROS 2 Humble.

Please also note that alternatively you could also launch the mqtt_client in a Docker container, see README.