basic_robotics.interfaces.ros_bridge module

Implement communications from Basic-Robotics to ROS 1 and ROS 2.

This is a very basic implementation of communications, and may be slower than more tightly integrated methods. This is as planned, as the intent is simply to provide a basic interface that can be used without much effort. It is expected that those who would desire a more tight integration (such as multithreaded pub/sub) would know how to enable such features on their own, and would have no need of this bridging module on its own.

class basic_robotics.interfaces.ros_bridge.ROSPub(name: str, node_type)[source]

Bases: object

Create a new ROS Publisher Instance.

__init__(name: str, node_type) → ROSPub[source]

Create a new ROS Publisher Instance.

Parameters:
  • name (str) – Name of the publisher

  • node_type (Any) – Datatype of the publisher

Returns:

ROSPub – New publisher instance.

send(message) → None[source]

Send a message.

Parameters:

message (Any) – Message data to send.

class basic_robotics.interfaces.ros_bridge.ROS1Pub(name, node_type)[source]

Bases: ROSPub

Create a new ROS1 Publisher Instance.

__init__(name, node_type)[source]

Create a new ROS1 Publisher Instance.

Parameters:
  • name (str) – Name of the publisher

  • node_type (Any) – Datatype of the publisher

Returns:

ROS1Pub – New publisher instance.

send(message)[source]

Send a message.

Parameters:

message (Any) – Message data to send.

class basic_robotics.interfaces.ros_bridge.ROS2Pub(name: str, node_type, host_node: ROS2Bridge)[source]

Bases: ROSPub

Create a new ROS2 Publisher Instance.

__init__(name: str, node_type, host_node: ROS2Bridge) → ROS2Pub[source]

Create a new ROS2 Publisher Instance.

Parameters:
  • name (str) – Name of the publisher

  • node_type (Any) – Datatype of the publisher

  • host_node (ROS2Bridge) – Reference to the ROS2 Bridge Node host.

Returns:

ROS2Pub – New publisher instance.

send(message) → None[source]

Send a message.

Parameters:

message (Any) – Message data to send.

class basic_robotics.interfaces.ros_bridge.ROSSub(name, node_type, host_node, call_back=None)[source]

Bases: object

Create a new ROS Subscriber Handle.

__init__(name, node_type, host_node, call_back=None)[source]

Create a new ROS Subscriber Handle.

Parameters:
  • name (str) – Name of the Subscription Node

  • node_type (Any) – Message type of the subscription node

  • call_back (Any, optional) – Callback function for subscriber. Defaults to None.

Returns:

ROSSub – New ROS2 Subscriber Handle.

setCallBack(call_back) → None[source]

Set callback function to external handle.

Parameters:

call_back (Any) – External function handle.

callBack(data) → None[source]

Execute default callback on most recent data.

Parameters:

data (Any) – data from Ros subscriber.

getUpdate()[source]

Get the most recent data.

Returns:

Any – Most recent data.

class basic_robotics.interfaces.ros_bridge.ROS1Sub(name: str, node_type, call_back=None)[source]

Bases: ROSSub

Create a new ROS1 Subscriber Handle.

__init__(name: str, node_type, call_back=None) → ROS1Sub[source]

Create a new ROS1 Subscriber Handle.

Parameters:
  • name (str) – Name of the Subscription Node

  • node_type (Any) – Message type of the subscription node

  • call_back (Any, optional) – Callback function for subscriber. Defaults to None.

Returns:

ROS1Sub – New ROS2 Subscriber Handle.

class basic_robotics.interfaces.ros_bridge.ROS2Sub(name: str, node_type, host_node: ROS2Bridge, call_back=None)[source]

Bases: ROSSub

Create a new ROS2 Subscriber Handle.

__init__(name: str, node_type, host_node: ROS2Bridge, call_back=None) → ROS2Sub[source]

Create a new ROS2 Subscriber Handle.

Parameters:
  • name (str) – Name of the Subscription Node

  • node_type (Any) – Message type of the subscription node

  • host_node (ROS2Bridge) – Instance of ROS2Bridge inheriting (NODE) properties.

  • call_back (Any, optional) – Callback function for subscriber. Defaults to None.

Returns:

ROS2Sub – New ROS2 Subscriber Handle.

Bases: object

Create a new Uplink from a function to a ROS topic.

__init__(pub: ROSPub, call) → Uplink[source]

Create a new Uplink from a function to a ROS topic.

Parameters:
  • pub (ROSPub) – Ros topic subscriber

  • call (Any) – method call to populate

Returns:

Uplink – New Uplink

update() → None[source]

Update the uplink’s internal publisher.

Bases: object

Create a downlink from a ROS topic to a function.

__init__(sub: ROSSub, call) → Downlink[source]

Create a new downlink from a ROS topic to a function.

Parameters:
  • sub (ROSSub) – Ros topic subscriber

  • call (Any) – method call to populate

Returns:

Downlink – New Downlink

