コード例 #1
0
        public virtual void Register(IBridgePlugin plugin)
        {
            // point cloud is special, as we use special writer for performance reasons
            plugin.AddType <PointCloudData>(RosUtils.GetMessageType <Ros.PointCloud2>());
            plugin.AddPublisherCreator <PointCloudData>(
                (instance, topic) =>
            {
                var rosInstance = instance as RosBridgeInstance;
                rosInstance.AddPublisher <Ros.PointCloud2>(topic);
                var writer = new RosPointCloudWriter(rosInstance, topic);
                return(new Publisher <PointCloudData>((data, completed) => writer.Write(data, completed)));
            }
                );

            RegPublisher <ImageData, Ros.CompressedImage>(plugin, Conversions.ConvertFrom);
            RegPublisher <CameraInfoData, Ros.CameraInfo>(plugin, Conversions.ConvertFrom);
            RegPublisher <Detected2DObjectData, Lgsvl.Detection2DArray>(plugin, Conversions.ConvertFrom);
            RegPublisher <ClockData, Ros.Clock>(plugin, Conversions.ConvertFrom);

            RegSubscriber <VehicleStateData, Lgsvl.VehicleStateDataRos>(plugin, Conversions.ConvertTo);
            RegSubscriber <Detected2DObjectArray, Lgsvl.Detection2DArray>(plugin, Conversions.ConvertTo);
            RegSubscriber <Detected3DObjectArray, Lgsvl.Detection3DArray>(plugin, Conversions.ConvertTo);

            // std_srvs/Empty
            RegService <EmptySrv, Ros.Empty, EmptySrv, Ros.Empty>(plugin, Conversions.ConvertTo, Conversions.ConvertFrom);

            // std_srvs/SetBool
            RegService <SetBoolSrv, Ros.SetBool, SetBoolSrv, Ros.SetBoolResponse>(plugin, Conversions.ConvertTo, Conversions.ConvertFrom);

            // std_srvs/Trigger
            RegService <EmptySrv, Ros.Empty, TriggerSrv, Ros.Trigger>(plugin, Conversions.ConvertTo, Conversions.ConvertFrom);
        }
コード例 #2
0
        public void Register(IBridgePlugin plugin)
        {
            // point cloud is special, as we use special writer for performance reasons
            plugin.AddType <PointCloudData>(Ros2Utils.GetMessageType <Ros.PointCloud2>());
            plugin.AddPublisherCreator(
                (instance, topic) =>
            {
                var ros2Instance = instance as Ros2BridgeInstance;
                ros2Instance.AddPublisher <Ros.PointCloud2>(topic);
                var writer = new Ros2PointCloudWriter(ros2Instance, topic);
                return(new Publisher <PointCloudData>((data, completed) => writer.Write(data, completed)));
            }
                );

            RegPublisher <ImageData, Ros.CompressedImage>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <Detected3DObjectData, Lgsvl.Detection3DArray>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <Detected2DObjectData, Lgsvl.Detection2DArray>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <SignalDataArray, Lgsvl.SignalArray>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <CanBusData, Lgsvl.CanBusData>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <UltrasonicData, Lgsvl.Ultrasonic>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <GpsData, Ros.NavSatFix>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <GpsOdometryData, Ros.Odometry>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <ImuData, Ros.Imu>(plugin, Ros2Conversions.ConvertFrom);
            RegPublisher <ClockData, Ros.Clock>(plugin, Ros2Conversions.ConvertFrom);

            RegSubscriber <VehicleStateData, Lgsvl.VehicleStateData>(plugin, Ros2Conversions.ConvertTo);
            RegSubscriber <VehicleControlData, Lgsvl.VehicleControlData>(plugin, Ros2Conversions.ConvertTo);
            RegSubscriber <Detected2DObjectArray, Lgsvl.Detection2DArray>(plugin, Ros2Conversions.ConvertTo);
            RegSubscriber <Detected3DObjectArray, Lgsvl.Detection3DArray>(plugin, Ros2Conversions.ConvertTo);
        }
コード例 #3
0
        public override void Register(IBridgePlugin plugin)
        {
            base.Register(plugin);

            // gps data is special, because it actually sends two Ros.Sentence messages for each data point from simulator
            plugin.AddType <GpsData>(RosUtils.GetMessageType <Ros.Sentence>());
            plugin.AddPublisherCreator(
                (instance, topic) =>
            {
                var rosInstance = instance as RosBridgeInstance;
                rosInstance.AddPublisher <Ros.Sentence>(topic);
                var writer = new RosNmeaWriter(rosInstance, topic);
                return(new Publisher <GpsData>((data, completed) => writer.Write(data, completed)));
            }
                );

            RegPublisher <CanBusData, Lgsvl.CanBusDataRos>(plugin, Conversions.RosConvertFrom);
            RegPublisher <DetectedRadarObjectData, Lgsvl.DetectedRadarObjectArray>(plugin, Conversions.RosConvertFrom);
            RegPublisher <GpsOdometryData, Ros.Odometry>(plugin, Conversions.ConvertFrom);
            RegPublisher <ImuData, Ros.Imu>(plugin, Conversions.ConvertFrom);
            RegPublisher <Detected3DObjectData, Lgsvl.Detection3DArray>(plugin, Conversions.ConvertFrom);
            RegPublisher <SignalDataArray, Lgsvl.SignalArray>(plugin, Conversions.ConvertFrom);
            RegPublisher <UltrasonicData, Lgsvl.Ultrasonic>(plugin, Conversions.ConvertFrom);
            RegPublisher <VehicleOdometryData, Lgsvl.VehicleOdometry>(plugin, Conversions.ConvertFrom);

            RegSubscriber <VehicleControlData, Lgsvl.VehicleControlDataRos>(plugin, Conversions.ConvertTo);
        }
