资源简介
ROS Robotics By Example - Second Edition 第2版ROS学习书籍代码。
代码片段和文件信息
#!/usr/bin/env python
# Execute as a python script
# Set linear and angular values of TurtleBot‘s speed and turning
import rospy # Needed to create a ROS node
from geometry_msgs.msg import Twist # Message that moves base
class ControlTurtleBot():
def __init__(self):
# ControlTurtleBot is name of the node sent to ROS Master
rospy.init_node(‘ControlTurtleBot‘ anonymous=False)
# Message to screen
rospy.loginfo(“Press CTRL+c to stop TurtleBot“)
# Keys CNTL + c will stop script
rospy.on_shutdown(self.shutdown)
#Publisher will send Twist message on topic cmd_vel_mux/input/navi
self.cmd_vel = rospy.Publisher(‘cmd_vel_mux/input/navi‘ Twist queue_size=10)
# TurtleBot will receive message 10 times per second
rate = rospy.Rate(10)
# 10 Hz is fine as long as the processing does not exceed 1/10 second
# Twist is a type of geometry_msgs for linear and angular velocity
move_cmd = Twist()
# Linear speed in x in meters/second is + (forward) or - (backwards)
move_cmd.linear.x = 0.3 # Modify value to change speed
# Turn at 0 radians/s
move_cmd.angular.z = 0 # Modify value to cause rotation rad/s
# Loop and TurtleBot will move until you type CNTL+c
while not rospy.is_shutdown():
# publish the Twist values to TurtleBot node /cmd_vel_mux
self.cmd_vel.publish(move_cmd)
# wait for 0.1 seconds (10 HZ) and publish again
rate.sleep()
def shutdown(self):
# You can stop TurtleBot by publishing an empty Twist message
rospy.loginfo(“Stopping TurtleBot“)
self.cmd_vel.publish(Twist())
# Give TurtleBot time to stop
rospy.sleep(1)
if __name__ == ‘__main__‘:
try:
ControlTurtleBot()
except:
rospy.loginfo(“End of the trip for TurtleBot“)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\
文件 354 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\CMakeLists.txt
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\launch\
文件 725 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\launch\ddrobot_gazebo.launch
文件 778 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\launch\ddrobot_rviz.launch
文件 708 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\package.xm
文件 4551 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf.rviz
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\
文件 2993 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot.gazebo
文件 254 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot.urdf
文件 1083 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot2.urdf
文件 1265 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot3.urdf
文件 1466 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot4.urdf
文件 2273 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot5.urdf
文件 2955 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\urdf\dd_robot6.urdf
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\worlds\
文件 496 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter02\ros_robotics\worlds\ddrobot.world
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter03\
文件 1926 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter03\ControlTurtleBot.py
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter04\
文件 1563 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter04\MoveTBtoGoalPoints.py
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\
文件 354 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\CMakeLists.txt
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\config\
文件 873 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\config\rrbot_control.yaml
目录 0 2017-11-30 14:20 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\launch\
文件 876 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\launch\rrbot_control.launch
文件 887 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\launch\rrbot_gazebo.launch
文件 673 2017-11-13 16:34 ROSRoboticsbyExampleSecondEdition_Code\Chapter05\ros_robotics\launch\rrbot_rviz.launch
............此处省略65个文件信息
- 上一篇:odoo12开发手册
- 下一篇:高中教科版多媒体技术应用教材
评论
共有 条评论