Widgets

../_images/banner_widget.png

Widgets work slightly differently then the other objects in the QLabs Workspaces. They are special actors that cannot be addressed after they have been spawned therefore they cannot be deleted individually, they do not support parenting and all actor properties must be set when they are spawned. The advantage of widgets is that they are highly efficient dynamic actors so it is possible to spawn thousands of widgets while maintaining performance.

In addition to the visible properties of widgets, widget actors can also individually contain invisible properties such as mass, a numerical ID tag, and a general purpose properties string. Some actors that are designed to interact with widgets include class methods to read these properties.

If you need the ability to make shapes static or the ability to address, modify, or parent shapes, see Basic Shapes instead.

See the Widgets Tutorial to get a better understanding of using people in Quanser Interactive Labs.

Description

Library

class qvl.widget.QLabsWidget(qlabs, verbose=False)[source]

This class is for the spawning of widgets.

Constants

QLabsWidget.CUBE = 0
QLabsWidget.CYLINDER = 1
QLabsWidget.SPHERE = 2
QLabsWidget.PLASTIC_BOTTLE = 4
QLabsWidget.METAL_CAN = 5

Methods

QLabsWidget.__init__(qlabs, verbose=False)[source]

Constructor Method

Parameters
  • qlabs (object) – A QuanserInteractiveLabs object

  • verbose (boolean) – (Optional) Print error information to the console.

QLabsWidget.spawn(location, rotation, scale, configuration, color=[1, 1, 1], measuredMass=0, IDTag=0, properties='', waitForConfirmation=True)[source]

Spawns a widget in an instance of QLabs at a specific location and rotation using radians.

Parameters
  • location (float array[3]) – An array of floats for x, y and z coordinates.

  • rotation (float array[3]) – An array of floats for the roll, pitch, and yaw in radians.

  • scale (float array[3]) – An array of floats for the scale in the x, y, and z directions.

  • configuration (uint32) – See configuration options

  • color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.

  • measuredMass (float) – A float value for use with mass sensor instrumented actors. This does not alter the dynamic properties.

  • IDTag (uint8) – An integer value for use with IDTag sensor instrumented actors.

  • properties (string) – A string for use with properties sensor instrumented actors. This can contain any string that is available for use to parse out user-customized parameters.

  • waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsWidget.spawn_degrees(location, rotation, scale, configuration, color=[1, 1, 1], measuredMass=0, IDTag=0, properties='', waitForConfirmation=True)[source]

Spawns a widget in an instance of QLabs at a specific location and rotation using degrees.

Parameters
  • location (float array[3]) – An array of floats for x, y and z coordinates.

  • rotation (float array[3]) – An array of floats for the roll, pitch, and yaw in degrees.

  • scale (float array[3]) – An array of floats for the scale in the x, y, and z directions.

  • configuration (uint32) – See configuration options.

  • color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.

  • measuredMass (float) – A float value for use with mass sensor instrumented actors. This does not alter the dynamic properties.

  • IDTag (uint8) – An integer value for use with IDTag sensor instrumented actors.

  • properties (string) – A string for use with properties sensor instrumented actors. This can contain any string that is available for use to parse out user-customized parameters.

  • waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsWidget.destroy_all_spawned_widgets()[source]

Destroys all spawned widgets, but does not destroy actors.

Returns

True if successful, False otherwise

Return type

boolean

QLabsWidget.widget_spawn_shadow(enableShadow=True)[source]

If spawning a large number of widgets causes performance degradation, you can try disabling the widget shadows. This function must be called in advance of widget spawning and all subsequence widgets will be spawned with the specified shadow setting.

Parameters

enableShadow (boolean) – (Optional) Show (True) or hide (False) widget shadows.

Returns

True if successful, False otherwise

Return type

boolean

Configurations

There are 5 different types of widgets that can be spawned in the widgets class.

  • 0 - Cube

  • 1 - Cylinder

  • 2 - Sphere

  • 4 - Plastic Bottle

  • 5 - Metal Can

../_images/configuration_widgets.png

Connection Points

There are no connection points for this actor class.

Widgets Tutorial