public override MetadataWrapper generateMetadataWrapper() { MetadataWrapper metadata = base.generateMetadataWrapper(); // For Drone controller, currentTime should be based on // fixed update passes so use DroneTimeSinceStart instead of TimeSinceStart metadata.currentTime = DroneTimeSinceStart(); // TODO: clean this up with reflection. // it works, but will not update when something changes to AgentMetadata // metadata.agent = new AgentMetadata baseAgent = metadata.agent; DroneAgentMetadata droneMeta = new DroneAgentMetadata(); droneMeta.name = "drone"; droneMeta.position = baseAgent.position; droneMeta.rotation = baseAgent.rotation; droneMeta.cameraHorizon = baseAgent.cameraHorizon; droneMeta.inHighFrictionArea = baseAgent.inHighFrictionArea; // New drone stuff for agent metadata droneMeta.LauncherPosition = GetLauncherPosition(); metadata.agent = droneMeta; return(metadata); }
public override MetadataWrapper generateMetadataWrapper() { // AGENT METADATA DroneAgentMetadata agentMeta = new DroneAgentMetadata(); agentMeta.name = "agent"; agentMeta.position = transform.position; agentMeta.rotation = transform.eulerAngles; agentMeta.cameraHorizon = m_Camera.transform.rotation.eulerAngles.x; if (agentMeta.cameraHorizon > 180) { agentMeta.cameraHorizon -= 360; } //New Drone Stuff for agentMeta agentMeta.LauncherPosition = GetLauncherPosition(); // OTHER METADATA MetadataWrapper metaMessage = new MetadataWrapper(); //For Drone controller, currentTime should be based on //fixed update passes so use DroneTimeSinceStart instead of TimeSinceStart metaMessage.currentTime = DroneTimeSinceStart(); //agentMeta.FlightMode = FlightMode; metaMessage.agent = agentMeta; metaMessage.sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; metaMessage.objects = this.generateObjectMetadata(); //check scene manager to see if the scene's objects are at rest metaMessage.isSceneAtRest = physicsSceneManager.isSceneAtRest; metaMessage.collided = collidedObjects.Length > 0; metaMessage.collidedObjects = collidedObjects; metaMessage.screenWidth = Screen.width; metaMessage.screenHeight = Screen.height; metaMessage.cameraPosition = m_Camera.transform.position; metaMessage.cameraOrthSize = cameraOrthSize; cameraOrthSize = -1f; metaMessage.fov = m_Camera.fieldOfView; metaMessage.lastAction = lastAction; metaMessage.lastActionSuccess = lastActionSuccess; metaMessage.errorMessage = errorMessage; metaMessage.actionReturn = this.actionReturn; if (errorCode != ServerActionErrorCode.Undefined) { metaMessage.errorCode = Enum.GetName(typeof(ServerActionErrorCode), errorCode); } List <InventoryObject> ios = new List <InventoryObject>(); if (ItemInHand != null) { SimObjPhysics so = ItemInHand.GetComponent <SimObjPhysics>(); InventoryObject io = new InventoryObject(); io.objectId = so.ObjectID; io.objectType = Enum.GetName(typeof(SimObjType), so.Type); ios.Add(io); } metaMessage.inventoryObjects = ios.ToArray(); // HAND metaMessage.hand = new HandMetadata(); metaMessage.hand.position = AgentHand.transform.position; metaMessage.hand.localPosition = AgentHand.transform.localPosition; metaMessage.hand.rotation = AgentHand.transform.eulerAngles; metaMessage.hand.localRotation = AgentHand.transform.localEulerAngles; // EXTRAS metaMessage.reachablePositions = reachablePositions; metaMessage.flatSurfacesOnGrid = flatten3DimArray(flatSurfacesOnGrid); metaMessage.distances = flatten2DimArray(distances); metaMessage.normals = flatten3DimArray(normals); metaMessage.isOpenableGrid = flatten2DimArray(isOpenableGrid); metaMessage.segmentedObjectIds = segmentedObjectIds; metaMessage.objectIdsInBox = objectIdsInBox; metaMessage.actionIntReturn = actionIntReturn; metaMessage.actionFloatReturn = actionFloatReturn; metaMessage.actionFloatsReturn = actionFloatsReturn; metaMessage.actionStringsReturn = actionStringsReturn; metaMessage.actionVector3sReturn = actionVector3sReturn; if (alwaysReturnVisibleRange) { metaMessage.visibleRange = visibleRange(); } // Resetting things reachablePositions = new Vector3[0]; flatSurfacesOnGrid = new float[0, 0, 0]; distances = new float[0, 0]; normals = new float[0, 0, 0]; isOpenableGrid = new bool[0, 0]; segmentedObjectIds = new string[0]; objectIdsInBox = new string[0]; actionIntReturn = 0; actionFloatReturn = 0.0f; actionFloatsReturn = new float[0]; actionStringsReturn = new string[0]; actionVector3sReturn = new Vector3[0]; return(metaMessage); }