Пример #1
0
        private RefList CallDic(SystemDic item)
        {
            //Discarded unreachable code: IL_0002
            //IL_0003: Incompatible stack heights: 0 vs 1
            item._0001(-3, out PredicateIssuerMock reg);
            BaseClassSpec baseClassSpec = new BaseClassSpec(reg);

            baseClassSpec._0002();
            Guid guid     = baseClassSpec._0001();
            int  num      = baseClassSpec._0002();
            int  attr_end = baseClassSpec._0003();
            int  num2     = baseClassSpec._0001();

            if (guid == IndexerInstance._TokenInstance)
            {
                return(new RefList(num2, attr_end, num));
            }
            if (guid == IndexerInstance.baseInstance)
            {
                return(RefList.ListDic(num2, num));
            }
            string arg = BridgeInstance.ResolveError(typeof(IndexerInstance), guid);

            throw new InvalidDataException($"Unsupported audio sub Type {arg}");
        }
Пример #2
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            Badge.OnModelCreating(builder);
            User.OnModelCreating(builder);

            // module section
            Module.OnModelCreating(builder);
            Lab.OnModelCreating(builder);
            LabVm.OnModelCreating(builder);
            UserModule.OnModelCreating(builder);
            // user module section
            UserModule.OnModelCreating(builder);
            UserLab.OnModelCreating(builder);
            UserLabVm.OnModelCreating(builder);
            // hypervisor
            Hypervisor.OnModelCreating(builder);
            HypervisorNode.OnModelCreating(builder);
            // configure many to many relationship
            UserUserModule.OnModelCreating(builder);
            ContactEmail.OnModelCreating(builder);
            BridgeInstance.OnModelCreating(builder);
            VmInterfaceTemplate.OnModelCreating(builder);
            VmInterfaceInstance.OnModelCreating(builder);
            BridgeTemplate.OnModelCreating(builder);
            VmTemplate.OnModelCreating(builder);
        }
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            var subscriber = BridgeMessageDispatcher.Instance.GetSynchronousSubscriber <VehicleControlData>(data =>
            {
                if (!IsControlReceived)
                {
                    IsControlReceived = true;

                    if (ApiManager.Instance != null)
                    {
                        var jsonData = new JSONObject();
                        ApiManager.Instance.AddCustom(transform.parent.gameObject, "checkControl", jsonData);
                    }
                }

                controlData       = data;
                LastControlUpdate = SimulatorManager.Instance.CurrentTime;

                if (double.IsInfinity(data.Acceleration.GetValueOrDefault()) || double.IsInfinity(data.Braking.GetValueOrDefault()) ||
                    double.IsNaN(data.Acceleration.GetValueOrDefault()) || double.IsNaN(data.Braking.GetValueOrDefault()))
                {
                    return;
                }

                var timeStamp = data.TimeStampSec.GetValueOrDefault();
                var dt        = (float)(timeStamp - LastTimeStamp);
                LastTimeStamp = timeStamp;

                Debug.Assert(data.Acceleration.GetValueOrDefault() >= 0 && data.Acceleration.GetValueOrDefault() <= 1);
                Debug.Assert(data.Braking.GetValueOrDefault() >= 0 && data.Braking.GetValueOrDefault() <= 1);
                var linearAccel = AccelerationInputCurve.Evaluate(data.Acceleration.GetValueOrDefault()) - BrakeInputCurve.Evaluate(data.Braking.GetValueOrDefault());

                var steeringTarget = -data.SteerTarget.GetValueOrDefault();
                var steeringAngle  = Controller.SteerInput;
                var sgn            = Mathf.Sign(steeringTarget - steeringAngle);
                var steeringRate   = data.SteerRate.GetValueOrDefault() * sgn;

                steeringAngle += steeringRate * dt;
                if (sgn != steeringTarget - steeringAngle)  // prevent oversteering
                {
                    steeringAngle = steeringTarget;
                }

                ADSteerInput = steeringAngle;
                ADAccelInput = linearAccel;

                if (data.CurrentGear == GearPosition.Reverse)
                {
                    Dynamics.ShiftReverseAutoGearBox();
                }
                else if (data.CurrentGear == GearPosition.Drive)
                {
                    Dynamics.ShiftFirstGear();
                }
            });

            bridge.AddSubscriber(Topic, subscriber);
        }
