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.
- 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.
- class basic_robotics.plotting.vis_3js_client.DrawClient(host: str = '127.0.0.1', port: int = 5000)[source]
Bases:
objectSupervisor 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.
- 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.
- 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.
- 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.
- sendAggregated(dict_list, hostalt: str = None) bool[source]
Send an aggregated list of dicts to the visualizer.
- send(dat: dict, msgtype: str, hostalt: str = None, addtime: bool = False) bool[source]
Send a dict to the visualization server.
- 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.
- sendTM(tmobj: tm, params: dict) bool[source]
Send a transformation matrix complete dict to the visualizer.
- 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.
- class basic_robotics.plotting.vis_3js_client.VisPlot(name: str, client: DrawClient = None)[source]
Bases:
objectA 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.
- 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:
VisPlotA 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.
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_
- 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:
PrimitivePlotA 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.
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
- class basic_robotics.plotting.vis_3js_client.AxesPlot(transform_origin: tm, client: DrawClient = None, scale: float = 1.0, name: str = None)[source]
Bases:
PrimitivePlotA 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
- 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:
PrimitivePlotA 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
- class basic_robotics.plotting.vis_3js_client.RobotPlot(name: str, bot, client: DrawClient = None)[source]
Bases:
VisPlotGeneral 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:
RobotPlotImplement 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.
- class basic_robotics.plotting.vis_3js_client.SPPlot(name: str, sp, client: DrawClient = None)[source]
Bases:
RobotPlotGeneral 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.