ROS控制M100笔记(一、消息的发布与服务的请求的查表方法)

基于ros的通信能够有效帮助UAV之间不同板块的信息发布与获取。其主要有两部分:消息的订阅与发布(subscribe&publisher)还有服务和客户端(service&client)。前者是一个节点(node)发布话题(topic)让另一个节点订阅。后者是客户端向服务发送请求(call request)。其中话题的内容与作用、服务的请求的格式都可以从http://wiki.ros.org/dji_sdk/中查询。

e.g.

Subscribed Topics:

/dji_sdk/flight_control_setpoint_generic (sensor_msgs/Joy)控制的flag见(https://blog.csdn.net/banzhuan133/article/details/81434036

此外也能通过查询获得一些类似flag里面代替数值的代码。

见:https://gitee.com/dji-sdk/Onboard-SDK/blob/3.8/osdk-core/api/inc/dji_control.hpp

里面VERTICAL_VELOCITY = 0x00等就是如此

这是被/dji_sdk订阅的topic。可以在wiki.ros上找到相关介绍如下:

/dji_sdk/flight_control_setpoint_generic (sensor_msgs/Joy)

  • General setpoint where axes[0] to axes[3] stores set-point data for the 2 horizontal channels, the vertical channel, and the yaw channel, respectively. The meaning of the set-point data will be interpreted based on the control flag which is stored in axes[4].

所以我们就可以得知,通过发布这类型为<sensor_msgs::Joy>的topic能够通过flag选择相应的控制类型。topic的名称为(”dji_sdk/flight_control_setpoint_generic”),python的类型可能需要再加一个“/”于topic名称的最前面。

具体示例如下:

声明一个pub其类型为<sensor_msgs::Joy>(需要相应头文件"sensor_msgs/Joy.h")

 ros::Publisher ctrlBrakePub = nh.advertise<sensor_msgs::Joy>("dji_sdk/flight_control_setpoint_generic", 10);

明确pub的内容

    sensor_msgs::Joy controlVelYawRate;
    uint8_t flag = (
                DJISDK::VERTICAL_VELOCITY   |
                DJISDK::HORIZONTAL_VELOCITY |
                DJISDK::YAW_RATE            |
                DJISDK::HORIZONTAL_GROUND   |
                DJISDK::STABLE_ENABLE);
/*flag是一个无符号8位整型数,利用以上符号代替一些十六进制数,通过或运算得到一个flag,
这个flag是唯一的,能够选择性表达不同的控制模式*/
    controlVelYawRate.axes.push_back(0);
    controlVelYawRate.axes.push_back(0);
    controlVelYawRate.axes.push_back(0);
    controlVelYawRate.axes.push_back(0);
    controlVelYawRate.axes.push_back(flag);//通过vector的push_back()运算控制.axes[0] 
                                           //to axes[5] 的value。

    ctrlBrakePub.publish(controlVelYawRate);//发布出去

这样消息就能发布出去了。

从wiki和blog中我们能够知道,这个发布最终能够控制无人机的水平速度(vx,vy)垂直速度(vz)and yaw rate of UAV.

If we want to control the altitude of the UAV, we need to change the "DJISDK::HORIZONTAL_VELOCITY" into "DJISDK::VERTICAL_POSITION".

DJISDK::HORIZONTAL_GROUND shows that the position is measured in horizontal frame(ENU) .

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值