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

error in ros1_msg.id = ros2_msg.id from Visiong messages in ObjectHypothesis when Building #440

Open
AlejandroGarcia03 opened this issue Oct 14, 2024 · 1 comment

Comments

@AlejandroGarcia03
Copy link

Bug report

error in ros1_msg.id = ros2_msg.id from Visiong messages in ObjectHypothesis when trying to build the workspace.

Hey, I hope the reader is doing well, I've found myself in a problem trying to build the ros1-bridge package with ros-noeitc and ros-foxy, I could do it normally before without any trouble and I was actually even able to use it, however after some time without using it it won't build anymore. I followed the steps in the github documentation to clone it and build it once again, even with the foxy branch being cloned and get no positive results.

Required Info:

  • Operating System:
    Ubuntu 20.04

  • Installation type:

    • source installed
  • Version or commit hash:
    git rev-parse HEAD = 689a932

  • DDS implementation:

/opt/ros/foxy/bin/ros2:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
/opt/ros/foxy/lib/python3.8/site-packages/ros2doctor/api/platform.py: 82: UserWarning: Distribution foxy is no longer supported or deprecated. To get the latest features, download the new versions at https://index.ros.org/doc/ros2/Installation/

  • Client library (if applicable):
    N/A

Steps to reproduce issue

mkdir -p ros_bridge_ws/src
cd ros_bridge_ws/src
git clone -b foxy https://github.com/ros2/ros1_bridge.git
cd ..
export ROS1_INSTALL_PATH=/opt/ros/noetic
export ROS2_INSTALL_PATH=/opt/ros/foxy
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash

colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure

Expected behavior

Colcon build completed succesfully

Actual behavior

/home/alejandro/2_exchange/ros1_bridge/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesis__factories.cpp: In static member function ‘static void ros1_bridge::Factory<ROS1_T, ROS2_T>::convert_2_to_1(const ROS2_T&, ROS1_T&) [with ROS1_T = vision_msgs::ObjectHypothesis_<std::allocator<void> >; ROS2_T = vision_msgs::msg::ObjectHypothesis_<std::allocator<void> >]’:
/home/alejandro/2_exchange/ros1_bridge/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesis__factories.cpp:79:26: error: cannot convert ‘const _id_type’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘vision_msgs::ObjectHypothesis_<std::allocator<void> >::_id_type’ {aka ‘long int’} in assignment
   79 |   ros1_msg.id = ros2_msg.id;
      |                 ~~~~~~~~~^~
      |                          |
      |                          const _id_type {aka const std::__cxx11::basic_string<char>}
/home/alejandro/2_exchange/ros1_bridge/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesisWithPose__factories.cpp: In static member function ‘static void ros1_bridge::Factory<ROS1_T, ROS2_T>::convert_2_to_1(const ROS2_T&, ROS1_T&) [with ROS1_T = vision_msgs::ObjectHypothesisWithPose_<std::allocator<void> >; ROS2_T = vision_msgs::msg::ObjectHypothesisWithPose_<std::allocator<void> >]’:
/home/alejandro/2_exchange/ros1_bridge/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesisWithPose__factories.cpp:87:26: error: cannot convert ‘const _id_type’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘vision_msgs::ObjectHypothesisWithPose_<std::allocator<void> >::_id_type’ {aka ‘long int’} in assignment
   87 |   ros1_msg.id = ros2_msg.id;
      |                 ~~~~~~~~~^~
      |                          |
      |                          const _id_type {aka const std::__cxx11::basic_string<char>}
make[2]: *** [CMakeFiles/ros1_bridge.dir/build.make:4321: CMakeFiles/ros1_bridge.dir/generated/vision_msgs__msg__ObjectHypothesis__factories.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/ros1_bridge.dir/build.make:4334: CMakeFiles/ros1_bridge.dir/generated/vision_msgs__msg__ObjectHypothesisWithPose__factories.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:260: CMakeFiles/ros1_bridge.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< ros1_bridge [2min 1s, exited with code 2]

Additional information

I looked up the type of messages for each id, I understand ros1_msg.id is int64 and ros_msg.id is a string, maybe the problem could be related to that, I don't know if this has been like this forever or if it was recently updated, but basically that is the error. Also the building stop after 2 minutes or something, just when it is about to end like at 96%
I believe it could really be a problem in an update of the vision messages because I was able to use ros1_bridge before and not anymore.
Screenshot from 2024-10-14 12-11-10

@AlejandroGarcia03
Copy link
Author

Issue fixed

Hey, just wanted to do an update on this, you have to have already tried to build this package to actually fix this mistake. Once you've tried to build the workspace you have look for the 2 files containing this mistake, mine is ros_bridge_ws and here is an example of the paths for the 2 files that must be fixed:

file1=/ros_bridge_ws/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesisWithPose__factories.cpp
file2=/ros_bridge_ws/build/ros1_bridge/generated/vision_msgs__msg__ObjectHypothesis__factories.cpp

Including Libraries

Make sure to have included the string library into both files first by doing:

#include <string>

File 1

Somewhere around the lines 60 and 87 you should find the commands that look like this:

ros2_msg.id = ros1_msg.id;
ros1_msg.id = ros2_msg.id;

The issue here is that the ros1_msg.id is a long int and the ros2_msg is a string, so it will be as easy as doing the respective conversions to it's type of variable.

ros2_msg.id = std::to_string(ros1_msg.id);
ros1_msg.id = std::stol(ros2_msg.id);

File 2

Similar to file 1 some where around the lines 60 and 79 you should find the commands that look like this:

ros2_msg.id = ros1_msg.id;
ros1_msg.id = ros2_msg.id;

Repeat the same for these solution by replacing for the following lines of code:

ros2_msg.id = std::to_string(ros1_msg.id);
ros1_msg.id = std::stol(ros2_msg.id);

Conclusion

I think this problem still needs a solution since you have to have tried building the workspace before fixing it, so in the source code there should be some files that need some modifications to have this corrected and build the workspace correctly each time. If you have got the same issue as me, I hope this helped, feel free to reply the issue, I'll do my best at helping you too.

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