Hello! For quiz 1, I am able to get my robot to move and turn. However, the robot gets to a point where it’s too close to the wall and I get an inf value. I’m not sure why this is happening. My code is attached below. Any advice would be greatly appreciated.
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
def callback(msg):
if msg.ranges[360] > 1.0:
move.linear.x = 0.10
move.angular.z = 0.0
print('Moving forward', msg.ranges[360])
if msg.ranges[360] < 1.0:
move.linear.x = 0.0
move.angular.z = 0.30
print('Turning', msg.ranges[360])
pub.publish(move)
rospy.init_node('topics_quiz_node')
pub = rospy.Publisher('/cmd_vel',Twist, queue_size = 1)
sub = rospy.Subscriber('/kobuki/laser/scan', LaserScan, callback)
move = Twist()
rospy.spin()