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

Own nav path has closed loop in rviz

asked 2019-02-18 04:32:25 -0500

Svyatoslav Mishin gravatar image

Hi, I want to make simple path following for differential drive robot,

So, I generated nav.msg/Path with own points and publish it, but in rviz I see my path with connection between start and end points, but I want see just my arc. my own publisher

When I use the code from Publisher about trajectory path to generate path from odom topic to path topic, I see not closed trajectory, that what I want to generate in my own path publisher. odom to path

What is my mistake?

How publish own points like nav.msg/Path correctly?

My source of publish node:

#!/usr/bin/env python
import rospy

from nav_msgs.msg import Path
from nav_msgs.msg import Odometry
from geometry_msgs.msg import PoseStamped
from geometry_msgs.msg import Pose

path = Path()
path.header.frame_id = 'odom'
seq = 0

def cartesian_to_path(x, y):
    global seq
    path.header.stamp = rospy.Time.now()

    for i, xi in enumerate(x):
        pose = PoseStamped()
        pose.header.stamp = rospy.Time.now()
        pose.header.frame_id = 'odom'
        pose.header.seq = seq
        pose.pose.position.x = xi
        pose.pose.position.y = y[i]
        pose.pose.position.z = 0
        path.poses.append(pose)
    seq += 1

    print(path)
    path_pub.publish(path)

rospy.init_node('path_node')
path_pub = rospy.Publisher('/path', Path, queue_size=10)
r = rospy.Rate(1)

if __name__ == '__main__':
    x = [ 3.86600947,  3.80181702,  3.72560205,  3.6376916 ,  3.53846288,
        3.42834168,  3.30780053,  3.17735667,  3.03756983,  2.88903983,
        2.73240402,  2.5683345 ,  2.3975353 ,  2.22073931,  2.03870516,
        1.85221396,  1.66206593,  1.46907699,  1.27407525,  1.07789747,
        0.88138542,  0.68538235,  0.4907293 ,  0.29826151,  0.10880487,
       -0.07682768, -0.25783959, -0.43345415, -0.60291779, -0.76550335]

    y = [3.88656062, 4.07229724, 4.25343267, 4.42918964, 4.598814  ,
       4.7615779 , 4.91678291, 5.06376305, 5.20188764, 5.33056399,
       5.44923995, 5.55740628, 5.65459886, 5.74040062, 5.81444339,
       5.87640946, 5.92603293, 5.96310087, 5.98745423, 5.99898849,
       5.99765418, 5.98345701, 5.95645791, 5.91677272, 5.86457174,
       5.80007895, 5.7235711 , 5.63537648, 5.53587353, 5.42548921]
    while not rospy.is_shutdown():
        cartesian_to_path(x,y)
        r.sleep()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-20 06:53:49 -0500

Svyatoslav Mishin gravatar image

It was mistake with declaration the object of class Path(), it was global, so, path object was not rewrited, path data was appending every cycle of Rate. correct source:

#...
from geometry_msgs.msg import Pose

def cartesian_to_path(x, y):
    path = Path()
    path.header.frame_id = 'odom'
    path.header.stamp = rospy.Time.now()
    #...
 #...
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-02-18 04:32:25 -0500

Seen: 569 times

Last updated: Feb 20 '19