Splines

Description

The spline actor can be used to create both curves and straight lines. Line color can be set for the entire line, and line width can be set on a per-control point basis. Splines are created by first spawning a spline actor and then adding control points. Depending on the configuration used when spawned, you can get variations on the curve shape or straight lines.

See the Splines Tutorial to get a better understanding of using splines in Quanser Interactive Labs.

Library

class qvl.spline_line.QLabsSplineLine(qlabs, verbose=False)[source]

Constants

QLabsSplineLine.ID_SPLINE_LINE = 180

Class ID

QLabsSplineLine.LINEAR = 0

See configurations

QLabsSplineLine.CURVE = 1

See configurations

QLabsSplineLine.CONSTANT = 2

See configurations

QLabsSplineLine.CLAMPED_CURVE = 3

See configurations

Member Variables

QLabsSplineLine.actorNumber = None

The current actor number of this class to be addressed. This will be set by spawn methods and cleared by destroy methods. It will not be modified by the destroy all actors. This can be manually altered at any time to use one object to address multiple actors.

Methods

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

Constructor Method

Parameters
  • qlabs (object) – A QuanserInteractiveLabs object

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

QLabsSplineLine.spawn(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)

Spawns a new actor with the next available actor number within this class.

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

  • waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred. Note that if this is False, the returned actor number will be invalid.

Returns

  • status - 0 if successful, 1 class not available, 3 unknown error, -1 communications error.

  • actorNumber - An actor number to use for future references.

Return type

int32, int32

QLabsSplineLine.spawn_degrees(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)

Spawns a new actor with the next available actor number within this class.

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

  • waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred. Note that if this is False, the returned actor number will be invalid.

Returns

  • status - 0 if successful, 1 class not available, 3 unknown error, -1 communications error.

  • actorNumber - An actor number to use for future references.

Return type

int32, int32

QLabsSplineLine.spawn_id(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)

Spawns a new actor.

Parameters
  • actorNumber (uint32) – User defined unique identifier for the class actor in QLabs

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

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

Returns

  • status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.spawn_id_degrees(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)

Spawns a new actor.

Parameters
  • actorNumber (uint32) – User defined unique identifier for the class actor in QLabs

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

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

Returns

  • status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.spawn_id_and_parent_with_relative_transform(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)

Spawns a new actor relative to an existing actor and creates a kinematic relationship.

Parameters
  • actorNumber (uint32) – User defined unique identifier for the class actor in QLabs

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

  • parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier

  • parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs

  • parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options

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

Returns

  • status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 cannot find the parent actor, 4 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.spawn_id_and_parent_with_relative_transform_degrees(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)

Spawns a new actor relative to an existing actor and creates a kinematic relationship.

Parameters
  • actorNumber (uint32) – User defined unique identifier for the class actor in QLabs

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.

  • parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier

  • parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs

  • parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options

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

Returns

  • status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 cannot find the parent actor, 4 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.destroy()

Find and destroy a specific actor. This is a blocking operation.

Returns

  • numActorsDestroyed - The number of actors destroyed. -1 if failed.

Return type

int32

QLabsSplineLine.destroy_all_actors_of_class()

Find and destroy all actors of this class. This is a blocking operation.

Returns

  • numActorsDestroyed - The number of actors destroyed. -1 if failed.

Return type

int32

QLabsSplineLine.ping()

Checks if the actor is still present in the environment. Note that if you did not spawn the actor with one of the spawn functions, you may need to manually set the actorNumber member variable.

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.get_world_transform()

Get the location, rotation, and scale in world coordinates of the actor.

Returns

  • status - True if successful, False otherwise

  • location

  • rotation

  • scale

Return type

boolean, float array[3], float array[3], float array[3]

QLabsSplineLine.get_world_transform_degrees()

Get the location, rotation, and scale in world coordinates of the actor.

Returns

  • status - True if successful, False otherwise

  • location

  • rotation

  • scale

Return type

boolean, float array[3], float array[3], float array[3]

QLabsSplineLine.set_points(color, pointList, alignEndPointTangents=False, waitForConfirmation=True)[source]

