ROS与AR.Drone-ROS命令
ROS命令
分别发送信息 std_msgs/Empty 到对应主题ardrone/takeoff, ardrone/land 和 ardrone/reset,可实现起飞,降落,重置。
例如起飞:
rostopic pub ardrone/takeoff std_msgs/Empty
- 起飞后,发送geometry_msgs::Twist消息到cmd_vel主题实现飞行,组件值:
-linear.x: move backward
+linear.x: move forward
-linear.y: move right
+linear.y: move left
-linear.z: move down
+linear.z: move up
-angular.z: turn right
+angular.z: turn left
- 例如转圈飞行:
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}'
- 解释:
“-r 10” 表示以10HZ的频率发布这条消息,
“/cmd_vel”为消息的Topic,”geometry_msgs/Twist” 为消息类型,
‘{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}’表示指定的线速度和角速度
- 组件值范围在-1.0 到 1.0之间,最大值可以通过参数配置
悬停模式
- geometry_msgs::Twist有两个angular.x 和angular.y,可以用来开启或关闭自动悬停模式。
- 当6个组件设置为0时候,进入自动悬停模式,如果你不想进入自动悬停模式,设置前4个组件为0,其他2个为任意的非0值。
常用命令
- 起飞:
rostopic pub -1 /ardrone/takeoff std_msgs/Empty
- 降落:
rostopic pub -1 /ardrone/land std_msgs/Empty
- 切换相机
rosservice call /ardrone/togglecam
- 行为:
# fly forward
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# fly backward
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: -1.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# fly to left
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 1.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# fly to right
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: -1.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# fly up
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 1.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# fly down
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: -1.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# counterclockwise rotation
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 1.0}}'
# clockwise rotation
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: -1.0}}'
# stop
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
观察飞行
# The output camera
rosrun image_view image_view image:=/ardrone/image_raw
# The front camera
rosrun image_view image_view image:=/ardrone/front/image_raw
# The buttom camera
rosrun image_view image_view image:=/ardrone/bottom/image_raw
# The height sensor
rostopic echo /sonar_height
#The navigation info
rostopic echo /ardrone/navdata
#A launch file for joystick drivers and image view nodes
roslaunch cvg_sim_test demo_tool.launch
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号