how to receive message use rosserial_window?

asked 2019-10-24 02:29:54 -0600

victor_12 gravatar image

updated 2019-10-24 03:21:44 -0600

gvdhoorn gravatar image

I user rosserial_window. I success receive topic /turtle1/cmd_vel.

but I want to receive nav_msgs::Path from loam package.

this is my window code.

void odom_callback(const nav_msgs::Path& msg) {

printf("Received pose x: %f, y: %f, z: %f \n", msg.st_poses.pose.position.x, msg.st_poses.pose.position.y, msg.st_poses.pose.position.z);

printf("Received orientation x: %f, y: %f, z: %f, w: %f \n", msg.st_poses.pose.orientation.x,msg.st_poses.pose.orientation.y, msg.st_poses.pose.orientation.z,msg.st_poses.pose.orientation.w); 

}

int _tmain(int argc, _TCHAR * argv[])
{   
    ros::NodeHandle nh;
    char *ros_master = "192.168.1.77";

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode(ros_master);

    ros::Subscriber<nav_msgs::Path> odom_Sub("odometry_sub", &odom_callback);
    nh.subscribe(odom_Sub);

    printf("Waiting to receive messages\n");
    while (1)
    {
        nh.spinOnce();
        //Sleep(100);
    }

    printf("All done!\n");
    return 0;
}

I think ubuntu ros and window connect are successful. because print message "Waiting to receive messages". tell me how to recive nav_msgs::Path topic.

edit retag flag offensive close merge delete