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) => { }); }
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))) ) ); }
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))) ) ); }