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

brucewang's profile - activity

2018-08-08 01:29:54 -0500 marked best answer how to have subs and publisher in one single cpp

i see some posts about writting the subs and publi in on cpp, but for my code, I will subs some points position from the camera and publish it with 10*those coordinate how do i do that ? (Say my ps4->pose.position.x is 10, i want to have a topic called "positions" which will publish this coordinate to be 100)please help

#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 std;
using namespace cv;
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_vidoe2;
    ros::init(argc, argv, "coordinator");

    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe<geometry_msgs::PoseStamped>("/visp_auto_tracker/object_position", 1000, imageCallback);
    ros::Publisher positions_pub = n.advertise<geometry_msgs::PoseStamped>("positions", 1000);



ros::Rate loop_rate(30);
        int count=0;
    while (ros::ok())
    {
            double x;



    geometry_msgs::PoseStamped msg;



ros::spinOnce();

        loop_rate.sleep();
        ++count;
        }

i know this is a partial code, please help~~ i am new to ros, please explain in details, thanks ~

2017-06-28 05:12:42 -0500 received badge  Famous Question (source)
2017-06-12 08:43:08 -0500 received badge  Notable Question (source)
2017-06-03 07:35:34 -0500 received badge  Popular Question (source)
2017-06-02 20:01:29 -0500 asked a question how to pulish something from the substriber?

how to pulish something from the substriber? I would like to have the publisher and substriber in one single cpp file. T

2017-06-02 20:01:29 -0500 asked a question how to have subs and publisher in one single cpp

how to have subs and publisher in one single cpp i see some posts about writting the subs and publi in on cpp, but for m