def get_angle(data): rospy.loginfo(rospy.get_caller_id() + "I heard ANGLE: %s", data.data) number_of_sensors = 4 sensor_indexes = sensor_indexes.create_sensor_indexes(number_of_sensors) sensor_interval = math.pi/number_of_sensors sensor_weight = sensor_interval*sensor_indexes rebound_angle_radians = (np.dot(sensor_weight, data.data))/(np.sum(data.data)) rebound_angle_degrees = np.rad2deg(rebound_angle_radians)
def get_rebound_angle(self, data): rospy.loginfo(rospy.get_caller_id() + "I heard ANGLE: %s", data.data) number_of_sensors = 4 sensor_indexes = create_sensor_indexes(number_of_sensors) sensor_interval = math.pi/number_of_sensors sensor_weight = np.dot(sensor_interval, sensor_indexes) rebound_angle_radians = (np.dot(sensor_weight, data.data))/(np.sum(data.data)) self.rebound_angle_degrees = np.rad2deg(rebound_angle_radians) print("rebound angle is: ", self.rebound_angle_degrees)