Help us understand the problem. What is going on with this article?

# ROSのTFへOdometoryを入力する

More than 1 year has passed since last update.

## 目的

ROSのgmappingなどでSLAMを行うためには、

ROSのLidarSLAMまとめ

## 実装

```#include <ros/ros.h>
#include <nav_msgs/Odometry.h>

void odom_calc(double &state_odom_x,double &state_odom_y,double &state_odom_th){
//ここでエンコーダ値を読み取り、オドメトリ変換する演算を行う。
}

int main(int argc, char **argv){
ros::Time current_time;
current_time = ros::Time::now();

ros::Rate r(30.0);

double state_odom_x=0.0;//オドメトリX座標[m]
double state_odom_y=0.0;//オドメトリY座標[m]

while(nh.ok()){
odom_calc(state_odom_x,state_odom_y,state_odom_th);
current_time = ros::Time::now();

geometry_msgs::TransformStamped odom_trans;

odom_trans.transform.translation.x = state_odom_x;
odom_trans.transform.translation.y = state_odom_y;
odom_trans.transform.translation.z = 0.0;
geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(state_odom_th);
odom_trans.transform.rotation = odom_quat;

ros::spinOnce();
r.sleep();
}
}
```

### 確認

rvizでtfが発行されていることを確認する。

## 参考：

ROS wiki Publishing Odometry Information over ROS

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away