0
$\begingroup$

Rosanswers logo

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}
)

Originally posted by akuramshin on ROS Answers with karma: 11 on 2021-08-25

Post score: 1


Original comments

Comment by jarvisschultz on 2021-08-25:
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

Comment by Fetullah Atas on 2021-08-26:
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

Comment by akuramshin on 2021-08-26:
Thanks for the reply! I just added robot_localization to my find_packages() but the same problem persists.

Comment by wkbot on 2021-08-31:
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.

Comment by troyelex on 2021-09-15:
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 to GeographicLib::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, std::allocator >&)' 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

$\endgroup$

2 Answers 2

1
$\begingroup$

Rosanswers logo

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


Originally posted by industriumph_engineer with karma: 21 on 2021-10-07

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by RRK on 2022-02-01:
This worked for me too. Thanks for sharing.

$\endgroup$
1
$\begingroup$

Rosanswers logo

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>

Originally posted by Debanik Roy with karma: 31 on 2022-05-20

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by amjack on 2022-10-11:
Worked for me on noetic

Comment by pauloliver on 2022-10-14:
This worked for melodic.

Many thanks! Saved my day!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.