ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

  1. Initialize your Twist and Pose object before creating subscribers. Therefore you should move the following lines just below def __init__(self):

    self.move = Twist()
    self.object = Pose()
    
  2. Please initialize self.object_1 to None just below the initialization of the Twist and Pose objects,

    self.object_1 = None
    
  3. Please use the conditional statement if (self.length == 2) and (self.object_1 < 5.4): only after ensuring that self.object_1 is not None.

On a side note, if lidar_distance and /info topics are running at a similar frequency, you may couple and receive them together in a single callback. Thus your logic will become much cleaner.

  1. Initialize your Twist and Pose object before creating subscribers. Therefore you should move the following lines just below def __init__(self):

    self.move = Twist()
    self.object = Pose()
    
  2. Please initialize self.object_1 to None just below the initialization of the Twist and Pose objects,

    self.object_1 = None
    
  3. Please use the conditional statement if (self.length == 2) and (self.object_1 < 5.4): only after ensuring that self.object_1 is not None.

On a side note, if lidar_distance and /info topics are running at a similar frequency, you may couple and receive them together in a single callback. Thus your logic will become much cleaner.

Update

The question has been updated completely. I am not sure if it is good practice to modify it entirely. Never mind, following is the error:

ValueError: min() arg is an empty sequence

The error is coming from this line mini_data = min(xyz_array[:,0]). So, please check the shape of xyz_array before indexing over it.