示例#1
0
    protected override void OnUpdate()
    {
        _nextUpdate -= Time.DeltaTime;
        if (_nextUpdate > Time.DeltaTime / 2)
        {
            return;
        }

        _nextUpdate = _updateTime + _nextUpdate;

        EntityQuery query = GetEntityQuery(ComponentType.ReadOnly <RobotId>());

        int size    = query.CalculateEntityCount();
        int arrayId = 0;

        var robotsInformation = new RosMessageTypes.Simulation.PoseRobot[size];

        Entities.WithoutBurst().ForEach((in RobotId robotId, in Rotation rotation, in Translation translation) => {
            var pos = ((Vector3)translation.Value).To <FLU>();
            var rot = ((Quaternion)rotation.Value).To <FLU>();

            var robotPos = new RosMessageTypes.Geometry.Point(pos.x, pos.y, pos.z);
            var robotRot = new RosMessageTypes.Geometry.Quaternion(rot.x, rot.y, rot.z, rot.w);

            var robotInfo = new RosMessageTypes.Simulation.PoseRobot(
                robotId.Value,
                new RosMessageTypes.Geometry.Pose(robotPos, robotRot)
                );

            if (arrayId < size && arrayId >= 0)
            {
                robotsInformation[arrayId] = robotInfo;
                arrayId++;
            }
        }).Run();