Ask Your Question

How to create a geometry_msgs::Point?

asked 2019-07-02 05:19:59 -0600

Elric gravatar image

updated 2019-07-02 21:53:24 -0600

jayess gravatar image

I'm using ROS melodic.

I'm trying this C++ code:

#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include "geometry_msgs/Quaternion.h"
#include "tf/transform_datatypes.h"
#include "tf/LinearMath/Matrix3x3.h"
#include "nav_msgs/Odometry.h"

#include <sstream>
#include <cmath>
#include <cstdlib>
#include <queue>

// ... More code

geometry_msgs::Point p;

But I get the following error message:

no instance of constructor "geometry_msgs::Point_::Point_ [with ContainerAllocator=std::allocator]" matches the argument list -- argument types are: (double, double)

What am I doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-02 07:09:03 -0600

pavel92 gravatar image

updated 2019-07-02 07:11:56 -0600

You will need to include the geometry_msgs/Point message, which resides in the geometry_msgs package. This is a header generated automatically from the Point.msg file in that package.

#include "geometry_msgs/Point.h"

Also dont forget to add the geometry_msgs in your package.xml and CMakeLists.txt
In package.xml add:


In CMakeLists.txt add:

find_package(catkin REQUIRED COMPONENTS

  CATKIN_DEPENDS geometry_msgs
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-07-02 05:19:59 -0600

Seen: 1,696 times

Last updated: Jul 02 '19