zoukankan      html  css  js  c++  java
  • 如何接收RVIZ中的2D Pose Estimate 和2D Nav Goal

    #include "ros/ros.h"
    #include "std_msgs/String.h"
    #include <geometry_msgs/PoseWithCovarianceStamped.h>
    #include <iostream>
    #include <geometry_msgs/PointStamped.h>
    
    void chatterCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg)
    {
      double x=msg->pose.pose.position.y;
      double y=msg->pose.pose.position.x;
      //double theta=msg->pose.pose.orientation;
      std::cout<<x<<y<<std::endl;
    }
    
    void chatterCallback1(const geometry_msgs::PointStamped::ConstPtr& msg)
    {
      double x=msg->point.x;
      double y=msg->point.y;
      //double theta=msg->pose.pose.orientation;
      std::cout<<x<<y<<std::endl;
    }
    int main(int argc, char **argv)
    {
      ros::init(argc, argv, "sub2");
      ros::NodeHandle nh;
    
      ros::Subscriber sub = nh.subscribe("/initialpose", 1000, chatterCallback);
     // ros::Subscriber sub = nh.subscribe("/clicked_point", 1000, chatterCallback1);
    while(1)
    {
      ros::spinOnce();
    }
      std::cout<<"........................."<<std::endl;
    
      return 0;
    }
  • 相关阅读:
    第一课 进阶高手的大门
    Codeforces Round #363 (Div. 2) C. Vacations
    HDU 5718 Oracle
    A
    Fibonacci数的后9位
    UESTC 982质因子分解
    UESTC149 解救小Q
    UESTC93 King's Sanctuary
    HDU 4857 逃生
    L1-006. 连续因子
  • 原文地址:https://www.cnblogs.com/fuhang/p/12105561.html
Copyright © 2011-2022 走看看