您现在的位置是:Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款 >
03 ros發布和訂閱python(如何在ros 使用odometry python)
Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款2024-06-16 08:24:37【】9人已围观
简介/p> self.cmd_vel=rospy.Publisher('/cmd_vel',Twist,queue_size=5)
self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=5)
rate = 20
r = rospy.Rate(rate)
linear_speed = 0.2
goal_distance =1.0
angular_speed = 1.0
goal_angle = pi
angular_tolerance = radians(2.5)
# Initialize tf listener, and give some time to fill its buffer
self.tf_listener = tf.TransformListener()
rospy.sleep(2)
# Set odom_frame and base_frame
self.odom_frame = '/odom'
try:
self.tf_listener.waitForTransform(self.odom_frame,
'/base_footprint',
rospy.Time(),
rospy.Duration(1.0))
self.base_frame = '/base_footprint'
except(tf.Exception, tf.ConnectivityException, tf.LookupException): try:
self.tf_listener.waitForTransform(self.odom_frame,
'/base_link',
rospy.Time(),
rospy.Duration(1.0))
self.base_frame = '/base_link'
except(tf.Exception, tf.ConnectivityException, tf.LookupException):
rospy.loginfo("Cannot find base_frame transformed from /odom")
rospy.signal_shutdown("tf Exception")
position = Point()
for i in range(2):
move_cmd = Twist()
move_cmd.linear.x = linear_speed # Initial pose, obtained from internal odometry
(position, rotation) = self.get_odom()
x_start = position.x
y_start = position.y
distance = 0
# Keep publishing Twist msgs, until the internal odometry reach the goal
while distance < goal_distance and not rospy.is_shutdown():
self.cmd_vel.publish(move_cmd)
r.sleep()
(position, rotation) = self.get_odom()
distance = sqrt( pow( (position.x-x_start), 2 ) + \
pow( (position.y-y_start), 2 ) )
# Stop 1 ms before rotate
move_cmd = Twist()
self.cmd_vel.publish(move_cmd)
rospy.sleep(1)
move_cmd.angular.z = angular_speed # should be the current ration from odom
angle_last = rotation
angle_turn = 0 while abs(angle_turn+angular_tolerance) < abs(goal_angle) \ and not rospy.is_shutdown():
self.cmd_vel.publish(move_cmd)
r.sleep()
(position, rotation) = self.get_odom
delta_angle = normalize_angle(rotation - angle_last)
angle_turn += delta_angle
angle_last = rotation
move_cmd = Twist()
self.cmd_vel.publish(move_cmd)
rospy.sleep(1)
self.cmd_vel.publish(Twist())
def get_dom(self): try:
(trans, rot) = self.tf_listener.lookupTransfrom(self.odom_frame,
&
很赞哦!(85683)
相关文章
- 01 qq音樂怎么看一首歌的播放量(怎樣知道QQ音樂播放量)
- 01 qq郵箱訂閱郵件怎么打開(怎樣在QQ郵箱中找到訂閱的郵件?)
- 01 redis發布訂閱模式是基于pull還是push(Spring Boot使用Redis進行消息的發布訂閱 原創)
- 01 youtube視頻下載器高清接口驅動程序(為何下載不了YOUTUBE的影片)
- 01 rakuten美妝海外旗艦店(海淘網站哪個最靠譜?求推薦。)
- 01 youtube視頻下載器教程詳解pdf下載(怎么將YouTube視頻嵌入到PPT PowerPoint中)
- 01 redis發布訂閱性能(《Redis設計與實現》pdf下載在線閱讀,求百度網盤云資源)
- 01 youtube視頻下載器教程詳解pdf百度(youtube視頻是什么?)
- 01 youtube視頻下載器教程視頻教程全集視頻(ios快捷指令油管視頻下載ssl錯誤)
- 01 qq音樂播放量總榜排行在哪看(如何查看QQ音樂播放量排名?)
热门文章
站长推荐
01 youtube視頻下載網站排行榜免費下載豆丁(網絡推廣100種方法有哪些)
01 youtube視頻下載器軟件哪個好而且便宜(一般什么視頻剪輯軟件好用,有誰知道Youtube達人一般用什么剪輯軟件制作的視頻。)
01 youtube視頻下載器高清線怎么打(folx如何使用)
01 youtube視頻下載器軟件安裝檢測安裝包(怎么在youtube上下載視頻)
01 youtube視頻下載器軟件電腦端好用(除了迅雷還有什么下載器最好用)
01 qq音樂的歌單播放量按什么算(qq音樂歌單播放量怎么算的?)
01 youtube視頻下載器軟件推薦知乎2023(6個全新社媒趨勢,2023跨境營銷機會在這里!)
01 redis的發布訂閱 性能(Spring Boot使用Redis進行消息的發布訂閱 原創)