Пример #4
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = bridge.AddPublisher <ImageData>(Topic);
     if (!string.IsNullOrEmpty(CameraInfoTopic))
     {
         CameraInfoPublish = bridge.AddPublisher <CameraInfoData>(CameraInfoTopic);
     }
 }
Пример #5
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = Bridge.AddPublisher <ImuData>(Topic);
     if (!string.IsNullOrEmpty(CorrectedTopic))
     {
         CorrectedWriter = Bridge.AddPublisher <CorrectedImuData>(CorrectedTopic);
     }
 }
Пример #6
0
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            if (bridge.Plugin.GetBridgeNameAttribute().Name == "CyberRT")
            {
                return;
            }

            Bridge  = bridge;
            Publish = bridge.AddPublisher <VehicleOdometryData>(Topic);
        }
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            if (bridge.Plugin.GetBridgeNameAttribute().Type == "ROS")
            {
                bridge.AddSubscriber <VehicleControlData>(Topic, data =>
                {
                    if (Time.timeScale == 0f)
                    {
                        return;
                    }

                    controlData       = data;
                    LastControlUpdate = SimulatorManager.Instance.CurrentTime;

                    float wheelAngle = data.SteerAngle.GetValueOrDefault();
                    wheelAngle       = UnityEngine.Mathf.Clamp(wheelAngle, -Dynamics.MaxSteeringAngle, Dynamics.MaxSteeringAngle);
                    var k            = (float)(wheelAngle + Dynamics.MaxSteeringAngle) / (Dynamics.MaxSteeringAngle * 2);

                    ADSteerInput = UnityEngine.Mathf.Lerp(-1f, 1f, k);
                    ADAccelInput = data.Acceleration.GetValueOrDefault() - data.Braking.GetValueOrDefault();
                });
            }
            else if (bridge.Plugin.GetBridgeNameAttribute().Type == "ROS2")
            {
                bridge.AddSubscriber <VehicleControlData>(Topic, data =>
                {
                    if (Time.timeScale == 0f)
                    {
                        return;
                    }

                    controlData       = data;
                    LastControlUpdate = SimulatorManager.Instance.CurrentTime;

                    float wheelAngle = data.SteerAngle.GetValueOrDefault();

                    ADSteerInput = wheelAngle;
                    ADAccelInput = data.Acceleration.GetValueOrDefault() - data.Braking.GetValueOrDefault();

                    if (data.TargetGear == GearPosition.Reverse)
                    {
                        Dynamics.ShiftReverseAutoGearBox();
                    }
                    else if (data.TargetGear == GearPosition.Drive)
                    {
                        Dynamics.ShiftFirstGear();
                    }
                });
            }
        }
Пример #8
0
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            Bridge = bridge;
            Bridge.AddSubscriber <VehicleControlData>(Topic, data =>
            {
                if (Time.timeScale == 0f)
                {
                    return;
                }

                LastControlUpdate = SimulatorManager.Instance.CurrentTime;
                ADSteerInput      = data.SteerInput.GetValueOrDefault();
                InferenceTime     = data.TimeStampSec.GetValueOrDefault();

                ControlMessages++;
                TotalInferenceTime  += InferenceTime;
                AverageInferenceTime = TotalInferenceTime / (float)ControlMessages;
            });
        }
