Broadcast Dowsampler
- class RobotRaconteur.BroadcastDownsampler(context, default_downsample=0)
Downsampler to manage rate of packets sent to client
PipeBroadcaster and WireBroadcaster by default sends packets to all clients when a pipe packet is sent or the wire value is changed. The updates typically happen within a sensor or control loop, with the rate set by the specific device producing the updates. Some clients may require less frequent data, and may run in to bandwidth or processing issues if the data is sent at the full update rate. The BroadcastDownsampler is used to implement broadcaster predicates that will drop packets. Clients specify how many packets they want dropped between each packet sent. For instance, a downsample of 0 means that no packets are dropped. A downsample of 1 will drop every other packet. A downsample of two will drop 2 packets between sending 1 packet, etc. The downsample level for each client is set using SetClientDownsample(). This should be made available to the client using a property member.
PipeBroadcaster and WireBroadcaster must be added to the downsampler using AddPipeBroadcaster() and AddWireBroadcaster(), respectively. It is recommended that these functions be called within the RRServiceObjectInit(context,servicepath) function thit is called by the node when a service object is initialized.
BeginStep() and EndStep() must be called for each iteration of the broadcasting loop. Use BroadcastDownsamplerStep for automatic management in the loop.
See com.robotraconteur.isoch.IsochDevice for the standard use of downsampling.
- AddPipeBroadcaster(broadcaster)
Add a PipeBroadcaster to the downsampler
Sets the predicate of the broadcaster to this downsampler
- Parameters:
broadcaster (PipeBroadcaster) – The pipe broadcaster to add
- AddWireBroadcaster(broadcaster)
Add a WireBroadcaster to the downsampler
Sets the predicate of the broadcaster to this downsampler
- Parameters:
broadcaster (PipeBroadcaster) – The pipe broadcaster to add
- BeginStep()
Begin the update loop step
Use BroadcastDownsamplerStep for automatic stepping
- EndStep()
End the update loop step
Use BroadcastDownsamplerStep for automatic stepping
- GetClientDownsample(ep)
Get the downsample for the specified client
- Parameters:
ep (int) – The endpoint ID of the client
- Returns:
The downsample
- Return type:
int
- SetClientDownsample(ep, downsample)
Set the downsample for the specified client
- Parameters:
ep (int) – The endpoint ID of the client
downsample (int) – The desired downsample
- class RobotRaconteur.BroadcastDownsamplerStep(downsampler)
Class for automatic broadcast downsampler stepping
Helper class to automate BroadcastDownsampler stepping. Calls BroadcastDownsampler.BeginStep() on construction, and BroadcastDownsampler.EndStep() on destruction.
Use with a “with” block