ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Undefined reference to `GeographicLib::UTMUPS::Forward(...)

asked 2021-08-25 16:33:08 -0500

akuramshin gravatar image

updated 2021-08-25 18:40:36 -0500

I am running ROS melodic on Ubuntu 18.04. I installed robot_localization via: sudo apt-get install ros-melodic-robot-localization

I am trying to use the RobotLocalization::NavsatConversions::LLtoUTM function from the robot_localization function but I am getting the following error:

CMakeFiles/gps_waypoint_mapping.dir/src/gps_waypoint_mapping.cpp.o: In function RobotLocalization::NavsatConversions::LLtoUTM(double, double, double&, double&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, double&)':
gps_waypoint_mapping.cpp:(.text+0x64): undefined reference to GeographicLib::UTMUPS::Forward(double, double, int&, bool&, double&, double&, double&, double&, int, bool)'
gps_waypoint_mapping.cpp:(.text+0xa1): undefined reference to `GeographicLib::MGRS::Forward(int, bool, double, double, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'

The snippet of code from gps_waypoint_mapping.cpp that uses LLtoUTM is:

geometry_msgs::PointStamped latLongtoUTM(double lati_input, double longi_input)
{

    double utm_x = 0, utm_y = 0;
    geometry_msgs::PointStamped UTM_point_output;

    //convert lat/long to utm
    RobotLocalization::NavsatConversions::LLtoUTM(lati_input, longi_input, utm_y, utm_x, utm_zone);

    //Construct UTM_point and map_point geometry messages
    UTM_point_output.header.frame_id = "utm";
    UTM_point_output.header.stamp = ros::Time(0);
    UTM_point_output.point.x = utm_x;
    UTM_point_output.point.y = utm_y;
    UTM_point_output.point.z = 0;

    return UTM_point_output;
}

I am pretty sure that GeographicLib is one of the dependencies of robot_localization so it was installed alongside. I ran rosdep install --from-paths src --ignore-src -r -y aswell to make sure.

Here is my CMakeLists.txt, sorry I am new to ROS so I didnt really know what to include and what not to include:

cmake_minimum_required(VERSION 3.0.3)
project(outdoor_waypoint_nav)

set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)


find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  tf
 roslib
 roslaunch
)

catkin_package()
roslaunch_add_file_check(launch)

include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(gps_waypoint src/gps_waypoint.cpp)
#add_executable(gps_waypoint_continuous src/gps_waypoint_continuous.cpp)
add_executable(gps_waypoint_continuous1 src/gps_waypoint_continuous1.cpp)
add_executable(gps_waypoint_continuous2 src/gps_waypoint_continuous2.cpp)
add_executable(gps_waypoint_mapping src/gps_waypoint_mapping.cpp)
add_executable(collect_gps_waypoints src/collect_gps_waypoints.cpp)
add_executable(plot_gps_waypoints src/plot_gps_waypoints.cpp)
add_executable(calibrate_heading src/calibrate_heading.cpp)
add_executable(safety_node src/safety_node.cpp)
add_executable(switch_controllers src/switch_controllers.cpp)

target_link_libraries(gps_waypoint ${catkin_LIBRARIES})
# target_link_libraries(gps_waypoint_continuous        ${catkin_LIBRARIES})
target_link_libraries(gps_waypoint_continuous1     ${catkin_LIBRARIES})
target_link_libraries(gps_waypoint_continuous2 ${catkin_LIBRARIES})
target_link_libraries(gps_waypoint_mapping ${catkin_LIBRARIES})
target_link_libraries(collect_gps_waypoints ${catkin_LIBRARIES})
target_link_libraries(plot_gps_waypoints ${catkin_LIBRARIES})
target_link_libraries(calibrate_heading ${catkin_LIBRARIES})
target_link_libraries(safety_node ${catkin_LIBRARIES})
target_link_libraries(switch_controllers ${catkin_LIBRARIES})