コード例 #4
0
        public void Register(IBridgePlugin plugin)
        {
            // here we need to register which types to we support for this bridge, we support all
            // simulator default types from Simulator.Bridge.Data namespace that can be published

            // we will convert all types to json as C# string that will be written to file
            // which means we do not need special converison function
            RegPublisher <CanBusData, string>(plugin, null);
            RegPublisher <ClockData, string>(plugin, null);
            RegPublisher <Detected2DObjectData, string>(plugin, null);
            RegPublisher <Detected3DObjectData, string>(plugin, null);
            RegPublisher <DetectedRadarObjectData, string>(plugin, null);
            RegPublisher <GpsData, string>(plugin, null);
            RegPublisher <GpsOdometryData, string>(plugin, null);
            RegPublisher <ImageData, string>(plugin, null);
            RegPublisher <ImuData, string>(plugin, null);
            RegPublisher <CorrectedImuData, string>(plugin, null);
            RegPublisher <PointCloudData, string>(plugin, null);
            RegPublisher <SignalDataArray, string>(plugin, null);
            RegPublisher <VehicleOdometryData, string>(plugin, null);

            // what subscribers we support
            plugin.AddType <VehicleControlData>(typeof(VehicleControlData).Name);
            plugin.AddSubscriberCreator <VehicleControlData>((instance, topic, callback) => { });
        }
コード例 #5
0
 public void RegSubscriber <DataType, BridgeType>(IBridgePlugin plugin, Func <BridgeType, DataType> converter)
 {
     plugin.AddType <DataType>(Ros2Utils.GetMessageType <BridgeType>());
     plugin.AddSubscriberCreator <DataType>(
         (instance, topic, callback) => (instance as Ros2BridgeInstance).AddSubscriber <BridgeType>(topic,
                                                                                                    rawData => callback(converter(Ros2Serialization.Unserialize <BridgeType>(rawData)))
                                                                                                    )
         );
 }
コード例 #6
0
 public void RegSubscriber <DataType, BridgeType>(IBridgePlugin plugin, Func <BridgeType, DataType> converter)
 {
     plugin.AddType <DataType>(typeof(BridgeType).Name);
     plugin.AddSubscriberCreator <DataType>(
         (instance, topic, callback) => (instance as CyberBridgeInstance).AddSubscriber <BridgeType>(topic,
                                                                                                     rawData => callback(converter(CyberSerialization.Unserialize <BridgeType>(rawData)))
                                                                                                     )
         );
 }
コード例 #7
0
 public void RegPublisher <DataType, BridgeType>(IBridgePlugin plugin, Func <DataType, BridgeType> converter)
 {
     plugin.AddType <DataType>(Ros2Utils.GetMessageType <BridgeType>());
     plugin.AddPublisherCreator(
         (instance, topic) =>
     {
         var ros2Instance = instance as Ros2BridgeInstance;
         ros2Instance.AddPublisher <BridgeType>(topic);
         var writer = new Ros2Writer <BridgeType>(ros2Instance, topic);
         return(new Publisher <DataType>((data, completed) => writer.Write(converter(data), completed)));
     }
         );
 }
コード例 #8
0
 public void RegPublisher <DataType, BridgeType>(IBridgePlugin plugin, Func <DataType, BridgeType> converter)
 {
     plugin.AddType <DataType>(typeof(BridgeType).Name);
     plugin.AddPublisherCreator(
         (instance, topic) =>
     {
         var cyberInstance = instance as CyberBridgeInstance;
         cyberInstance.AddPublisher <BridgeType>(topic);
         var writer = new CyberWriter <BridgeType>(cyberInstance, topic);
         return(new Publisher <DataType>((data, completed) => writer.Write(converter(data), completed)));
     }
         );
 }
コード例 #9
0
        // this function can be called not only by our "Register" method, but also
        // from custom sensor plugins
        public void RegPublisher <DataType, BridgeType>(IBridgePlugin plugin, Func <DataType, BridgeType> converter)
        {
            // register "native name" for data type, we just use name of original tpye
            plugin.AddType <DataType>(typeof(DataType).Name);

            // then we provide delegate to create publishers on specific topic
            // writing functionality is delegated to actual bridge instance
            plugin.AddPublisherCreator(
                (instance, topic) =>
            {
                var loggingInstance = instance as LoggingBridgeInstance;

                // as we have very simple bridge that does not require "conversion", we'll just call
                // serializer directly on simulator data types. For real bridges you would need to convert data
                // types (DataType) to something that your native bridge implementation supports (BridgeType)
                ;
                return(new Publisher <DataType>(
                           (data, completed) => loggingInstance.Write(typeof(DataType).Name, topic, JsonConvert.SerializeObject(data, jsonSettings), completed)));
            }
                );
        }