Gazebo_precision_landing_array.py ERROR


#1

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))


#2

Not sure but I assume the other single aruco program was working in your setup environment?
If you want to send the code to me I can check. [dronedojoforum@gmail.com]


#3

This link https://bobbyhadz.com/blog/python-attributeerror-int-object-has-no-attribute explains the problem. In line 127 marker_heights is defined as an integer (i.e., marker_heights = 0) but in line 130 it is being referenced as an array (i.e., if altitude > marker_heights[1]). Hope this helps.


#4

That is a typo in the above code. Should be:

marker_height=0


closed #5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.