Trying to solve rosject basic part1 and the ranges list is out of range. What is the length of ranges list? here is my code:
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
def callback(msg):
print(msg.ranges[360])
print(msg.ranges[0])
if msg.ranges[360] < 0.5:
move.linear.x = 0
move.angular.z = 0.49
if msg.ranges[0] > 0.3:
move.linear.x = 0.19
move.angular.z = -0.49
if msg.ranges[0] < 0.2:
move.linear.x = 0.19
move.angular.z = 0.49
pub.publish(move)
rospy.init_node('wall_follow_node')
sub = rospy.Subscriber('/scan', LaserScan, callback)
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
move = Twist()
rospy.spin()