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

how to creating fake Pose

asked 2021-10-21 11:15:01 -0500

jjb1220 gravatar image

Hello, I am trying to pubuilsh a fake pose in code. I checked the message rules and put the desired value and executed it, but the following error occurs in the subscriber. May i know what mistake i made??

Error:   TF_NAN_INPUT: Ignoring transform for child_frame_id "map" from authority "unknown_publisher" because of a nan value in the transform (0.000000 0.000000 nan) (0.000000 0.000000 0.000000 1.000000)
         at line 244 in /tmp/binarydeb/ros-melodic-tf2-0.6.5/src/buffer_core.cpp


Below is the code I want to run

#include "ros/ros.h"
#include "geometry_msgs/PoseStamped.h"
#include "geometry_msgs/PoseWithCovarianceStamped.h"
#include <tf/transform_broadcaster.h>
#include <iostream>

static geometry_msgs::PoseStamped rpyPose_goal;

using namespace std;
class send_Pose{
public:
    // Initialize ROS publishers
    ros::Publisher start_pub;
    ros::Publisher goal_pub;

// Take Goal_pose as input and publish
void handle_goal_pose() {

  rpyPose.header.frame_id = "map";
  rpyPose.header.stamp = ros::Time::now();
  rpyPose.pose.pose.position.x = (float)16.9677391052;
  rpyPose.pose.pose.position.y = (float)6.06961250305;
  rpyPose.pose.pose.position.z = (float)0;
  rpyPose.pose.pose.orientation.x = (float)0;
  rpyPose.pose.pose.orientation.y = (float)0;
  rpyPose.pose.pose.orientation.z = (float)0.683183893935;
  rpyPose.pose.pose.orientation.w = (float)0.730246374224;
  start_pub.publish(rpyPose);
  ROS_INFO("SUCCESS!");
}

};

int main(int argc, char **argv) {
  ros::init(argc, argv, "rviz_click_to_2d");
  ros::NodeHandle node;
  send_Pose send_pose;

  send_pose.goal_pub = node.advertise<geometry_msgs::PoseStamped>("/move_base_simple/goal", 1);

  send_pose.handle_start_pose();
  send_pose.handle_goal_pose();

  ros::Rate loop_rate(10);

  while (ros::ok()) {
        ros::spinOnce();
        loop_rate.sleep();
  }
  return 0;
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-21 18:24:52 -0500

miura gravatar image

If It update

  rpyPose.pose.pose.orientation.w = (float)0.730246374224;
  start_pub.publish(rpyPose);
  ROS_INFO("SUCCESS!");

to

  rpyPose.pose.pose.orientation.w = (float)0.730246374224;
  goal_pub.publish(rpyPose);  // replace start_pub to goal_pub
  ROS_INFO("SUCCESS!");

, it appears to progress.

The goal_pub is set using advertise, but the start_pub is not yet set.

edit flag offensive delete link more

Comments

1

thank you. I made a mistake

jjb1220 gravatar image jjb1220  ( 2021-10-21 19:41:00 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-10-21 11:15:01 -0500

Seen: 149 times

Last updated: Oct 21 '21