TurtleBot运行的几条关键语句
roslaunch turtlebot_gazebo tuetlebot_world.launch
roslaunch turtlebot_teleop keyboard_teleop.launch
roslaunch turtlebot_rviz_launchers view_robot.launch
测试Kinect(仿真环境下不需要Kinnect,日后再补充)
http://learn.turtlebot.com/2015/02/01/8/
echo $TURTLEBOT_3D_SENSOR
如果输出不是kinect,则需要更改该变量
echo "export TURTLEBOT_3D_SENSOR=kinect" >> .bashrc
显示深度图和RGB图
rosrun image_view image_view image:=/camera/depth/image_raw
此处的:=意为覆盖赋值。其他的还有 ?=若左边变量未被赋值则赋值 +=在左边变量后面加上新字符串
简单例子 Draw a square
'''
Copyright (c) 2015, Mark Silliman
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
import rospy
from geometry_msgs.msg
import Twist
from math
import radians
class DrawASquare():
def __init__(self):
rospy.init_node(
'drawasquare', anonymous=
False)
rospy.on_shutdown(self.shutdown)
self.cmd_vel = rospy.Publisher(
'cmd_vel_mux/input/navi', Twist, queue_size=
10)
r = rospy.Rate(
5);
move_cmd = Twist()
move_cmd.linear.x =
0.2
turn_cmd = Twist()
turn_cmd.linear.x =
0
turn_cmd.angular.z = radians(
45);
count =
0
while not rospy.is_shutdown():
rospy.loginfo(
"Going Straight")
for x
in range(
0,
10):
self.cmd_vel.publish(move_cmd)
r.sleep()
rospy.loginfo(
"Turning")
for x
in range(
0,
10):
self.cmd_vel.publish(turn_cmd)
r.sleep()
count = count +
1
if(count ==
4):
count =
0
if(count ==
0):
rospy.loginfo(
"TurtleBot should be close to the original starting position (but it's probably way off)")
def shutdown(self):
rospy.loginfo(
"Stop Drawing Squares")
self.cmd_vel.publish(Twist())
rospy.sleep(
1)
if __name__ ==
'__main__':
try:
DrawASquare()
except:
rospy.loginfo(
"node terminated.")
仿真环境下可以实现较为精确的速度控制。此例程中需要注意的
r = rospy.Rate(
5);
r.sleep()
rospy.on_shutdown(self.shutdown)
创建地图
http://learn.turtlebot.com/2015/02/03/8/
roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch turtlebot_gazebo gmapping_demo.launch
roslaunch turtlebot_rviz_launchers view_navigation.launch
转载请注明原文地址: https://ju.6miu.com/read-1311850.html