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

hudaming's profile - activity

2022-12-16 21:49:42 -0500 received badge  Student (source)
2022-08-29 11:00:06 -0500 marked best answer How to subscribe the topic only once

I have a problem about how to sucscribe the topic only once,In some time, I only hope to get the first data from the topic, rather than change the publisher. So how should I do? This is my code:

#include  <ros/ros.h>
#include <sensor_msgs/NavSatFix.h>
#include <geometry_msgs/PointStamped.h>
static geometry_msgs::PointStamped point;

void imageCallback(const sensor_msgs::NavSatFix::ConstPtr &msg)
{
  point.point.x=msg->latitude;
  point.point.y=msg->longitude;
  point.point.z=msg->altitude;
}



int main(int argc, char **argv)
{
  ros::init(argc, argv, "test");
  ros::NodeHandle nh;
  ros::Subscriber positions_sub = nh.subscribe("/POSITIONS", 3, &imageCallback);
  ros::spin();
}

In this code, I can get many points, but I only hope to get the first point. What should I change in tthe code ? THANKS!

2018-04-14 18:51:31 -0500 received badge  Popular Question (source)
2018-04-14 03:01:28 -0500 asked a question symbol lookup error

symbol lookup error Sorry to bother you. When I use this code using :rosrun feature_extraction feature_extraction_node,

2018-04-13 05:29:21 -0500 received badge  Enthusiast
2018-04-12 02:00:48 -0500 received badge  Famous Question (source)
2017-09-06 10:47:00 -0500 received badge  Famous Question (source)
2017-09-06 08:25:24 -0500 commented answer How to subscribe the topic only once

Sorry, I can not get the solution. Can you give me an example? My hope is to loop the imageCallback only once. Thanks!

2017-09-06 06:45:36 -0500 received badge  Notable Question (source)
2017-09-06 06:10:57 -0500 received badge  Popular Question (source)
2017-09-06 04:16:42 -0500 edited question How to subscribe the topic only once

How to subscirbe the topic only once I have a problem about how to sucscribe the topic only once,In some time, I only ho

2017-09-06 04:16:06 -0500 edited question How to subscribe the topic only once

How to subscirbe the topic only once I have a problem about how to sucscribe the topic only once,In some time, I only ho

2017-09-06 04:16:06 -0500 received badge  Editor (source)
2017-09-06 04:15:23 -0500 asked a question How to subscribe the topic only once

How to subscirbe the topic only once I have a problem about how to sucscribe the topic only once,In some time, I only ho

2017-09-05 05:06:46 -0500 received badge  Famous Question (source)
2017-07-16 00:28:02 -0500 received badge  Notable Question (source)
2017-07-04 01:47:21 -0500 received badge  Popular Question (source)
2017-07-03 07:40:08 -0500 edited question How to subscribe many topic in one code and save data in one txt file

How to subscribe many topic in one code and save data in one txt file I hope to subscribe many topics in one code, and I

2017-07-03 07:39:12 -0500 asked a question How to subscribe many topic in one code and save data in one txt file

How to subscribe many topic in one code and save data in one txt file I hope to subscribe many topics in one code, and I

2017-07-01 21:54:50 -0500 marked best answer The question about ros::publisher and ros::subscriber

I want to achieve receiving and transform data using rostopic at the same time or in a low time. I know that ros::subscriber can subscribe rostopic and receive the data included in topic. So I hope to process the data in one topic and send the processing-data to another topic, and others can subscribe the new topic. Such as the code:

void receiveGPS(const sensor_msgs::NavSatFix::ConstPtr &msg)
{

  gps_common::GPSFix gps;

  gps.header.stamp=msg->header.stamp;

  gps.status.status=msg->status.status;

  gps.latitude=msg->latitude;

  gps.longitude=msg->longitude;

  gps.altitude=msg->altitude;

  gps.position_covariance[0]=msg->position_covariance[0];
  gps.position_covariance[4]=msg->position_covariance[4];
  gps.position_covariance[8]=msg->position_covariance[8];
}

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

// Set up ROS.

  ros::init(argc, argv, "receiveGPS");

  ros::NodeHandle n;

  ros::Subscriber sub = n.subscribe("gps", 2,&receiveGPS);

  ros::spin();

}

I can get gps.latitude from the topic "gps",and I hope to send gps.latitude to another topic and publish it. Could you tell me what should I do next? Thanks!

2017-07-01 21:54:50 -0500 received badge  Scholar (source)
2017-07-01 02:51:22 -0500 received badge  Supporter (source)
2017-06-28 05:12:27 -0500 commented answer The question about ros::publisher and ros::subscriber

OK! You are right, I will try it soon. This is my first time using Q&A, this is a good start for me! Thank you!

2017-06-28 05:09:24 -0500 commented question The question about ros::publisher and ros::subscriber

I hope to subscribe the topic and deal with the data in it firstly, and the send the processed data to another topic tha

2017-06-28 04:34:01 -0500 received badge  Notable Question (source)
2017-06-27 16:53:18 -0500 received badge  Popular Question (source)
2017-06-27 08:15:30 -0500 asked a question The question about rostopic ros::publish ros::subscribe

The question about rostopic ros::publish ros::subscribe I want to achieve receiving and transform data using rostopic a

2017-06-27 08:15:29 -0500 asked a question The question about ros::publisher and ros::subscriber

The question about ros::publisher and ros::subscriber I want to achieve receiving and transform data using rostopic at