ROS源码阅读日记——nav_test.py


#这段代码的作用是实现在地图中随机导航。在ros下需要先加载机器人和相关配置,详请参阅 古-月 的博客http://blog.csdn.net/hcx25909/article/details/12110959
#这里主要是用于自己来理解这段代码

#!/usr/bin/env python

import rospy
import actionlib
from actionlib_msgs.msg import *
from geometry_msgs.msg import Pose, PoseWithCovarianceStamped, Point, Quaternion, Twist
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
from random import sample
from math import pow, sqrt

class NavTest():
    def __init__(self):
        rospy.init_node('nav_test', anonymous=True)
        
        rospy.on_shutdown(self.shutdown)#rospyAPI:on_shutdown()
        
        # How long in seconds should the robot pause at each location?
        #在每个目标点停留的时间
        self.rest_time = rospy.get_param("~rest_time", 10)#API get_param
        
        # Are we running in the fake simulator?
        #是否是在模拟环境中运行
        self.fake_test = rospy.get_param("~fake_test", False)
        
        # Goal state return values
        #目标状态返回值
        goal_states = ['PENDING', 'ACTIVE', 'PREEMPTED', 
                       'SUCCEEDED', 'ABORTED', 'REJECTED',
                       'PREEMPTING', 'RECALLING', 'RECALLED',
                       'LOST']
        
        # Set up the goal locations. Poses are defined in the map frame.  
        #设置目标位置,在地图坐标系中的姿态
        # An easy way to find the pose coordinates is to point-and-click
        #找到某一姿态的坐标,选中然后单击
        # Nav Goals in RViz when running in the simulator.
        #
        # Pose coordinates are then displayed in the terminal
        # that was used to launch RViz.
        locations = dict()
        #这里定义了六个定位点的姿态
        locations['hall_foyer'] = Pose(Point(0.643, 4.720, 0.000), Quaternion(0.000, 0.000, 0.223, 0.975))
        locations['hall_kitchen'] 
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值