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); }
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); }
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); }
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))); } ); }
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))); } ); }
// 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))); } ); }