[ros-users] [Discourse.ros.org] [General] How to access the …

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Aankin Wang via ros-users
Date:  
To: ros-users
Subject: [ros-users] [Discourse.ros.org] [General] How to access the instant ros callback value


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;
    //ps_cov->publish(ps);


    }




    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);


        ros::spin();
        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.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>