ROS_Description - kairproject/kair_algorithms_draft GitHub Wiki
ROS ์ค์น
1. Docker ์ด์ฉํ์ฌ ROS ๋ฐ ํ๋ก์ ํธ ํ๊ฒฝ ์ฌ์ฉ
ROS ์ค์น๋ฅผ ์ํด์๋ ๋ค์ Dockerfile์ ์ฐธ๊ณ ํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. Dockerfile for kairproject using ROS
2. Local์ ROS ์ค์น์ ํ๋ก์ ํธ๋ฅผ ์ํ ํ๊ฒฝ ์ค์
Dockerfile์ ์ฐธ๊ณ ํ์ฌ local์์ ROS๋ฅผ ์ค์นํ์ฌ ํ๊ฒฝ์ ์ค์ ํ์ฌ ์ฌ์ฉํ์๊ธฐ ๋ฐ๋๋๋ค.
Dockerfile์ ๋ช
๋ น์ค ์์ sudo
๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ค์นํฉ๋๋ค.
ROS Workspace
1. initial workspace
catkin workspace
$ cd ~/catkin_ws/src
์ฒ์ ์์ ๊ณต๊ฐ์ ๋ง๋ค์์ ๋๋ catkin_ws/src/ ํด๋ ์์ CMakeLists.txt ํ์ผ ํ๋๊ฐ ์กด์ฌํฉ๋๋ค. ์์ ์ค์น ๋ฐ ํ๊ฒฝ์ค์ ์ ๋ฐ๋ผ์ค์ จ์ผ๋ฉด catkin_ws/src/ ์์ ์ด๋ฏธ ํด๋๋ค์ด ์์ ๊ฒ ์ ๋๋ค.
ROS ํ์ผ ๋น๋
catkin_make ๋ช ๋ น์ผ๋ก ์ด ์์ ๊ณต๊ฐ์ "๋น๋"ํ๋ ๊ฒ์ด ๊ฐ๋ฅํฉ๋๋ค.
$ cd ~/catkin_ws/
$ catkin_make
2. ROS Package ์์ฑ/๋น๋
ROS Package ๊ตฌ์ฑ
workspace_folder/ -- ์์
๊ณต๊ฐ
src/ -- ์์ค ํด๋
CMakeLists.txt -- catkin์ด ์ ๊ณตํ๋ '์ต์์'์ CMake ํ์ผ,
package_1/
CMakeLists.txt -- package_1์ ๋ํ CMakeLists.txt ํ์ผ
package.xml -- package_1์ ๋ํ ๋งค๋ํจ์คํธ
...
package_n/
CMakeLists.txt -- package_n์ ๋ํ CMakeLists.txt ํ์ผ
package.xml -- package_n์ ๋ํ ๋งค๋ํจ์คํธ
์์) std_msgs, roscpp, rospy์ ๋ํ ์์กด์ฑ์ ๊ฐ์ง๋ โbeginner_tutorialsโ ํจํค์ง๋ฅผ ๋ง๋ค๊ธฐ ์ํด catkin_creaet_pkg ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์๋๋ฅผ ์ํํ๋ฉด package.xml๊ณผ CMakeLists.txt์ด ๋ค์ด์๋ beginner_tutorials ํด๋๊ฐ ๋ง๋ค์ด์ง๋๋ค.
$ cd ~/catkin_ws/src
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
ROS ์ฉ์ด
- Master roscore๋ก ์คํํ๊ณ , ๋ค์์๋ฒ์ ๋น์ทํ ์ญํ ์ ์ํํฉ๋๋ค.๋ง์คํฐ๋ฅผ ์คํํ๋ฉด ๋ ธ๋ ์ด๋ฆ ๋ฑ๋ก ๋ฐ ์กฐํ, ๋ฉ์ธ์ง ํต์ ํ ์ ์์ต๋๋ค. ๋ง์คํฐ๊ฐ ์์ผ๋ฉด ๋ ธ๋๋ ์๋ก๋ฅผ ์ฐพ๊ณ ๋ฉ์ธ์ง๋ฅผ ๊ตํํ๊ฑฐ๋ ์๋น์ค๋ฅผ ํธ์ถํ ์ ์์ต๋๋ค.
roscore
- Nodes ๋ ธ๋๋ ๊ณ์ฐ์ ์ํํ๋ ์ต์ ๋จ์ ๋ฐํ์ ํ๋ก์ธ์ค ์ ๋๋ค. ROS ์ ์ด ์์คํ ์ ๋ง์ ๋ ธ๋๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ํ๋์ ๋ ธ๋๋ gripper position ์ ์ด, ํ๋์ ๋ ธ๋๋ ๊ฐ๊ฐ์ joint position ์ ์ด, ํ๋์ ๋ ธ๋๋ manipulator state ์ ์ด ๋ฑ์ ์ํํ๋๋ก ํ ์ ์์ต๋๋ค. ROS ๋ ธ๋๋ rospy์ roscpp์ ๊ฐ์ ROS ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ์์ฑ๋ฉ๋๋ค. rosrun ๋ช ๋ น์ผ๋ก ํจํค์ง ์์ ๋ ธ๋๋ฅผ ์ง์ ์คํ์ํฌ ์ ์๊ฒ ํด์ค๋๋ค.
rosrun kairproject openmanipulator
# rosrun [package_name] [node_name]
- Messages ๋ ธ๋๋ ๋ฉ์ธ์ง๋ฅผ ์ ๋ฌํ์ฌ ์๋ก ํต์ ํฉ๋๋ค.
ROS ํต์
ROS์์ ์ฌ์ฉ๋๋ ํต์ ๊ฐ๋
์ ์๊ฐํฉ๋๋ค.
์ฌ๊ธฐ์๋ ROS topic, service ๋ ๊ฐ์ง ๊ฐ๋
์ ์ฌ์ฉํฉ๋๋ค.
-
Topics
๋ ธ๋๋ ์ฃผ์ด์ง ํ ํฝ์ ๋ํด publishing์ ํตํด ๋ฉ์ธ์ง๋ฅผ ๋ณด๋ด๊ฒ ๋ฉ๋๋ค. ํ ํฝ์ ๋ฉ์ธ์ง์ ๋ด์ฉ์ ๊ตฌ๋ณํ๋ ์ด๋ฆ์ ๋๋ค. ํน์ ์ข ๋ฅ์ ๋ฐ์ดํฐ์ ๊ด์ฌ์ด ์๋ ๋ ธ๋๋ ํ ํฝ์ ๋ํด์ subscribe ํ๊ฒ ๋ฉ๋๋ค. ํ๋์ ํ ํฝ์ ๋ํด ์ฌ๋ฌ๊ฐ์ publisher์ subscriber๊ฐ ์์ ์ ์๊ณ , ํ๋์ ๋ ธ๋๊ฐ ์ฌ๋ฌ๊ฐ์ ํ ํฝ์ผ๋ก publishํ๊ณ subscribe ํ ์ ์์ต๋๋ค. -
Service
publish/subscribe ๋ชจ๋ธ์ ๋จ๋ฐฉํฅ ์ ์ก์ด๋ฉฐ, ์ด๋ request/reply ์ํธ์์ฉ์ ์ ํฉํ์ง ์์ต๋๋ค. ์๋น์ค๋ request์ reply ์ค ํ ์์ ๋ฉ์ธ์ง ๊ตฌ์กฐ๋ก ์ ์๋ฉ๋๋ค. ์ ๊ณต ๋ ธ๋๋ ์ด๋ฆ์ผ๋ก ์๋น์ค๋ฅผ ์ ๊ณตํ๊ณ , service client๋ request๋ฅผ ๋ณด๋ด๊ณ service server๋ ์๋ต์ ๊ธฐ๋ค๋ฆผ์ผ๋ก์จ ์๋น์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค.
ROS msg/srv
ํ๋ก์ ํธ์์ ์ฌ์ฉ๋ msg, srv ์ ๋๋ค. Openmanipulator ์ ์กฐ์ฌ ROBOTIS ์์ ์ ๊ณตํ๋ open_manipulator_msgs ์ ๋๋ค.
from gazebo_msgs.srv import DeleteModel, GetModelState, SpawnModel
from geometry_msgs.msg import Pose
from open_manipulator_msgs.msg import KinematicsPose, OpenManipulatorState
from sensor_msgs.msg import JointState
from std_msgs.msg import Float64
string[] joint_name
float64[] position
float64 max_accelerations_scaling_factor
float64 max_velocity_scaling_factor
example of srv file
int64 A
int64 B
---
int64 Sum
ROS topic
ํ์ฌ ์คํ๋๊ณ ์๋ ROS topic list๋ฅผ ์์๋ด ์๋ค.
$ rostopic list
/open_manipulator/gripper_position/command
/open_manipulator/gripper_sub_position/command
/open_manipulator/joint1_position/command
/open_manipulator/joint2_position/command
/open_manipulator/joint3_position/command
/open_manipulator/joint4_position/command
์์ ๋ ธ๋๋ค์ด ํ๋ฉด์ ๋์ฌ ๊ฒ ์ ๋๋ค.
ROS Publisher
joint position | |
---|---|
node | /open_manipulator/gripper_position/command, open_manipulator/gripper_sub_position/command, /open_manipulator/joint1_position/command, /open_manipulator/joint2_position/command, /open_manipulator/joint3_position/command, /open_manipulator/joint4_position/command |
msg | Float64 |
์ฝ๋ ์์น: ros_interface.py line 52 init_publisher_node
ROS Subscriber
joint state | kinematics_pose | openmanipulator state | |
---|---|---|---|
node | /open_manipulator/joint_states | /open_manipulator/gripper/kinematics_pose | /open_manipulator/states |
msg | JointState | KinematicsPose | OpenManipulatorState |
callback | joint_state_callback | kinematics_pose_callback | robot_state_callback |
์ฝ๋ ์์น: ros_interface.py line 77 init_subscriber_node
ROS tf(transformation)
๊ฐ coordinate frame ๊ฐ์ ๊ด๊ณ, ์์์ time์์ ๋ coodinate frame๊ฐ ์ , ๋ฒกํฐ ๋ฑ ๋ณํ
- 5์ด ์ ์ head frame์ด world frame์ ๋ํด ์ด๋ ์์น์ ์๋์ง
- gripper object์ Pose๊ฐ base์ ์ด๋ค ๊ด๋ จ์ด ์๋์ง
Base data types (Quaternion, Vector, Point, Pose, Transform)
ROS geometry_msg ํ์ ์ค์์ transform data types
type | tf | raw message define |
---|---|---|
Quaternion | tf::Quaternion | float64 x,float64 y,float64 z,float64 w |
Vector | tf::Vector3 | float64 x,float64 y,float64 z |
Point | tf::Point | float64 x,float64 y,float64 z |
Pose | tf::Pose | Point position,Quaternion orientation |
Transfer | tf::Transform | Vector3 translaion,Quaternion rotation |