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

Can't find package: cartographer_ros

asked 2019-07-02 13:03:46 -0500

Alan8 gravatar image

updated 2019-07-03 15:09:53 -0500

gvdhoorn gravatar image

I'm trying to get a marker array containing pose info from cartographer_ros. I got the 2D cartographer_ros demo working, and the Subscribe demo working.

I'm now trying to modify the Subscribe demo to get pose messages from cartographer_ros, but the documentation for this is sparse so I'm experimenting.

The error I'm getting is not being able to "link" with cartographer_ros:

-- +++ processing catkin package: 'agitr'
-- ==> add_subdirectory(agitr)
-- Could NOT find cartographer_ros (missing: cartographer_ros_DIR)
-- Could not find the required component 'cartographer_ros'. The
following CMake error indicates that
you either need to install the package
with the same name or change your
environment so that it can be found.
CMake Error at
/opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83
(find_package):

Package.xml:

<?xml  version ="1.0"?> <package>
        <name>agitr</name>
        <version>0.0.1</version>
        <description>
                Examples from A Gentle Introduction to ROS
        </description> <maintainer  email="alan@h3dgamma.com">
        Alan </maintainer> <license>TO DO</license>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>geometry_msgs</build_depend>
<run_depend>geometry_msgs</run_depend>

<build_depend>roscpp</build_depend>
<run_depend>roscpp</run_depend>

<run_depend>cartographer_ros</run_depend>

find_package(catkin REQUIRED
COMPONENTS roscpp cartographer_ros)

</package>

subpose.cpp:

#include <ros/ros.h>
#include <cartographer_ros/Pose.h>
#include <iomanip>

// for std :: setprecision and std :: fixed
// A callback function.  Executed each time a new pose
// message arrives.

void poseMessageReceived ( const  cartographer_ros::Pose& msg)  {
         ROS_INFO_STREAM( std::setprecision(2) << std::fixed
                         << " position =(" <<  msg.x << ", " << msg.y << " ) "
                         << "direction=" << msg.theta ) ;
 }

int main (int argc, char **argv)  {
        // Initialize the ROS system and become a node.
        ros::init (argc, argv, "subscribe_to_pose");
        ros::NodeHandle nh;
        ROS_INFO_STREAM("We're in main.\n");

      // Create a subscriber object.
      ros::Subscriber sub = nh.subscribe("cartographer_ros/pose", 1000,
                            &poseMessageReceived);
            // Let ROS take over.
            ros::spin();
}

ROS Environment:

ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/home/alan/sub/src:/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=/home/alan/sub/devel/share/common-lisp
ROS_DISTRO=melodic

CMakeLists.txt:

# What version of CMake is needed?
cmake_minimum_required(VERSION 2.8.3)

# Name of this package.
project (agitr)

# Find the catkin build system, and any other packages on
# which we depend.
find_package(catkin REQUIRED COMPONENTS roscpp geometry_msgs cartographer_ros)

# Declare our catkin package.
catkin_package ()

# Specify locations of header files.
include_directories(include ${catkin_INCLUDE_DIRS})

# Declare the executable , along with i t s source f i l e s.  I f
# there are multiple executables, use multiple copies of
# this line.
add_executable (subpose subpose.cpp)

# Specify l i b r a r i e s against which to l i n k.  Again , t h i s
# l i n e should be copied f o r each d i s t i n c t executable in
# the package.
target_link_libraries(subpose ${catkin_LIBRARIES})

I'm using Ubuntu 18.04.2 LTS/melodic, gcc version 7.4.0.

(Sorry about the formatting; the XML angle brackets aren't coming through, and the font seems to be changing randomly.)

Thanks! Alan

edit retag flag offensive close merge delete

Comments

2

The formatting was broken because you were formatting things as quotes rather than as pre-formatted text.

Geoff gravatar image Geoff  ( 2019-07-02 18:48:43 -0500 )edit
3

It may seem obvious, but have you installed cartographer? It is not installed by default. You need to install the package ros-melodic-cartographer-ros.

Geoff gravatar image Geoff  ( 2019-07-02 20:14:20 -0500 )edit

Thanks for the comments Geoff. I assumed it was already installed since I can run the Cartographer 2D demo, but I reinstalled it and I'm getting the same results.

When I type "rospack depends1 cartographer_ros", I get "[rospack] Error: no such package cartographer_ros".

I go over the tutorials, but feel like pieces are missing. Can you tell me where packages are installed, and how they're located? Thanks.

Alan8 gravatar image Alan8  ( 2019-07-03 11:02:31 -0500 )edit

Found the packages: /opt/ros/melodic/share but cartographer_ros isn't there, even though I've "installed" it. Another mystery...

Alan8 gravatar image Alan8  ( 2019-07-03 11:43:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-07-03 12:08:06 -0500

Alan8 gravatar image

updated 2019-07-03 12:19:31 -0500

In case anyone else is wondering how to do an install:

sudo apt-get install ros-melodic-cartographer-ros

The environment variable ROS_PACKAGE_PATH is the list of directories to search for ROS packages.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-07-02 13:03:46 -0500

Seen: 2,358 times

Last updated: Jul 03 '19