I am doing GAZEBO_PRECISION_LANDING_ARRAY.PY. I’ve searched repeatedly several times, but I can’t find a solution.
please help me
======== ERROR CODE======
[ERROR] [1665578311.065302, 18303.673000]: bad callback: <function msg_receiver at 0x7fb7219572d0>
Traceback (most recent call last):
File “/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py”, line 750, in _invoke_callback
cb(msg)
File “/home/apl/aplc/catkin_ws/src/gazebo_drone/scripts/gazebo_precision_landing_array.py”, line 130, in msg_receiver
if altitude > marker_heights[1]:
TypeError: ‘int’ object has no attribute 'getitem’
============= Work file ==============
def msg_receiver(message):
global notfound_count, found_count, time_last, time_to_wait, id_to_find
if time.time() - time_last > time_to_wait:
np_data = rnp.numpify(message) ##Deserialize image data into array
gray_img = cv2.cvtColor(np_data, cv2.COLOR_BGR2GRAY)
ids = ''
(corners, ids, rejected) = aruco.detectMarkers(image=gray_img,dictionary=aruco_dict,parameters=parameters)
ids == [129,72]
altitude = vehicle.location.global_relative_frame.alt ##meters
id_to_find=0
marker_heights=0
marker_size=0
** if altitude > marker_heights[1]:**
** id_to_find=ids_to_find[0]**
** marker_height=marker_heights[0]**
** marker_size=marker_sizes[0]**
** elif altitude < marker_heights[1]:**
** id_to_find=ids_to_find[1]**
** marker_height=marker_heights[1]**
** marker_size=marker_sizes[1]**
ids_array_index=0
found_id=0
print ("Looking for marker: "+ str(id_to_find))