본문 바로가기

공부

gazebo의 model pose를 tf로 게시하기

gazebo를 실행하기 위해 world 파일을 생성한다.

gazebo에서 model을 나타내는 방법은 robot spawn, world안에 model 생성 등이 있다.

아래 내용은 world로 생성한 model의 포즈를 구하고 tf로 게시 하는 방법이다.

 

1. world 파일에 plugin 추가

 

 

  <plugin name="gazebo_ros_state" filename="libgazebo_ros_state.so">
      <ros>
        <namespace>/gazebo</namespace>
      </ros>
      <update_rate>1.0</update_rate>
  </plugin>

 

 

이 plugin을 world 파일에 넣는다. 

매생이는 맨 위의 world name 밑에 넣었다.

 

 

2. model의 tf 게시 노드

 tf게시하는 방법은 ros2 doc을 찾아보면 된다. 

 

https://docs.ros.org/en/rolling/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.html

 

Writing a broadcaster (Python) — ROS 2 Documentation: Rolling documentation

Let’s first create the source files. Go to the learning_tf2_py package we created in the previous tutorial. Inside the src/learning_tf2_py/learning_tf2_py directory download the example broadcaster code by entering the following command: Open the file us

docs.ros.org

 

매생이는 이 글을 참고 했다.

 

pose[2]를 한 이유는 내가 만든 world에 있는 model이 여러개였기 때문이다.

 

ros2 topic echo /gazebo/model_states를 하면 

 

 

이렇게 출력이 된다.

그래서 2번째 배열에 있는 moving_obstacle을 가져오기 위해 [2]를 한것이다.

 

여기까지가 gazebo에 있는 model의 pose로 tf를 게시하는 방법이다.

 

실행한 영상은 아래 링크에서 확인할 수 있다. 

https://www.youtube.com/watch?v=qLsZs9TXQHQ