Ask Your Question
0

How to create a geometry_msgs::Point?

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

Elric gravatar image

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

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
3

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

pavel92 gravatar image

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

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:

<depend>geometry_msgs</depend>

In CMakeLists.txt add:

find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
)

catkin_package(
  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

2 followers

Stats

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

Seen: 121 times

Last updated: Jul 02