basic_robotics.plotting.vis_3js_client module

Client functions for using the 3JS visualizer.

basic_robotics.plotting.vis_3js_client.newFloor(filename: str = 'ChFloor2.glb') → dict[source]

Create a new floor.

Parameters:

filename (str, optional) – Floor file. Defaults to ‘ChFloor2.glb’.

Returns:

dict – dict representing the floor object.

basic_robotics.plotting.vis_3js_client.newMaterial(color: hex = 3291304, transparent: bool = True, opacity: float = 0.5) → dict[source]

Create a new material for an object primitive.

Parameters:
  • color (hexadecimal, optional) – Color of the Object. Defaults to 0xff8800.

  • transparent (bool, optional) – transparency boolean. Defaults to True.

  • opacity (float, optional) – opacity between 0 and 1. Defaults to .5.

Returns:

dict – dict representing the new material.

basic_robotics.plotting.vis_3js_client.newPrimitive(name: str = 'CubeLet', file: str = 'Cube3.glb', Category: str = 'Model', scale=[1.0, 1.0, 1.0], color: dict = None) → dict[source]

Create a new primative for the visualizer.

Parameters:
  • name (str, optional) – name of the object. Defaults to “CubeLet”

  • file (str, optional) – filename of the primitive. Defaults to “Cube3.glb”.

  • Category (str, optional) – type of object. Defaults to “Model”.

  • scale (list[float], optional) – scale of object dimensions XYZ. Defaults to [1.0, 1.0, 1.0].

  • color (dict, optional) – color dict of the object. Defaults to None.

Returns:

dict – New dict representing primitive.

basic_robotics.plotting.vis_3js_client.determineAxis(joint_location: tm, axis: ndarray[float]) → tm[source]

Determine axis of rotation in global space of a joint.

Parameters:
  • joint_location (tm) – joint location in global space

  • axis (np.ndarray[float]) – Axis of the joint pulled from the Arm model.

Returns:

tm – tm indicating rotation of joint.

class basic_robotics.plotting.vis_3js_client.DrawClient(host: str = '127.0.0.1', port: int = 5000)[source]

Bases: object

Supervisor clieent for accessing 3JS visualizer.

__init__(host: str = '127.0.0.1', port: int = 5000) → DrawClient[source]

Create a new DrawClient for the 3JS visualizer.

Parameters:
  • host (str, optional) – Host IP of the visualizer. Defaults to ‘127.0.0.1’.

  • port (int, optional) – Port of the visualizer. Defaults to 5000.

Returns:

DrawClient – new Draw Client.

newName() → str[source]

Allocate a new name for an object to use, if default name was not assigned.

Returns:

str – new name to use

deleteName(name: str) → bool[source]

Delete a particular object from the default/unammed registry.

Parameters:

str (name) – Object to remove.

Returns:

bool – Success of removal

deleteAllUnnamed() → bool[source]

Delete all objects that were named by default.

Returns:

bool – Success of Default.

setPort(new_port: int) → None[source]

Set a new host port.

Parameters:

new_port (int) – new host port.

setHost(new_host: str) → None[source]

Set a new host IP.

Parameters:

new_host (str) – New Host IP.

makeHostURL() → None[source]

Make the host url from the host IP and port saved.

detHost(host_alt: str = None) → str[source]

Switch hosts between default and an alternate (if supplied).

Parameters:

host_alt (str, optional) – Alternate host URL. Defaults to ‘None’

Returns:

str – Host URL

tryDictMatch(tdict: dict, val: str, init: any) → any[source]

Try and retrieve appropriate value from a dict.

Parameters:
  • tdict (dict) – dict of interest.

  • val (str) – value key of interest.

  • init (any) – default value.

Returns:

any – return type of accessed dict or default.

makeFloor(floor_file='jsons/SceneFloor.json') → None[source]

Make a floor.

Parameters:

floor_file (str, optional) – optional floor file. Defaults to ‘jsons/SceneFloor.json’.

prepAggregated(dict_list) → dict[source]

Turn a list of dicts into a single dict with named elements.

Parameters:

dictarray (list[dict]) – Input list of dicts.

Returns:

dict – output dict.

sendAggregated(dict_list, hostalt: str = None) → bool[source]

Send an aggregated list of dicts to the visualizer.

Parameters:
  • dict_list (list[dict]) – Input list of dicts.

  • hostalt (str, optional) – Alternate Host. Defaults to None.

Returns:

bool – _description_

send(dat: dict, msgtype: str, hostalt: str = None, addtime: bool = False) → bool[source]

Send a dict to the visualization server.

Parameters:
  • dat (dict) – Dict to send

  • msgtype (str) – Type of message (PUT or POST)

  • hostalt (str, optional) – alternate host. Defaults to None.

  • addtime (bool, optional) – add network time to package. Defaults to False.

Returns:

bool – Success on placing message