After spawning the origin of the spline actor, this method is used to create the individual points. At least 2 points must be specified to make a line.

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

  • pointList (float 2D array[4][n]) – A 2D array with each row containing [x,y,z,width] elements. Width is in m.

  • alignEndPointTangents (boolean) – (Optional) Sets the tangent of the first and last point to be the same.

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.circle_from_center(radius, lineWidth=0.1, color=[1, 0, 0], numSplinePoints=8, waitForConfirmation=True)[source]

After spawning the origin of the spline actor, this method is used to create a circle. Configuration 1 is recommended when spawning the line.

Parameters
  • radius (float) – Radius in m

  • lineWidth (float) – Line width in m

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

  • numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.arc_from_center(radius, startAngle=0, endAngle=math.pi / 2, lineWidth=1, color=[1, 0, 0], numSplinePoints=8, waitForConfirmation=True)[source]

After spawning the origin of the spline actor, this method is used to create an arc. Configuration 1 is recommended when spawning the line.

Parameters
  • radius (float) – Radius in m

  • startAngle (float) – Angle relative to the spawn orientation in radians

  • endAngle (float) – Angle relative to the spawn orientation in radians

  • lineWidth (float) – Line width in m

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

  • numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.arc_from_center_degrees(radius, startAngle=0, endAngle=90, lineWidth=1, color=[1, 0, 0], numSplinePoints=4, waitForConfirmation=True)[source]

After spawning the origin of the spline actor, this method is used to create an arc. Configuration 1 is recommended when spawning the line.

Parameters
  • radius (float) – Radius in m

  • startAngle (float) – Angle relative to the spawn orientation in degrees

  • endAngle (float) – Angle relative to the spawn orientation in degrees

  • lineWidth (float) – Line width in m

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

  • numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.rounded_rectangle_from_center(cornerRadius, xWidth, yLength, lineWidth=0.1, color=[1, 0, 0], waitForConfirmation=True)[source]

After spawning the origin of the spline actor, this method is used to create a rounded rectangle. Configuration 1 is recommended when spawning the line.

Parameters
  • cornerRadius (float) – Corner radius in m

  • xWidth (float) – Dimension in m of the rectangle in the local x axis

  • yLength (float) – Dimension in m of the rectangle in the local y axis

  • lineWidth (float) – Line width in m

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

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsSplineLine.parent_with_relative_transform(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)

Parents one existing actor to another to create a kinematic relationship.

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier

  • parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs

  • parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options

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

Returns

  • status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.parent_with_relative_transform_degrees(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)

Parents one existing actor to another to create a kinematic relationship.

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

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

  • scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.

  • parentClassID (uint32) – (Optional) See the ID variables in the respective library classes for the class identifier

  • parentActorNumber (uint32) – (Optional) User defined unique identifier for the class actor in QLabs

  • parentComponent (uint32) – (Optional) 0 for the origin of the parent actor, see the parent class for additional reference frame options

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

Returns

  • status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.parent_with_current_world_transform(parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)

Parents one existing actor to another to create a kinematic relationship while preserving the current world transform of the child actor.

Parameters
  • parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier

  • parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs

  • parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options

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

Returns

  • status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error

Return type

int32

QLabsSplineLine.parent_break(waitForConfirmation=True)

Breaks any relationship with a parent actor (if it exists) and preserves the current world transform

Parameters

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

Returns

  • status - 0 if successful, 1 cannot find this actor, -1 communications error

Return type

int32

Configurations

../_images/configuration_spline_types.png

Configurations 0 to 3 are shown from top to bottom in the above image using the same set of control points.

Configuration

Mode

Description

0

Linear

The tangent of the curve at each control point is set to match the tangent of the start of each line segment.

1

Curve

The tangent of the curve at each control point is an average of the two adjacent line segments and matched to the start and end tangents.

2

Constant

Straight line segments

3

Clamped Curve

As angles become more acute, the curve will transition from a smooth change to a sharp point.

Connection Points

There are no connection points for this actor class.

Splines Tutorial