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

Problems with geometry_msgs::PoseStamped

asked 2015-04-10 08:30:52 -0500

JanOr gravatar image

Hi, I am try to write a tool that uses geometry_msgs::PoseStamped. Unfortunately I always get the error

src/systemplatform.cpp.o: In function `feedbackLoop(geometry_msgs::PoseStamped_<std::allocator<void> > const&)':  .../systemplatform.cpp:44: undefined reference to `Tool::getPose(geometry_msgs::PoseStamped_<std::allocator<void> >, double*)' 
collect2: error: ld returned 1 exit status

The error appears in Source File: systemplatform.c with the call of tool.getPose(msgPose, posetypeRNum); I don't find the error, but can imagine that is related to the use or call of msgPose which should be geometry_msgs::PoseStamped rosTopicMsg; It would be really nice if you could help me. I have added the code as following:

Thanks a lot in Advance!!!

//=============================================================================

//Header File: systemplatform.c

/* Required Headers */
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include "std_msgs/String.h"
#include "std_msgs/Empty.h"
#include "std_srvs/Empty.h"
#include <cstdlib>
#include <string>
#include <iostream>
#include <curses.h>
#include "tf/tf.h"
#include "tf/transform_broadcaster.h"
#include "geometry_msgs/PoseStamped.h"
#include "tool.h"

//=============================================================================

//Source File: systemplatform.c

#include "systemplatform.h"

/*Tool-class-pointers*/
Tool toolPtr;

/*Subscriber initialization*/
ros::Subscriber toolSubscriber;


void feedbackLoop(const geometry_msgs::PoseStamped& msgPose)
{
    typeRNum posetypeRNum [5]={0,0,0,0,0};
    tool.getPose(msgPose, posetypeRNum);
}

int main(int argc, char **argv)
{

    ros::init(argc, argv, "tool");
    ros::NodeHandle ntool;  //For receiving OptitrackData

    toolSubscriber = ntool.subscribe("tooltopic", 10, feedbackLoop);
    ros::spin();

    return 0;
}

//=============================================================================

//Header File: tool.h

/* Required Headers */
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include "tf/tf.h"
#include "tf/transform_broadcaster.h"
#include "geometry_msgs/PoseStamped.h"

class Tool
{
  public:

  void getPose(geometry_msgs::PoseStamped rosTopicMsg, double* posetypeRNum);
};
#endif

//=============================================================================

//Source File: tool.cpp

#include "tool.h"
void Toll::getPose(geometry_msgs::PoseStamped rosTopicMsg, double* array)
{
...
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-11 07:42:05 -0500

timm gravatar image

The linker error message is pretty clear: It tells that the function which you are calling in feedbackLoop(), Tool::getPose(...), is declared in a header file, but its implementation is not defined.

In tool.cpp you have a typo: It says Toll::getPose instead of Tool::getPose. I wonder why you are getting a linker error, though, as this should already cause an error during compilation because a Tollclass it not declared anywhere. In your CMakeLists.txt, did you forget to add tool.cpp as a source file in the add_executable() / add_library() call?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-10 08:30:52 -0500

Seen: 6,523 times

Last updated: Apr 11 '15