sendFile(fname: str, host_alt: str = None, add_time: bool = True, key_name: str = None) → <module 'json' from '/opt/hostedtoolcache/Python/3.14.7/x64/lib/python3.14/json/__init__.py'>[source]

Send a file to the server.

Parameters:
  • fname (str) – File name to send.

  • host_alt (str, optional) – alternate host to send to. Defaults to None.

  • add_time (bool, optional) – add network time to package. Defaults to True.

  • key_name (str, optional) – key file name. Defaults to None.

Returns:

json – response json

prepTM(tmobj: tm, params: dict) → dict[source]

Add a Tm to an outbound dict.

Parameters:
  • tmobj (tm) – transform to add in.

  • params (dict) – dict to send out.

Returns:

dict – dict to send out.

sendTM(tmobj: tm, params: dict) → bool[source]

Send a transformation matrix complete dict to the visualizer.

Parameters:
  • tmobj (tm) – transformation

  • params (dict) – dict needing new position

Returns:

bool – success of placement.

sendAxes(loc: tm, name: str = 'Frame', scale: float = 1.0) → bool[source]

Send Axes to the client.

Parameters:
  • loc (tm) – Origin of the axes

  • name (str, optional) – name of the axes object. Defaults to “Frame”.

  • scale (float, optional) – scale (default is 1m axes). Defaults to 1.0.

Returns:

bool – success of placement.

sendLine(line_tms, host_alt: str = None, key: str = None, type: str = 'Arrow', color=[0.0, 1.0, 0.0], linewidth: float = 0.0025) → str[source]

Send a line between two transforms to the visualization server.

Parameters:
  • line_tms (list[tm, tm]) – list containing two tms, that is the line to be drawn.

  • host_alt (str, optional) – Alternate Host. Defaults to None.

  • key (str, optional) – name of the line. Defaults to None.

  • type (str, optional) – type of line (“Line” or “Arrow”). Defaults to “Arrow”.

  • color (list[float], optional) – color of line. Defaults to [0., 1., 0.].

  • linewidth (float, optional) – line width. Defaults to .0025.

Returns:

str – name of placed line.

get(params: dict = {}, hostalt: str = None) → dict[source]

Get a dict currently hosted on the visualization server.

Parameters:
  • params (dict, optional) – parameters to match. Defaults to {}.

  • hostalt (str, optional) – alternate host. Defaults to None.

Returns:

dict – dict matching desired request.

delete(params: dict = {}, hostalt: str = None) → bool[source]

Delete something from the server.

Parameters:
  • params (dict, optional) – params to match. Defaults to {} (DeleteAll).

  • hostalt (str, optional) – Alternate host. Defaults to None.

Returns:

bool – success of deletion

class basic_robotics.plotting.vis_3js_client.VisPlot(name: str, client: DrawClient = None)[source]

Bases: object

A Simple Holding Class for Drawing on the 3JS Server.

__init__(name: str, client: DrawClient = None) → VisPlot[source]

Create a new Visplot object.

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

  • client (DrawClient, optional) – Reference to active DrawClient. Defaults to None.

Returns:

VisPlot – New Visplot object.

delete()[source]

Delete this Object from the Visualizer.

initialize()[source]

Initialize this Vis Plot Instance.

update(send=False)[source]

Update visualized robot to match current configuration.

class basic_robotics.plotting.vis_3js_client.PrimitivePlot(name: str, transform_origin: tm, dimensions, client: DrawClient = None, c: str = 'grey', a: float = 0.1)[source]

Bases: VisPlot

A Simple Holding Class for Drawing on the 3JS Server. Models a primitive shape.

__init__(name: str, transform_origin: tm, dimensions, client: DrawClient = None, c: str = 'grey', a: float = 0.1) → PrimitivePlot[source]

Generate a new primitive plot instance.

Parameters:
  • name (str) – Name of this new object.

  • transform_origin (tm) – Transformation of this object in global space.

  • dimensions (list[float]) – Dimensions of this object.

  • client (DrawClient, optional) – Reference to DrawClient object. Defaults to None.

  • c (str, optional) – Color of this object. Defaults to ‘grey’.

  • a (float, optional) – Transparency of this object. Defaults to 0.1.

Returns:

PrimitivePlot – _description_

setTM(transform_origin: tm, send: bool = False)[source]

Set a new Transformation for this object.

Parameters:
  • transform_origin (tm) – Object transformation

  • send (bool, optional) – Whether or not to send object. Defaults to False.

Returns:

dict reference to this object.

update(send: bool = False)[source]

Update the object in the visualizer.

Parameters:

send (bool, optional) – Whether or not to send object. Defaults to False.

Returns:

dict reference to this object.

class basic_robotics.plotting.vis_3js_client.CubePlot(transform_origin: tm, dimensions, client: DrawClient = None, c: str = 'grey', a: float = 0.1, name: str = None)[source]

Bases: PrimitivePlot

A Simple Holding Class for Drawing on the 3JS Server. Models a cubic shape.

