Can't find package: cartographer_ros
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
The formatting was broken because you were formatting things as quotes rather than as pre-formatted text.
It may seem obvious, but have you installed
cartographer
? It is not installed by default. You need to install the packageros-melodic-cartographer-ros
.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.
Found the packages: /opt/ros/melodic/share but cartographer_ros isn't there, even though I've "installed" it. Another mystery...