install(DIRECTORY  launch
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
edit retag flag offensive close merge delete

Comments

Would be good to also include the snippet of your CMakeLists.txt that builds the chunk of code shown in the original post. This is likely a linking error caused by missing something in the CMakeLists.txt

jarvisschultz gravatar image jarvisschultz  ( 2021-08-25 17:44:59 -0500 )edit

You are using a function from robot_localiztion but you haven’t link against it in your CmakeLists.txt. Add robot_localization package to find_packages() function

Fetullah Atas gravatar image Fetullah Atas  ( 2021-08-26 01:32:45 -0500 )edit

Thanks for the reply! I just added robot_localization to my find_packages() but the same problem persists.

akuramshin gravatar image akuramshin  ( 2021-08-26 12:44:44 -0500 )edit

try download the old version of navsat_conversions.h from github and modify the include header in your gps cpp file to point to this .h file.

wkbot gravatar image wkbot  ( 2021-08-31 22:19:45 -0500 )edit
1

Hey, did it worked? I am facing this problem too . CMakeFiles/plot_gps_waypoints.dir/src/plot_gps_waypoints.cpp.o: In function RobotLocalization::NavsatConversions::LLtoUTM(double, double, double&, double&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, double&)': plot_gps_waypoints.cpp:(.text+0x64): undefined reference toGeographicLib::UTMUPS::Forward(double, double, int&, bool&, double&, double&, double&, double&, int, bool)' plot_gps_waypoints.cpp:(.text+0xa1): undefined reference to `GeographicLib::MGRS::Forward(int, bool, double, double, int, std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >&)' collect2: error: ld returned 1 exit status waypoint_nav/outdoor_waypoint_nav/CMakeFiles/plot_gps_waypoints.dir/build.make:122: recipe for target '/home/root1/workspace_test/devel/lib/outdoor_waypoint_nav/plot_gps_waypoints' failed make[2]: * [/home/root1/workspace_test/devel/lib/outdoor_waypoint_nav/plot_gps_waypoints] Er

troyelex gravatar image troyelex  ( 2021-09-15 05:37:16 -0500 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2021-10-07 02:43:23 -0500

industriumph_engineer gravatar image

You can try clone git repository "robot_localization" at: https://github.com/cra-ros-pkg/robot_... into " /catkin_ws/src/ ". Then catkin_make. It works for me.

edit flag offensive delete link more

Comments

This worked for me too. Thanks for sharing.

RRK gravatar image RRK  ( 2022-02-01 07:29:01 -0500 )edit
2

answered 2022-05-20 16:53:01 -0500

Debanik Roy gravatar image

updated 2022-05-20 17:24:25 -0500

jayess gravatar image

Add robot_localization into CmakeList.txt and package.xml In CmakeList.txt --->

find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
tf
roslib
roslaunch
robot_localization
)

In package.xml -->

<build_depend>robot_localization</build_depend>
edit flag offensive delete link more

Comments

Worked for me on noetic

amjack gravatar image amjack  ( 2022-10-11 09:35:22 -0500 )edit

This worked for melodic.

Many thanks! Saved my day!

pauloliver gravatar image pauloliver  ( 2022-10-14 05:26:29 -0500 )edit
0

answered 2021-09-16 05:53:09 -0500

PabloV gravatar image

Hi,

I was able to fix these errors by adding the dependency to the package.xml file too. As follow:

<?xml version="1.0"?>
<package>
<name>outdoor_waypoint_nav</name>
<version>0.0.0</version>
<description>The outdoor_waypoint_nav package</description>

<maintainer email="nicholas.c.charron@gmail.com">Nick</maintainer>

<license>BSD</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>roslaunch</build_depend>
<build_depend>robot_localization</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>hector_mapping_nav</run_depend>
<run_depend>husky_control</run_depend>
<run_depend>husky_customization</run_depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
  <!-- Other tools can request additional information be placed here -->

</export>
</package>
edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-08-25 16:33:08 -0500

Seen: 1,583 times

Last updated: May 20 '22