__init__(transform_origin: tm, dimensions, client: DrawClient = None, c: str = 'grey', a: float = 0.1, name: str = None) → CubePlot[source]

Generate a new CubePlot Object.

Parameters:
  • transform_origin (tm) – Transform of the object.

  • dimensions (list[float]) – Dimesnions of the object.

  • client (DrawClient, optional) – Reference to Drawclient. Defaults to None.

  • c (str, optional) – color of the object. Defaults to ‘grey’.

  • a (float, optional) – transparency of the object. Defaults to 0.1.

  • name (str, optional) – Name of the object. Defaults to None.

Returns:

CubePlot – A new CubePlot

initialize()[source]

Initialize a new cube.

class basic_robotics.plotting.vis_3js_client.AxesPlot(transform_origin: tm, client: DrawClient = None, scale: float = 1.0, name: str = None)[source]

Bases: PrimitivePlot

A Simple Holding Class for Drawing on the 3JS Server. Models an Axes object.

__init__(transform_origin: tm, client: DrawClient = None, scale: float = 1.0, name: str = None)[source]

Generate a new AxesPlot Object.

Parameters:
  • transform_origin (tm) – Transform of the object.

  • client (DrawClient, optional) – Reference to Drawclient. Defaults to None.

  • scale (float, optional) – scale of the axes. Defaults to 1.0

  • name (str, optional) – Name of the object. Defaults to None.

Returns:

AxesPlot – new AxesPlot object

initialize()[source]

Initialize a new Axes object.

class basic_robotics.plotting.vis_3js_client.TubePlot(transform_origin: tm, height: float, radius: float, client: DrawClient, color: str = 'blue', a: float = 0.1, name: str = None)[source]

Bases: PrimitivePlot

A Simple Holding Class for Drawing on the 3JS Server. Models a tube.

__init__(transform_origin: tm, height: float, radius: float, client: DrawClient, color: str = 'blue', a: float = 0.1, name: str = None) → TubePlot[source]

Generate a new TubePlot Object.

Parameters:
  • transform_origin (tm) – Transform of the object.

  • height (float) – height of the cylinder.

  • radius (float) – radius of the cylinder.

  • client (DrawClient, optional) – Reference to Drawclient. Defaults to None.

  • c (str, optional) – color of the object. Defaults to ‘grey’.

  • a (float, optional) – transparency of the object. Defaults to 0.1.

  • name (str, optional) – Name of the object. Defaults to None.

Returns:

TubePlot – new TubePlot object

initialize()[source]

Initialize a new tube.

class basic_robotics.plotting.vis_3js_client.RobotPlot(name: str, bot, client: DrawClient = None)[source]

Bases: VisPlot

General modelling class for a robot in the 3JS visualizer system.

__init__(name: str, bot, client: DrawClient = None) → RobotPlot[source]

Initialize a new RobotPlot instance.

Parameters:
  • name (str) – Name of this robot for reference.

  • bot (Robot) – Reference to the robot object desired to draw.

  • client (DrawClient, optional) – DrawClient instance. If none, make a new one. Defaults to None.

Returns:

RobotPlot – New RobotPlot Instance.

class basic_robotics.plotting.vis_3js_client.ArmPlot(name: str, arm, client: DrawClient = None)[source]

Bases: RobotPlot

Implement Creation of Serial Arm in the Visualizer.

__init__(name: str, arm, client: DrawClient = None)[source]

Initialize a new ArmPlot instance.

Parameters:
  • name (str) – Name of this robot for reference.

  • arm (Arm) – Reference to the robot object desired to draw.

  • client (DrawClient, optional) – DrawClient instance. If none, make a new one. Defaults to None.

Returns:

ArmPlot – New ArmPlot Instance.

initialize()[source]

Initialize this ArmPlot Instance.

update(send=False)[source]

Update visualized robot to match current configuration.

class basic_robotics.plotting.vis_3js_client.SPPlot(name: str, sp, client: DrawClient = None)[source]

Bases: RobotPlot

General modelling class for a stewart platform in the 3JS visualizer system.

__init__(name: str, sp, client: DrawClient = None)[source]

Initialize a new SPPlot instance.

Parameters:
  • name (str) – Name of this sp for reference.

  • sp (SP) – Reference to the robot object desired to draw.

  • client (DrawClient, optional) – DrawClient instance. If none, make a new one. Defaults to None.

Returns:

SPPlot – New SPPlot Instance.

legBot(i: int) → tm[source]

Get bottom part of an actuator position and rotation in global space.

Parameters:

i (int) – index of leg.

Returns:

tm – position of bottom part of actuator.

legTop(i: int) → tm[source]

Get top part of an actuator position and rotation in global space.

Parameters:

i (int) – index of leg.

Returns:

tm – position of top part of actuator.

initialize()[source]

Initialize this ArmPlot Instance.

update(send=False)[source]

Update visualized robot to match current configuration.