Пример #9
0
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            Bridge = bridge;

            if (MessageType == MessageTypes.LaserScan)
            {
                if (LaserCount == 1)
                {
                    LaserScanPublish = bridge.AddPublisher <LaserScanData>(Topic);
                }
                else
                {
                    Debug.LogError("LaserScan message type is only valid when LaserCount is 1. Falling back to PointCloud2.");
                    PointCloudPublish = bridge.AddPublisher <PointCloudData>(Topic);
                }
            }
            else
            {
                PointCloudPublish = bridge.AddPublisher <PointCloudData>(Topic);
            }
        }
Пример #10
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     //
 }
Пример #11
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = bridge.AddPublisher <PointCloudData>(Topic);
 }
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = bridge.AddPublisher <VehicleOdometryData>(Topic);
 }
Пример #13
0
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            bridge.AddSubscriber <VehicleStateData>(Topic, data =>
            {
                if (Time.timeScale == 0f)
                {
                    return;
                }

                if (data != null)
                {
                    if (StateData.Blinker != data.Blinker)
                    {
                        if (data.Blinker == 0)
                        {
                            if (Actions.LeftTurnSignal)
                            {
                                Actions.LeftTurnSignal = false;
                            }
                            if (Actions.RightTurnSignal)
                            {
                                Actions.RightTurnSignal = false;
                            }
                            if (Actions.HazardLights)
                            {
                                Actions.HazardLights = false;
                            }
                        }
                        else if (data.Blinker == 1)
                        {
                            Actions.LeftTurnSignal = true;
                        }
                        else if (data.Blinker == 2)
                        {
                            Actions.RightTurnSignal = true;
                        }
                        else if (data.Blinker == 3)
                        {
                            Actions.HazardLights = true;
                        }
                    }
                    if (StateData.HeadLight != data.HeadLight)
                    {
                        if (data.HeadLight == 0)
                        {
                            Actions.CurrentHeadLightState = HeadLightState.OFF;
                        }
                        else if (data.HeadLight == 1)
                        {
                            Actions.CurrentHeadLightState = HeadLightState.LOW;
                        }
                        else if (data.HeadLight == 2)
                        {
                            Actions.CurrentHeadLightState = HeadLightState.HIGH;
                        }
                    }
                    if (StateData.Gear != data.Gear)
                    {
                        if (data.Gear == (byte)GearPosition.Reverse)
                        {
                            Dynamics.ShiftReverseAutoGearBox();
                        }
                        else if (data.Gear == (byte)GearPosition.Drive)
                        {
                            Dynamics.ShiftFirstGear();
                        }
                    }
                    if (StateData.HandBrake != data.HandBrake)
                    {
                        if (data.HandBrake == true)
                        {
                            Dynamics.SetHandBrake(true);
                        }
                        else
                        {
                            Dynamics.SetHandBrake(false);
                        }
                    }

                    StateData = data;
                }
            });
        }
Пример #14
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     // TODO new base class?
 }
Пример #15
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = Bridge.AddPublisher <SignalDataArray>(Topic);
 }
Пример #16
0
 public abstract void OnBridgeSetup(BridgeInstance bridge);
Пример #17
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     bridge.AddSubscriber <Detected3DObjectArray>(Topic, data => Detected = data.Data);
 }
Пример #18
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = Bridge.AddPublisher <GpsInsData>(Topic);
 }
Пример #19
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = Bridge.AddPublisher <Detected2DObjectData>(Topic);
 }
Пример #20
0
 public override void OnBridgeSetup(BridgeInstance bridge)
 {
     Bridge  = bridge;
     Publish = bridge.AddPublisher <UltrasonicData>(Topic);
 }
Пример #21
0
 public void Init(BridgePlugin plugin)
 {
     Bridge = new BridgeInstance(plugin);
 }
