ROS学习(二)NavSatFix.msg

1.sensor_msgs/NavSatFix.h源码

# Navigation Satellite fix for any Global Navigation Satellite System
#
# Specified using the WGS 84 reference ellipsoid

# header.stamp specifies the ROS time for this measurement (the
#        corresponding satellite time may be reported using the
#        sensor_msgs/TimeReference message).
#
# header.frame_id is the frame of reference reported by the satellite
#        receiver, usually the location of the antenna.  This is a
#        Euclidean frame relative to the vehicle, not a reference
#        ellipsoid.
Header header

# 卫星定位状态信息
NavSatStatus status

# 纬度[度],正赤道以北;
float64 latitude

# 经度[度],正数在本初子午线的东部,负的是西。
float64 longitude

# Altitude [m]. Positive is above the WGS 84 ellipsoid
# (quiet NaN if no altitude is available).
float64 altitude

# Position covariance [m^2] defined relative to a tangential plane
# through the reported position. The components are East, North, and
# Up (ENU), in row-major order.
#
# Beware: this coordinate system exhibits singularities at the poles.
#位置协方差
float64[9] position_covariance

# If the covariance of the fix is known, fill it in completely. If the
# GPS receiver provides the variance of each measurement, put them
# along the diagonal. If only Dilution of Precision is available,
# estimate an approximate covariance from that.

uint8 COVARIANCE_TYPE_UNKNOWN = 0
uint8 COVARIANCE_TYPE_APPROXIMATED = 1
uint8 COVARIANCE_TYPE_DIAGONAL_KNOWN = 2
uint8 COVARIANCE_TYPE_KNOWN = 3

uint8 position_covariance_type

1.1header

1.head.stamp:指此测量的ROS时间(可以使用sensor_msgs / TimeReference消息报告相应的卫星时间)。

2.header.frame_id:是卫星接收器报告的参考帧,通常是天线的位置。 这是相对于车辆的欧几里德框架,而不是椭圆体参考坐标系。

1.2NavSatStatus

# Navigation Satellite fix status for any Global Navigation Satellite System

# Whether to output an augmented fix is determined by both the fix
# type and the last time differential corrections were received.  A
# fix is valid when status >= STATUS_FIX.

int8 STATUS_NO_FIX =  -1        # 无法确定位置
int8 STATUS_FIX =      0        # 未能精准定位
int8 STATUS_SBAS_FIX = 1        # with satellite-based augmentation
int8 STATUS_GBAS_FIX = 2        # with ground-based augmentation

int8 status

# Bits defining which Global Navigation Satellite System signals were
# used by the receiver.

uint16 SERVICE_GPS =     1
uint16 SERVICE_GLONASS = 2
uint16 SERVICE_COMPASS = 4      # includes BeiDou.
uint16 SERVICE_GALILEO = 8

uint16 service

 

ROS中,使用.msg文件来定义消息类型。具体步骤如下: 1. 在ROS包中创建一个名为msg的文件夹。 2. 在msg文件夹中创建一个名为*.msg的文件,其中*为你所定义的消息类型名称。 3. 在*.msg文件中定义消息类型的字段和类型。例如,定义一个包含字符串和整数字段的消息类型可以写作: ``` string name int32 age ``` 4. 在CMakeLists.txt文件中添加以下代码: ``` add_message_files( FILES *.msg ) generate_messages( DEPENDENCIES std_msgs ) ``` 其中,add_message_files()函数将*.msg文件添加到ROS包中,generate_messages()函数根据*.msg文件生成对应的消息类型代码。 5. 在package.xml文件中添加以下代码: ``` <build_depend>message_generation</build_depend> <exec_depend>message_runtime</exec_depend> ``` 这些代码声明了消息生成器(message_generation)和消息运行时(message_runtime)的依赖项。 6. 编译ROS包。在ROS包的根目录下运行以下命令: ``` catkin_make ``` 编译成功后,将生成一个msg_gen_cpp文件夹,其中包含自动生成的消息类型代码。 7. 在ROS节点中使用自定义的消息类型。 在ROS节点中使用自定义的消息类型时,需要包含消息类型的头文件,并使用该消息类型的变量进行消息传递。例如,使用上面定义的消息类型可以写作: ``` #include <ros/ros.h> #include <your_package_name/your_message_type_name.h> int main(int argc, char **argv) { ros::init(argc, argv, "your_node_name"); ros::NodeHandle nh; your_package_name::your_message_type_name msg; msg.name = "John"; msg.age = 30; ros::Publisher pub = nh.advertise<your_package_name::your_message_type_name>("your_topic_name", 10); pub.publish(msg); ros::spin(); return 0; } ``` 这个例子中,我们使用了自定义的消息类型your_message_type_name,将消息发布到your_topic_name话题上。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

火柴的初心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值