python可以用来写导航吗_Turbot与python编程-实现多点导航

本文介绍了一个Python脚本,该脚本详细展示了如何利用actionlib库和move_base ROS节点,控制TurtleBot在给定的地图上实现多点导航。脚本中定义了多个目标点坐标,并在机器人到达每个点后会停留一段时间。此外,还提供了启动和配置相关ROS服务及脚本的步骤。
摘要由CSDN通过智能技术生成

Turbot与python教程-实现多点导航

说明:

介绍如何实现通过python控制turbot实现多点导航

代码:

实现代码:

#!/usr/bin/env python

# TurtleBot must have minimal.launch & amcl_demo.launch

# navMultiPoints.py

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)

# How long in seconds should the robot pause at each location?

self.rest_time = rospy.get_param("~rest_time", 10)

# 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'] = Pose(Point(-1.994, 4.382, 0.000), Quaternion(0.000, 0.000, -0.670, 0.743))

location

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值