# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A single scan from a planar laser range-finder
class LaserScan(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = LaserScan()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsLaserScan(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # LaserScan
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Timestamp of scan
    # LaserScan
    def Timestamp(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from .Time import Time
            obj = Time()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Frame of reference
    # LaserScan
    def FrameId(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Origin of scan relative to frame of reference; points are positioned in the x-y plane relative to this origin; angles are interpreted as counterclockwise rotations around the z axis with 0 rad being in the +x direction
    # LaserScan
    def Pose(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Pose import Pose
            obj = Pose()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Bearing of first point, in radians
    # LaserScan
    def StartAngle(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Bearing of last point, in radians
    # LaserScan
    def EndAngle(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Distance of detections from origin; assumed to be at equally-spaced angles between `start_angle` and `end_angle`
    # LaserScan
    def Ranges(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Float64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
        return 0

    # LaserScan
    def RangesAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # LaserScan
    def RangesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LaserScan
    def RangesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0

    # Intensity of detections
    # LaserScan
    def Intensities(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Float64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
        return 0

    # LaserScan
    def IntensitiesAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # LaserScan
    def IntensitiesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LaserScan
    def IntensitiesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        return o == 0

def LaserScanStart(builder): builder.StartObject(7)
def Start(builder):
    return LaserScanStart(builder)
def LaserScanAddTimestamp(builder, timestamp): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(timestamp), 0)
def AddTimestamp(builder, timestamp):
    return LaserScanAddTimestamp(builder, timestamp)
def LaserScanAddFrameId(builder, frameId): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(frameId), 0)
def AddFrameId(builder, frameId):
    return LaserScanAddFrameId(builder, frameId)
def LaserScanAddPose(builder, pose): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(pose), 0)
def AddPose(builder, pose):
    return LaserScanAddPose(builder, pose)
def LaserScanAddStartAngle(builder, startAngle): builder.PrependFloat64Slot(3, startAngle, 0.0)
def AddStartAngle(builder, startAngle):
    return LaserScanAddStartAngle(builder, startAngle)
def LaserScanAddEndAngle(builder, endAngle): builder.PrependFloat64Slot(4, endAngle, 0.0)
def AddEndAngle(builder, endAngle):
    return LaserScanAddEndAngle(builder, endAngle)
def LaserScanAddRanges(builder, ranges): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(ranges), 0)
def AddRanges(builder, ranges):
    return LaserScanAddRanges(builder, ranges)
def LaserScanStartRangesVector(builder, numElems): return builder.StartVector(8, numElems, 8)
def StartRangesVector(builder, numElems):
    return LaserScanStartRangesVector(builder, numElems)
def LaserScanAddIntensities(builder, intensities): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(intensities), 0)
def AddIntensities(builder, intensities):
    return LaserScanAddIntensities(builder, intensities)
def LaserScanStartIntensitiesVector(builder, numElems): return builder.StartVector(8, numElems, 8)
def StartIntensitiesVector(builder, numElems):
    return LaserScanStartIntensitiesVector(builder, numElems)
def LaserScanEnd(builder): return builder.EndObject()
def End(builder):
    return LaserScanEnd(builder)