CodexLabsLLC / Colosseum

Open source simulator for autonomous robotics built on Unreal Engine with support for Unity
https://codexlabsllc.github.io/Colosseum/
Other
390 stars 122 forks source link

getMultirotorState() Function error #106

Open V7KX opened 2 months ago

V7KX commented 2 months ago

Bug report

What's the issue you encountered?

I want to draw the flight trajectory of a drone, but every time the program calls getMultirotorState() function, it will report an error.

Settings

{
  "SeeDocsAt":"https://github.com/Microsoft/AirSim/blob/main/docs/settings.md",
  "SettingsVersion": 1.2, 
  "SimMode":"Multirotor",
  "PawnPaths":{
    "UAV1":{"PawnBP":"Class'/Game/customdrone/BP_FlyingPawn.BP_FlyingPawn_C'"},
},

  "Vehicles":{
    "Drone":{
        "VehicleType":"SimpleFlight",
        "DisplayName":"My First Drone",
        "AutoCreate":true,
        "EnableCollisionPasthrough":false,
        "PawnPath": "UAV1",
        "X":0,"Y":0,"Z":0
    }
  }
}

How can the issue be reproduced?

import os
import airsim
import time
import pygame

client = airsim.MultirotorClient()
client.confirmConnection()

client.enableApiControl(True)
client.armDisarm(True)
client.takeoffAsync().join()
client.moveToZAsync(-5, 5).join()
# Test
state = client.getMultirotorState()

client.hoverAsync().join()
time.sleep(5)

client.landAsync().join()
client.armDisarm(False)
client.enableApiControl(False)

Include full error message in text form

Connected!
Client Ver:1 (Min Req: 1), Server Ver:1 (Min Req: 1)

Traceback (most recent call last):
  File "D:\project\pythonProject1\test.py", line 14, in <module>
    state = client.getMultirotorState()
  File "C:\Users\Lenovo\AppData\Roaming\Python\Python37\site-packages\airsim\client.py", line 1594, in getMultirotorState
    return MultirotorState.from_msgpack(self.client.call('getMultirotorState', vehicle_name))
  File "C:\Users\Lenovo\AppData\Roaming\Python\Python37\site-packages\airsim\types.py", line 30, in from_msgpack
    raise ValueError("Length of encoded data does not match number of attributes")
ValueError: Length of encoded data does not match number of attributes
# len(encoded)=6, len(cls.attribute_order)=9

What's better than filing an issue? Filing a pull request :).

MBT2023 commented 2 weeks ago

Hello, I have the same issue with this function, I can't run hello_drone.py. I am using UE 5.4, Win10, Colosseum-main. I get this error: ################################################### Traceback (most recent call last): File "C:\Users\amax\Colosseum\PythonClient\multirotor\hello_drone.py", line 15, in state = client.getMultirotorState() File "C:\Users\amax\Colosseum\PythonClient\airsim\client.py", line 1594, in getMultirotorState return MultirotorState.from_msgpack(self.client.call('getMultirotorState', vehicle_name)) File "C:\Users\amax\Colosseum\PythonClient\airsim\types.py", line 36, in from_msgpack raise ValueError("Length of encoded data does not match number of attributes") ValueError: Length of encoded data does not match number of attributes #####################################################################

Did you find any solution ?

V7KX commented 2 weeks ago

Sorry, I haven't solved this problem either. It seems that Colossum is unable to obtain the status information of the drone itself. The version I am currently using is cosys-airsim, but it also has a problem as it cannot set ' "DrawDebugPoints": true, ' in settings. json, otherwise it will crash. So I think if it's not necessary, it's better to use UE4 back.

Liu Zhe @.***

College graduates Shandong Province, China

 

------------------ 原始邮件 ------------------ 发件人: "CodexLabsLLC/Colosseum" @.>; 发送时间: 2024年11月7日(星期四) 晚上10:15 @.>; 抄送: "Liu @.**@.>; 主题: Re: [CodexLabsLLC/Colosseum] getMultirotorState() Function error (Issue #106)

Hello, I have the same issue with this function, I can't run hello_drone.py. I am using UE 5.4, Win10, Colosseum-main. I get this error: ################################################### Traceback (most recent call last): File "C:\Users\amax\Colosseum\PythonClient\multirotor\hello_drone.py", line 15, in state = client.getMultirotorState() File "C:\Users\amax\Colosseum\PythonClient\airsim\client.py", line 1594, in getMultirotorState return MultirotorState.from_msgpack(self.client.call('getMultirotorState', vehicle_name)) File "C:\Users\amax\Colosseum\PythonClient\airsim\types.py", line 36, in from_msgpack raise ValueError("Length of encoded data does not match number of attributes") ValueError: Length of encoded data does not match number of attributes #####################################################################

Did you find any solution ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

MBT2023 commented 2 weeks ago

Thanks for your answer. I tried also Pegasus based on Isaac Sim. It seems to work but is very GPU demanding.

MBT2023 commented 2 weeks ago

I changed types.py file (PythonClient/airsim/) and I don't have the error message.

def from_msgpack(cls, encoded):

    obj = cls()
     # if len(encoded) != len(cls.attribute_order):
     #   raise ValueError("Length of encoded data does not match number of attributes")        
    # for index, (attr_name, attr_type) in enumerate(cls.attribute_order):
        # value = encoded[index]
        # if issubclass(attr_type, MsgpackMixin):
        #     value = attr_type.from_msgpack(value)
        # setattr(obj, attr_name, value)
    if isinstance(encoded, dict):
        for k, v in encoded.items():
            if (isinstance(v, dict) and hasattr(getattr(obj, k).__class__, 'from_msgpack')):
                obj.__dict__[k] = getattr(getattr(obj, k).__class__, 'from_msgpack')(v)
            else:
                obj.__dict__[k] = v
    else:
        obj = encoded

    return obj