[ros-users] [Discourse.ros.org] [General] How to access the instant ros callback value

Aankin Wang ros.discourse at gmail.com
Thu Jun 1 20:10:07 UTC 2017

So i am subscribing the position of a marker, but i would like to access its position at the instant i am using the function so that i can put the x y z coordinate into a vector. how should i do that ?

    #include "ros/ros.h"
    #include <math.h>
    #include <opencv/cv.h>
    #include <opencv/cvaux.h>
    #include <opencv/highgui.h>
    #include "geometry_msgs/PoseStamped.h"
    #include "geometry_msgs/Pose.h"
    #include "geometry_msgs/PoseWithCovariance.h"
    #include <visp/vpDisplayGDI.h>
    #include <visp/vpDisplayX.h>
    #include <visp/vpDot2.h>
    #include <visp/vpImageIo.h>
    #include <visp/vpPixelMeterConversion.h>
    #include <visp/vpPose.h>
    using namespace cv;
    using namespace std;
    void imageCallback(const geometry_msgs::PoseStamped::ConstPtr& ps4){
    cout<<"pose is"<<ps4->pose.position<<endl;
    int main(int argc,char** argv){
        geometry_msgs::PoseStamped my_vidoe;
        ros::init(argc, argv, "visp_auto_tracker_1");
        ros::NodeHandle n;
        ros::Subscriber sub = n.subscribe<geometry_msgs::PoseStamped>("/visp_auto_tracker/object_position", 1000, imageCallback);
        return 0;

[Visit Topic](https://discourse.ros.org/t/how-to-access-the-instant-ros-callback-value/1888/1) or reply to this email to respond.

More information about the ros-users mailing list