Inverted Pendulum icon Inverted Pendulum — Balancing controller for Sainsmart v3 (and compatible) robots: PID tuning, real‑time telemetry, angle offset, movement and calibration via ARC. Try it →
 

Bus

Share data with the rest of the robot through the Robot Bus: publish messages on topics and read them back, call services that robot skills, ARCx and other programs provide, look up where one frame (a camera, the robot's body) is from another, and record topics to play back later. Messages are JSON, so a script publishes dicts and lists and gets dicts and lists back. The same topics and services are open to robot skills, AI assistants and programs outside ARCx (Python, JavaScript, ROS nodes through the ROS Connector), which connect to the robot's Robot Bus address when it is turned on in Options → Preferences → Robot Bus. Views → Robot Bus shows everything on the bus, live.

Bus.Publish("/my_robot/status", {"state": "patrolling", "lap": 3})

pose = Bus.GetLatest("/arcx/nms/pose")

if pose is not None:
  print("At", pose["x"], pose["y"])

heard = Bus.WaitForMessage("/arcx/speech/recognized", 10000)

if heard is not None:
  Bus.Call("/arcx/speech/say", {"text": "You said " + heard["text"]})

camera = Bus.LookupTransform("base_link", "camera")   # [x, y, z, roll, pitch, yaw]

Where to find it: type Bus. in a Python script, or open the ARCx API view of the script editor and expand Bus


Commands

Command What it does
Bus.Call Calls a service and waits for its answer.
Bus.Exists Checks whether a topic exists.
Bus.GetAge Gets how many seconds ago the latest message on a topic was published.
Bus.GetField Gets one field of the latest message on a topic by its path, such as x or pose.yaw or objects.0.name.
Bus.GetFrames Lists every frame name in the transform tree, sorted.
Bus.GetLatest Gets the latest message published on a topic, as a dict.
Bus.GetRate Gets how many messages per second a topic is receiving right now.
Bus.GetServices Lists the names of every service on the bus, or those a pattern matches.
Bus.GetTopics Lists the names of every topic on the bus, or those a pattern matches.
Bus.LookupTransform Gets where one frame is as seen from another, as [x, y, z, roll, pitch, yaw] in metres and radians.
Bus.Publish Publishes a message on a topic.
Bus.SetTransform Sets where a frame is relative to its parent, such as a camera on the robot.
Bus.StartPlayback Plays a recording back onto the bus with its original timing.
Bus.StartRecording Starts recording topics to a file in ARCx Data\Recordings.
Bus.StopPlayback Stops the playback, if one is running.
Bus.StopRecording Stops the recording being made.
Bus.TransformPoint Converts a point from one frame to another, such as an object the camera sees into the robot's frame.
Bus.WaitForMessage Waits for the next message on a topic.

Details

Bus.Call

Calls a service and waits for its answer. Throws when the call fails or the time runs out, so the reason shows in the script console; wrap it in try and except to carry on instead.

Bus.Call(service)
Bus.Call(service, args)
Bus.Call(service, args, timeoutMs)
Value Type What it is
service str The service name, such as /arcx/speech/say.
args dict Optional. The arguments as a dict, such as {"text": "Hello"}.
timeoutMs float Optional. The longest to wait in milliseconds. 0 or less uses the default of 30 seconds.

Gives back: object. What the service returned.

Bus.Exists

Checks whether a topic exists.

Bus.Exists(topic)
Value Type What it is
topic str The topic name.

Gives back: bool. Whether anyone has published or advertised it.

Bus.GetAge

Gets how many seconds ago the latest message on a topic was published.

Bus.GetAge(topic)
Value Type What it is
topic str The topic name.

Gives back: float. The age in seconds, or -1 when nothing has been published on the topic.

Bus.GetField

Gets one field of the latest message on a topic by its path, such as x or pose.yaw or objects.0.name.

Bus.GetField(topic, path)
Value Type What it is
topic str The topic name, such as /arcx/nms/pose.
path str The field, with dots between levels and numbers for array items.

Gives back: object. The field's value, or None when the topic or field does not exist.

Bus.GetFrames

Lists every frame name in the transform tree, sorted.

Bus.GetFrames()

Gives back: list[str]. The frame names.

Bus.GetLatest

Gets the latest message published on a topic, as a dict.

Bus.GetLatest(topic)
Value Type What it is
topic str The topic name, such as /arcx/nms/pose.

Gives back: object. The message data, or None when nothing has been published on the topic.

Bus.GetRate

Gets how many messages per second a topic is receiving right now.

Bus.GetRate(topic)
Value Type What it is
topic str The topic name.

Gives back: float. The rate in messages per second, or 0 when it is quiet or does not exist.

Bus.GetServices

Lists the names of every service on the bus, sorted, or only those a pattern matches, such as /arcx/recorder/* .

Bus.GetServices()
Bus.GetServices(pattern)
Value Type What it is
pattern str Optional. A pattern: * matches one level, ** any number of levels.

Gives back: list[str]. The service names.

Bus.GetTopics

Lists the names of every topic on the bus, sorted, or only those a pattern matches, such as /arcx/** .

Bus.GetTopics()
Bus.GetTopics(pattern)
Value Type What it is
pattern str Optional. A pattern: * matches one level, ** any number of levels.

Gives back: list[str]. The topic names.

Bus.LookupTransform

Gets where one frame is as seen from another, as [x, y, z, roll, pitch, yaw] in metres and radians. Throws when the frames are not connected.

Bus.LookupTransform(target, sourceFrame)
Value Type What it is
target str The frame to measure from, such as odom.
sourceFrame str The frame being measured, such as camera.

Gives back: list[float]. The position and rotation of sourceFrame in target.

Bus.Publish

Publishes a message on a topic. Every robot skill, script and external program subscribed to the topic receives it, and it becomes the topic's latest message. Naming the type tells others what fields to expect.

Bus.Publish(topic, data)
Bus.Publish(topic, data, type)
Value Type What it is
topic str The topic name, such as /my_robot/status.
data object What to publish: a dict, a list, a number or text.
type str Optional. The message type, such as my_robot/Status.

Bus.SetTransform

Sets where a frame is relative to its parent, such as a camera on the robot, and optionally whether it is fixed (bolted down) or moving. Metres and radians, +X forward, +Y left, +Z up.

Bus.SetTransform(parent, child, x, y, z, roll, pitch, yaw)
Bus.SetTransform(parent, child, x, y, z, roll, pitch, yaw, isStatic)
Value Type What it is
parent str The parent frame, such as base_link.
child str The frame being placed, such as camera.
x float Metres forward of the parent.
y float Metres left of the parent.
z float Metres above the parent.
roll float Rotation about the forward axis in radians.
pitch float Rotation about the left axis in radians; positive tilts down.
yaw float Rotation about the up axis in radians; positive turns left.
isStatic bool Optional. True for something that never moves relative to its parent.

Bus.StartPlayback

Plays a recording back onto the bus with its original timing, or faster or slower.

Bus.StartPlayback(name)
Bus.StartPlayback(name, speed)
Value Type What it is
name str The recording's name.
speed float Optional. 1 is real time, 2 twice as fast, 0.5 half speed.

Bus.StartRecording

Starts recording topics to a file in ARCx Data\Recordings. Use ** to record everything.

Bus.StartRecording(topics)
Value Type What it is
topics str A topic or pattern, or several separated by commas, such as /arcx/nms/,/arcx/vision/ .

Gives back: str. The recording's name.

Bus.StopPlayback

Stops the playback, if one is running.

Bus.StopPlayback()

Bus.StopRecording

Stops the recording being made.

Bus.StopRecording()

Gives back: float. How many messages were recorded, or 0 when nothing was recording.

Bus.TransformPoint

Converts a point from one frame to another, such as an object the camera sees into the robot's frame. Throws when the frames are not connected.

Bus.TransformPoint(target, sourceFrame, x, y, z)
Value Type What it is
target str The frame to convert into, such as base_link.
sourceFrame str The frame the point is in, such as camera.
x float The point's X in sourceFrame, metres.
y float The point's Y in sourceFrame, metres.
z float The point's Z in sourceFrame, metres.

Gives back: list[float]. The point in the target frame as [x, y, z].

Bus.WaitForMessage

Waits for the next message on a topic, with no time limit or until the time limit passes.

Bus.WaitForMessage(topic)
Bus.WaitForMessage(topic, timeoutMs)
Value Type What it is
topic str The topic name, or a pattern such as /arcx/vision/** .
timeoutMs float Optional. The longest to wait in milliseconds. 0 or less waits with no limit.

Gives back: object. The message data, or None when the time ran out.