$ roslaunch robot_description empty_world.launch
$ rqt_graph
$ rostopic echo /gazebo/model_states
$ rostopic pub /gazebo/set_model_state gazebo_msgs/ModelState "model_name: unit_box
$ rosservice call /gazebo/...
/gezebo/pause_physics: 물리 업데이트를 일시 중지
/gazebo/unpause_physics: 물리 업데이트를 재개
/gazebo/reset_simulator: 시간을 포함한 전체 시뮬레이션을 재설정
/gazebo/reset_world: 모델의 포즈를 재설정
Name | Type | 설명 |
---|---|---|
material | value | 시각적 요소의 재질 |
gravity | bool | 중력 사용 여부 |
dampingFactor | double | 링크 속도의 지수적 감쇠 - 주어진 값과 이전 링크 속도를 (1-dampingFactor)로 곱합니다. |
maxVel | double | 최대 접촉 보정 속도 절단 항목 |
minDepth | double | 접촉 보정 임펄스가 적용되기 전에 허용되는 최소 깊이 |
mu1 | double | Open Dynamics Engine (ODE)에 의해 정의된 주요 접촉 방향에 대한 마찰 계수 μ |
mu2 | ||
fdir1 | string | 충돌 로컬 참조 프레임에서 mu1의 방향을 지정하는 3-튜플 |
kp | double | ODE에 정의된 강체 접촉의 접촉 강도 k_p 및 감쇠 k_d |
kd | ||
selfCollide | bool | 참이면 모델 내의 다른 링크와 충돌할 수 있음 |
maxContacts | int | 두 엔터티 간에 허용되는 최대 접촉 수. 이 값은 물리에서 정의된 max_contacts 요소를 무시함 |
laserRetro | double | 레이저 센서에 의해 반환된 강도 값 |
https://wiki.ros.org/simulator_gazebo/Tutorials/ListOfMaterials
$ gedit /usr/share/gazebo-9/media/materials/scripts/gazebo.material
<gazebo reference="link_chassis">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="link_caster_wheel">
<material>Gazebo/Grey</material>
</gazebo>
<gazebo reference="link_left_wheel">
<material>Gazebo/Black</material>
</gazebo>
<gazebo reference="link_right_wheel">
<material>Gazebo/Black</material>
</gazebo>
<gazebo reference="joint_chassis_caster_wheel">
<preserveFixedJoint>true</preserveFixedJoint>
</gazebo>
<gazebo reference="link_chassis">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="link_caster_wheel">
<material>Gazebo/Grey</material>
<mu1>0</mu1>
<mu2>0</mu2>
</gazebo>
<gazebo reference="link_left_wheel">
<material>Gazebo/Black</material>
<mu1>1</mu1>
<mu2>1</mu2>
</gazebo>
<gazebo reference="link_right_wheel">
<material>Gazebo/Black</material>
<mu1>1</mu1>
<mu2>1</mu2>
</gazebo>
https://classic.gazebosim.org/tutorials?tut=ros_gzplugins
<!-- Robot Differential Driver -->
<gazebo>
<plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller">
<alwaysOn>true</alwaysOn>
<updateRate>20</updateRate>
<leftJoint>joint_chassis_left_wheel</leftJoint>
<rightJoint>joint_chassis_right_wheel</rightJoint>
<wheelSeparation>1.66</wheelSeparation>
<wheelDiameter>0.8</wheelDiameter>
<torque>10</torque>
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<robotBaseFrame>link_chassis</robotBaseFrame>
</plugin>
</gazebo>
#!/usr/bin/env python3
import rospy
from geometry_msgs.msg import Twist
from nav_msgs.msg import Odometry
def odom_callback(msg):
rospy.loginfo('X: %s / Y: %s' % (round(msg.pose.pose.position.x, 2), round(msg.pose.pose.position.y,2)))
def main():
odom_sub = rospy.Subscriber('odom', Odometry, odom_callback)
twist_pub = rospy.Publisher('cmd_vel', Twist, queue_size=10)
rospy.init_node('move_simple_node', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
vel_msg = Twist()
vel_msg.linear.x = 0.3
vel_msg.angular.z = 0.3
twist_pub.publish(vel_msg)
rate.sleep()
if __name__=='__main__':
try:
main()
except rospy.ROSInterruptException:
pass
#!/usr/bin/env python3
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
def laser_callback(msg):
rospy.loginfo('Minimum distance is: %s' % min(msg.ranges))
def main():
laser_sub = rospy.Subscriber('laser/scan', LaserScan, callback=laser_callback)
twist_pub = rospy.Publisher('cmd_vel', Twist, queue_size=10)
rospy.init_node('move_with_laser_node', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
twist_msg = Twist()
twist_msg.linear.x = 0.3
twist_msg.angular.z = 0.3
twist_pub.publish(twist_msg)
rate.sleep()
if __name__=='__main__':
try:
main()
except rospy.ROSInterruptException:
pass
로봇 모델링과 설명을 쉽게 관리하기 위한 XML 기반의 마크업 언어입니다.
xacro는 주로 로봇 모델링에 사용되며, URDF와 통합하여 로봇을 효과적으로 설명하고 관리할 수 있도록 도와줍니다.
- 매크로 지원: xacro는 매크로 기능을 제공하여 반복적이고 재사용 가능한 코드 블록을 정의할 수 있습니다. 이는 로봇 모델을 단순화하고 가독성을 높이는 데 도움이 됩니다.
- 파라미터화: xacro 파일은 파라미터를 사용하여 로봇의 여러 부분을 조절할 수 있습니다. 이를 통해 다양한 설정에 대응하는 유연한 모델을 만들 수 있습니다.
- Include 기능: 다른 xacro 파일이나 URDF 파일을 include하여 로봇 모델을 구성하는 데 사용할 수 있습니다. 이를 통해 모델을 모듈화하고 재사용성을 높일 수 있습니다.
<robot name="robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:include filename="$(find robot_description)/urdf/robot.gazebo" />
<!-- Parameters -->
<xacro:property name="chassis_mass" value="10" />
<xacro:property name="pi" value="3.1415926535897931"/>
<!-- Link - chassis -->
<link name="link_chassis">
<inertial>
<mass value="${chassis_mass}" />
...
https://wiki.ros.org/ros_control
https://classic.gazebosim.org/tutorials?tut=ros_control