IndexError : tuple index out of range
I made a code for autonomous driving of the designated stadium. But when I ran it on ubuntu 18.04, Jetson nano, there was a tuple error. Considering the Python version, i entered the driving code as "python *.py". Can you tell me what's wrong? marked with "" part where there was an error is
class Test():
count=0
corner_flag=0
check=0
check1=0
heading=0
ratio = 0
start = 0
start_angle = 0
def __init__(self):
self.scan_sub=rospy.Subscriber('/scan', LaserScan, self.scan_callback)
self.odom_sub=rospy.Subscriber('/odom', Odometry, self.odom_callback)
self.vel_pub=rospy.Publisher('/cmd_vel',Twist,queue_size=0)
self.twist=Twist()
rospy.init_node('imu_values', anonymous=False)
def scan_callback(self,data):
self.scan=data
def odom_callback(self,odom):
self.odom_pose=odom.pose.pose
def centerline(self):
if Test.count==0:
rospy.sleep(2)
Test.count=1
self.twist=Twist()
self.orientaion_list=[self.odom_pose.orientation.x,
self.odom_pose.orientation.y,
self.odom_pose.orientation.z,
self.odom_pose.orientation.w]
(self.roll,self.pitch,self.yaw)=euler_from_quaternion(self.orientaion_list)
if self.start == 0:
self.start_angle = int(math.degrees(self.yaw))
self.start = 1
self.l_01=round(self.scan.ranges[0],3)
self.l_02=round(self.scan.ranges[1],3)
self.l_03=round(self.scan.ranges[2],3)
self.l_04=round(self.scan.ranges[-1],3)
self.l_05=round(self.scan.ranges[-2],3)
self.l_11=round(self.scan.ranges[90],3)
self.l_12=round(self.scan.ranges[89],3)
self.l_13=round(self.scan.ranges[91],3)
self.l_21=round(self.scan.ranges[-90],3)
self.l_22=round(self.scan.ranges[-89],3)
self.l_23=round(self.scan.ranges[-91],3)
self.m_1=round(self.scan.ranges[179-self.heading],3)
**self.m_2=round(self.scan.ranges[359-self.heading],3)**
self.centroid_l=self.m_1+self.m_2
self.centroid_m=self.m_1+self.m_2+0.4
self.diff=max(self.l_01,self.l_02,self.l_03,self.l_04,self.l_05)
self.diff1=max(self.l_11,self.l_12,self.l_13)
self.diff2=max(self.l_21,self.l_22,self.l_23)
Test.ratio = self.diff1 - self.diff2
if self.diff<0.1:
self.diff=1
# start
self.twist.linear.x=0.1
self.twist.angular.z=0.0
if Test.ratio > -0:
self.twist.linear.x=0.1
self.twist.angular.z=0.02
self.vel_pub.publish(self.twist)
elif Test.ratio < 0:
self.twist.linear.x=0.1
self.twist.angular.z=-0.02
self.vel_pub.publish(self.twist)
else:
self.twist.linear.x=0.1
self.twist.angular.z=0.0
self.vel_pub.publish(self.twist)
print(self.twist.linear.x, self.twist.angular.z)
print(self.diff1,self.diff, self.diff2)
# turnning point
if self.diff <= 0.57:
print(self.twist.linear.x, self.twist.angular.z)
print(self.centroid_l, self.diff, Test.ratio, self.diff <= 0.5)
# right turn
if Test.check == 0:
while 1:
self.orientaion_list=[self.odom_pose.orientation.x,
self.odom_pose.orientation.y,
self.odom_pose.orientation.z,
self.odom_pose.orientation.w]
(self.roll,self.pitch,self.yaw)=euler_from_quaternion(self.orientaion_list ...