Пример #22
0
        public override void OnBridgeSetup(BridgeInstance bridge)
        {
            bridge.AddSubscriber <VehicleControlData>(Topic, data =>
            {
                controlData       = data;
                LastControlUpdate = SimulatorManager.Instance.CurrentTime;

                if (data.Velocity.HasValue) // autoware
                {
                    controlType = ControlType.AutowareAi;
                    if (data.ShiftGearUp || data.ShiftGearDown)
                    {
                        if (data.ShiftGearUp)
                        {
                            Dynamics.GearboxShiftUp();
                        }
                        if (data.ShiftGearDown)
                        {
                            Dynamics.GearboxShiftDown();
                        }

                        ADAccelInput = data.Acceleration.GetValueOrDefault() - data.Braking.GetValueOrDefault(); // converted from lin accel
                        ADSteerInput = data.SteerAngle.GetValueOrDefault();                                      // angle should be in degrees
                    }
                    else
                    {
                        if (Dynamics.Reverse)
                        {
                            return;                   // TODO move?
                        }
                        var linMag   = Mathf.Clamp(Mathf.Abs(data.Velocity.GetValueOrDefault() - ActualLinVel), 0f, 1f);
                        ADAccelInput = ActualLinVel < data.Velocity.GetValueOrDefault() ? linMag : -linMag;
                        ADSteerInput = -Mathf.Clamp(data.SteerAngularVelocity.GetValueOrDefault() / (29 * (float)System.Math.PI / 180), -1f, 1f);
                        //ADASTEC 0.506 radian for 29 degrees
                        //Dividing with 0.506 radian is for normalizing -0.506,+0.506 radians to -1,1 unity values.
                    }
                }
                else if (data.SteerRate.HasValue) // apollo
                {
                    if (double.IsInfinity(data.Acceleration.GetValueOrDefault()) || double.IsInfinity(data.Braking.GetValueOrDefault()) ||
                        double.IsNaN(data.Acceleration.GetValueOrDefault()) || double.IsNaN(data.Braking.GetValueOrDefault()))
                    {
                        return;
                    }

                    controlType   = ControlType.Apollo;
                    var timeStamp = data.TimeStampSec.GetValueOrDefault();
                    var dt        = (float)(timeStamp - LastTimeStamp);
                    LastTimeStamp = timeStamp;

                    Debug.Assert(data.Acceleration.GetValueOrDefault() >= 0 && data.Acceleration.GetValueOrDefault() <= 1);
                    Debug.Assert(data.Braking.GetValueOrDefault() >= 0 && data.Braking.GetValueOrDefault() <= 1);
                    var linearAccel = AccelerationInputCurve.Evaluate(data.Acceleration.GetValueOrDefault()) - BrakeInputCurve.Evaluate(data.Braking.GetValueOrDefault());

                    var steeringTarget = -data.SteerTarget.GetValueOrDefault();
                    var steeringAngle  = Controller.SteerInput;
                    var sgn            = Mathf.Sign(steeringTarget - steeringAngle);
                    var steeringRate   = data.SteerRate.GetValueOrDefault() * sgn;
                    steeringAngle     += steeringRate * dt;

                    if (sgn != steeringTarget - steeringAngle) // to prevent oversteering
                    {
                        steeringAngle = steeringTarget;
                    }

                    ADSteerInput = steeringAngle;
                    ADAccelInput = linearAccel;

                    if (data.CurrentGear == GearPosition.Reverse)
                    {
                        Dynamics.ShiftReverseAutoGearBox();
                    }
                    else if (data.CurrentGear == GearPosition.Drive)
                    {
                        Dynamics.ShiftFirstGear();
                    }
                }
                else if (data.SteerInput.HasValue) // lgsvl
                {
                    controlType  = ControlType.LGSVL;
                    ADSteerInput = data.SteerInput.GetValueOrDefault();
                }
                else if (data.Acceleration.HasValue)
                {
                    controlType  = ControlType.AutowareAuto;
                    ADAccelInput = data.Acceleration.GetValueOrDefault() - data.Braking.GetValueOrDefault();
                    ADSteerInput = data.SteerAngle.GetValueOrDefault();
                }
                else
                {
                    controlType = ControlType.None;
                }
            });
        }