Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I wantna publish a initialpose to AMCL, but error~

I try to write a node for publish a msg to initialpose topic, but error

Error:   TF_NAN_INPUT: Ignoring transform for child_frame_id "odom" from authority "unknown_publisher" because of a nan value in the transform (-nan -nan -nan) (-nan -nan -nan -nan)
         at line 244 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
Error:   TF_DENORMALIZED_QUATERNION: Ignoring transform for child_frame_id "odom" from authority "unknown_publisher" because of an invalid quaternion in the transform (-nan -nan -nan -nan)
         at line 257 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp

my code:

#include <ros/ros.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>

int main (int argc, char** argv) 
{
    ros::init(argc, argv, "initialpose_pub");
    ros::NodeHandle nh_;
    ros::Publisher initPosePub_ = nh_.advertise<geometry_msgs::PoseWithCovarianceStamped>("initialpose", 2, true);
ros::Rate rate(1.0);
while(nh_.ok()) 
{
    //get time
    ros::Time scanTime_ = ros::Time::now();     
    //create msg
    geometry_msgs::PoseWithCovarianceStamped initPose_;
    //create the time & frame
    initPose_.header.stamp = scanTime_;
    initPose_.header.frame_id = "map";
    //position
    initPose_.pose.pose.position.x = 0.f;
    initPose_.pose.pose.position.y = 0.f;
    //angle
    initPose_.pose.pose.orientation.z = 0.f;
    //publish msg
    initPosePub_.publish(initPose_);
    //sleep
    rate.sleep();
}
return 0;
}

I don't know why.