如何解决将turtlebot2绕其轴旋转10度
你好吗?如何将turtlebot2绕其轴旋转10度,然后暂停。 注意:机器人不会移动,只会说20秒一次,旋转10度。 我尝试在Z方向上设置Twist()对象的角速度,但只有一个轮子移动,最终机器人移位了。
下面是我的代码:
angular_veLocity = radians(10) #10 degs / s
r = rospy.Rate(5) #5Hz
#rospy.loginfo("starting loop")
while not rospy.is_shutdown():
rospy.loginfo("in loop")
new_angle = (angle + new_angle) % 360
real_angle = real_angle + angle
#real_angle = rea1_angle + 5
rospy.loginfo("after addition")
new_angle = real_angle % 360
turn_cmd.angular.z = angular_veLocity #turns 10 degrees a second
#turn at 10 degrees a second for 1 second
for i in range(5):
self.cmd_vel.publish(turn_cmd)
r.sleep()
r.sleep()
# wait 40s
for x in range(200):
self.cmd_vel.publish(Twist()) #publish ) to stop the bot at that point
# stop the turtle and gather data as u wait
r.sleep()
try:
data = "get some data from external source"
if(data):
try:
#rospy.loginfo("w(rads/$
comb_d.write( str(data)
except:
rospy.loginfo("Failed or bad data)
pass
r.sleep()
comb_d.close()
def shutdown(self):
# stop turtlebot
rospy.loginfo("Stop turning")
self.cmd_vel.publish(Twist())
以上是我的逻辑。但是机器人不仅会移动,而且不会像我期望的那样旋转10度。 我究竟做错了什么? 非常感谢你。 我正在使用ROS靛蓝kobuki和turtlebot2
话虽这么说-稍微不同一点-rospy.Rate()
函数和内部for
循环以达到10
甚至30
的有利值是多少相对较高的角速度(例如25 degrees per second
)旋转1度。因为似乎机器人在10 degs/s
等低速下不能很好地工作。有时,当给出低速时,它根本不会移动。无论如何,谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。