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!
Originally posted by hudaming on ROS Answers with karma: 13 on 2017-06-27
Post score: 0
Original comments
Comment by allenh1 on 2017-06-27:
Are you talking about a node that's simultaneously a subscriber and a publisher?
Comment by hudaming on 2017-06-28:
I hope to subscribe the topic and deal with the data in it firstly, and the send the processed data to another topic that can be subscribed.