查看package的命令:
rospack list | grep turtlebot
如果提示没有这个package,那么可以进入到这个package的目录,然后source一下
source ~/catvehicle_ws/devel/setup.bash
roslaunch catvehicle catvehicle_skidpan.launch
roslaunch用法:
$ roslaunch [package] [filename.launch]
在gazebo中移动自动驾驶车车
1.#source catvehicle包,并roslaunch一下 该包中的 某个launch文件
2.gzclient#开启客户端
3.rosrun rviz rviz #用rviz可视化
4.#用一个keyboard teleop launch文件中的node实现键盘控制车车
其中4.的详细步骤:(这里用turtlebot_teleop包中的keyboard_teleop.launch控制键盘)
roslaunch turtlebot_teleop keyboard_teleop.launch # we can launch an existing TurtleBot teleop node using this command
rosrun topic_tools relay /cmd_vel_mux/input/teleop /catvehicle/cmd_vel # The TurtleBot teleop node is publishing Twist messages to topic'/cmd_vel_mux/input/teleop', and we need to convert them into topic '/catvehicle/cmd_vel'
rostopic:
rostopic list #查看所有topic
rostopic echo [topic] #可以把该topic上publish的消息echo出来
例如:
$ rostopic echo /turtle1/cmd_vel
关于rosnode:
rosrun [package] [node] #开启运行一个node
rosnode list #列出所有活着的node
rosnode kill [/node] #杀死指定node
rosnode通过topic进行通信:
rosrun [package] [/node1]
rosrun [package] [/node2]
若node1和node2通过topic进行通信,那么一定是一个/node*发布(publication)一个/topic,另一个/node*订阅(subscription)这个/topic
rosnode info [/node1] #查看/node1的infomation
rosnode info [/node2] #......
那么这两个node的info中,一个的发布(publication)一定是另一个的订阅(subscription)
rostopic type /topic #查看由/topic发送的消息的类型
上面命令执行后显示:geometry_msgs/Twist
rosmsg show geometry_msgs/Twist #显示消息的字段
那么我们就能用命令直接发布topic了
rostopic pub [/topic] [topic-type] [满足消息字段的data]