I can't create a subscriber for ar_track_alvar.
I would like to use the code below to subscribe to the position of the AR marker obtained by ” ar_track_alvar” . However, I am getting the error shown below.
Can you please tell me why I am getting the error? Also, please let me know the correct code.
The development environment is Ubuntu kinetic.
[code]
#include <ros/ros.h>
#include <ar_track_alvar_msgs/AlvarMarkers.h>
#include <iostream>
using namespace std;
void poseCallback(const ar_track_alvar_msgs::AlvarMarkers& pos){
ROS_INFO("position (x,y,z) = (%f : %f : %f) \n", pos->position.x, pos->position.y, pos->position.z);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "basic_simple_listener");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe<ar_track_alvar_msgs::AlvarMarkers>("ar_pose_marker", 100, poseCallback);
ros::spin();
return 0;
}
Here is the error
error: ‘const AlvarMarkers {aka const struct ar_track_alvar_msgs::AlvarMarkers_<std::allocator<void> >}’ has no member named ‘position’
ROS_INFO("position (x,y,z) = (%f : %f : %f) \n", pos.position.x, pos->position.
Can you please share your ar_track_alvar_msgs/AlvarMarkers.h msg file.