update()[source]

Update the downlink’s internal subscriber.

Returns:

Any – Most recent data.

class basic_robotics.interfaces.ros_bridge.ROSBridge(name='faserNode', rate=10)[source]

Bases: object

Create a bridge between Basic Robotics and ROS.

__init__(name='faserNode', rate=10)[source]

Create a new ROSBridge instance.

Parameters:
  • name (str, optional) – Name of this Bridge Node. Defaults to ‘faserNode’.

  • rate (int, optional) – Updates per second. Defaults to 10.

newPub(name, node_type)[source]

Create a new Publisher handle.

Parameters:
  • name (str) – Name of the publisher.

  • node_type (Any) – Message type of the publisher.

Returns:

ROSPub – New Publisher node.

newSub(name, node_type, func)[source]

Create a new Subscriber handle.

Parameters:
  • name (str) – Name of the subscriber

  • node_type (Any) – Message type of the subscriber

  • func (Any) – Function handler for subscriber to bind to

Returns:

ROSSub – New Subscriber Node

Bind a new uplink to the bridge, pulling data from a function and publishing over ROS.

Parameters:
  • name (str) – Name of the upload handle.

  • node_type (Any) – Datatype for the upload handle.

  • func (Any) – Function handle to hold on to.

Bind a new downlink to the bridge, pulling data from ROS and calling a function.

Parameters:
  • name (str) – Name of download handle.

  • node_type (Any) – Datatype for the download handle.

  • func (Any) – Function to hold on to.

spin()[source]

Start a continous update cycle.

class basic_robotics.interfaces.ros_bridge.ROS2Bridge(*args: Any, **kwargs: Any)[source]

Bases: Node, ROSBridge

Create a bridge between Basic Robotics and ROS 2.

__init__(name: str = 'faserNode', rate: int = 10)[source]

Create a new ROS2 Bridge instance.

Parameters:
  • name (str, optional) – Name of this Bridge Node. Defaults to ‘faserNode’.

  • rate (int, optional) – Updates per second. Defaults to 10.

newPub(name: str, node_type) → ROS2Pub[source]

Create a new Publisher handle.

Parameters:
  • name (str) – Name of the publisher.

  • node_type (Any) – Message type of the publisher.

Returns:

ROS2Pub – New Publisher node.

newSub(name: str, node_type, func) → ROS2Sub[source]

Create a new Subscriber handle.

Parameters:
  • name (str) – Name of the subscriber

  • node_type (Any) – Message type of the subscriber

  • func (Any) – Function handler for subscriber to bind to

Returns:

ROS2Sub – New Subscriber Node

spin()[source]

Start a continous update cycle.

class basic_robotics.interfaces.ros_bridge.ROS1Bridge(name: str = 'faserNode', rate: int = 10)[source]

Bases: ROSBridge

Create a bridge between Basic Robotics and ROS 1.

__init__(name: str = 'faserNode', rate: int = 10) → ROSBridge[source]

Create a new ROS1 Bridge instance.

Parameters:
  • name (str, optional) – Name of this Bridge Node. Defaults to ‘faserNode’.

  • rate (int, optional) – Updates per second. Defaults to 10.

newPub(name: str, node_type) → ROS1Pub[source]

Create a new Publisher handle.

Parameters:
  • name (str) – Name of the publisher.

  • node_type (Any) – Message type of the publisher.

Returns:

ROS1Pub – New Publisher node.

newSub(name: str, node_type, func) → ROS1Sub[source]

Create a new Subscriber handle.

Parameters:
  • name (str) – Name of the subscriber

  • node_type (Any) – Message type of the subscriber

  • func (Any) – Function handler for subscriber to bind to

Returns:

ROS1Sub – New Subscriber Node

spin() → None[source]

Start a continous update cycle.

basic_robotics.interfaces.ros_bridge.makeROSBridge(node_name: str, node_rate: int = 10, ros_ver: int = 1, exargs=None) → ROSBridge[source]

Make a new ROS Bridge.

Parameters:
  • node_name (string) – Name of this ROS node.

  • node_rate (int, optional) – updates per second. Defaults to 10.

  • ros_ver (int, optional) – ROS Bridge version to build. Defaults to 1.

  • exargs (Any, optional) – Extra arguments for ROS2. Defaults to None.

Returns:

ROSbridge – New ROS Bridging Function

basic_robotics.interfaces.ros_bridge.getMsgHandle(ros_ver: int = 1)[source]

Get a handle to this ROS version’s form of std_msg.msg.

Parameters:

ros_ver (int, optional) – ROS Version. Defaults to 1.

Returns:

std_msg.msg – ROS message types

basic_robotics.interfaces.ros_bridge.getRosHandle(ros_ver: int = 1)[source]

Return a handle to the ROS python installation.

Parameters:

ros_ver (int, optional) – ROS Version to return. Defaults to 1.

Returns:

Ros Handle – Handle to a ROS installation.