1先建立工作空间~/catkin_ws参阅/note/516843231/3在工程目录下建一个src子目录和.py
文件源代码文件:topic_publisher.py~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#!/usr/bin/envpythonimportroslibroslib.load_manifest('basic')importrospyfromstd_msgs.msgimportInt32rospy.init_node('topic_publisher')pub=rospy.Publisher('counter',Int32)rate=rospy.Rate(2)count=0whilenotrospy.is_shutdown():pub.publish(count)count+=1rate.sleep()~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *** 作步骤如下liao@liao-eagle:~/catkin_ws$lsbuilddevelinstallsrcliao@liao-eagle:~/catkin_ws$cdsrcliao@liao-eagle:~/catkin_ws/src$lsbasicbeginner_tutorialsCMakeLists.txtfirstsecondliao@liao-eagle:~/catkin_ws/src$cdbasic/liao@liao-eagle:~/catkin_ws/src/basic$lsCMakeLists.txtpackage.xmlsrcliao@liao-eagle:~/catkin_ws/src/basic$cdsrcliao@liao-eagle:~/catkin_ws/src/basic/src$vitopic_publisher.pyliao@liao-eagle:~/catkin_ws/src/basic/src$chmod+xtopic_publisher.py4回到~/catkin_ws目录下,
编译程序$cd~/catkin_wsliao@liao-eagle:~/catkin_ws$catkin_make5将当前工程加入到shell环境里去liao@liao-eagle:~/catkin_ws$echo"source~/catkin_ws/devel/setup.bash">>~/.bashrcliao@liao-eagle:~/catkin_ws$source~/.bashrc6运行程序(需开两个终端)liao@liao-eagle:~/catkin_ws$roscoreliao@liao-eagle:~/catkin_ws$rosrunbasictopic_publisher.py7通过rostopic查看相关信息liao@liao-eagle:~/catkin_ws$rostopiclist/counter/rosout/rosout_agg问题能不能详细点?
首先要有C++面向对象的基础,要会使用类
然后最起码要知道ros节点、主题、服务器、客户端这些东西吧
接下来就开始上ros wiki看navigation、tf、actionlib等等这些了
看的过程中跟着写一写,熟练就好
还有就是要多看看ros wiki里的API
评论列表(0条)