QCar 2

../_images/QCar2_Banner.png

Description

QCars are considered “actors” in Quanser Interactive Labs. The QCar library can be used to acquire sensor data from the virtual environment and controls the motion of the vehicles.

See the QCar 2 Tutorial to get a better understanding of using QCars in Quanser Interactive Labs.

Library

class qvl.qcar2.QLabsQCar2(qlabs, verbose=False)[source]

This class is for spawning QCars.

Constants

QLabsQCar2.ID_QCAR = 161

Class ID

Note

CSI camera resolution is 820x410.

QLabsQCar2.CAMERA_CSI_RIGHT = 0
QLabsQCar2.CAMERA_CSI_BACK = 1
QLabsQCar2.CAMERA_CSI_LEFT = 2
QLabsQCar2.CAMERA_CSI_FRONT = 3

Note

RGB and depth resolution is 640x480.

QLabsQCar2.CAMERA_RGB = 4
QLabsQCar2.CAMERA_DEPTH = 5

Note

Overhead and trailing cameras support user zoom using the mouse wheel.

QLabsQCar2.CAMERA_OVERHEAD = 6
QLabsQCar2.CAMERA_TRAILING = 7

Member Variables

QLabsQCar2.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

QLabsQCar2.set_transform_and_request_state(location, rotation, enableDynamics, headlights, leftTurnSignal, rightTurnSignal, brakeSignal, reverseSignal, waitForConfirmation=True)[source]

Sets the location, rotation, and other car properties. Note that setting the location ignores collisions so ensure that the location is free of obstacles that may trap the actor if it is subsequently used in a dynamic mode. This transform can also be used to “playback” previously recorded position data without the need for a full dynamic model.

Parameters
  • location (float array[3]) – An array of floats for x, y and z coordinates in full-scale units. Multiply physical QCar locations by 10 to get full scale locations.

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

  • enableDynamics (boolean/int) – Enables or disables gravity for set transform requests.

  • headlights (boolean/int) – If the type is a boolean set all the headlights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left middle, b2: left inside, b3: right outside, b4: right middle, b5: right inside).

  • leftTurnSignal (boolean/int) – If the type is a boolean set all the left turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • rightTurnSignal (boolean/int) – If the type is a boolean set all the right turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • brakeSignal (boolean/int) – This does not affect the motion of the vehicle. If the type is a boolean set all the brake lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left inside, b2: right outside, b3: right inside).

  • reverseSignal (boolean/int) – If the type is a boolean set all the reverse lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left, b1: right).

  • waitForConfirmation (boolean) – (Optional) Wait for confirmation before proceeding. This makes the method a blocking operation. NOTE: Return data will only be valid if waitForConfirmation is True.

Returns

  • status - True if successful or False otherwise

  • location - in full scale

  • rotation - in radians

  • forward vector - unit scale vector

  • up vector - unit scale vector

  • front bumper hit - True if in contact with a collision object, False otherwise

  • rear bumper hit - True if in contact with a collision object, False otherwise

Return type

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

QLabsQCar2.set_transform_and_request_state_degrees(location, rotation, enableDynamics, headlights, leftTurnSignal, rightTurnSignal, brakeSignal, reverseSignal, waitForConfirmation=True)[source]

Sets the location, rotation, and other car properties. Note that setting the location ignores collisions so ensure that the location is free of obstacles that may trap the actor if it is subsequently used in a dynamic mode. This transform can also be used to “playback” previously recorded position data without the need for a full dynamic model.

Parameters
  • location (float array[3]) – An array of floats for x, y and z coordinates in full-scale units. Multiply physical QCar locations by 10 to get full scale locations.

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

  • enableDynamics (boolean) – (default True) Enables or disables gravity for set transform requests.

  • headlights (boolean/int) – If the type is a boolean set all the headlights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left middle, b2: left inside, b3: right outside, b4: right middle, b5: right inside).

  • leftTurnSignal (boolean/int) – If the type is a boolean set all the left turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • rightTurnSignal (boolean/int) – If the type is a boolean set all the right turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • brakeSignal (boolean/int) – This does not affect the motion of the vehicle. If the type is a boolean set all the brake lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left inside, b2: right outside, b3: right inside).

  • reverseSignal (boolean/int) – If the type is a boolean set all the reverse lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left, b1: right).

  • waitForConfirmation (boolean) – (Optional) Wait for confirmation before proceeding. This makes the method a blocking operation. NOTE: Return data will only be valid if waitForConfirmation is True.

Returns

  • status - True if successful or False otherwise

  • location - in full scale

  • rotation - in radians

  • forward vector - unit scale vector

  • up vector - unit scale vector

  • front bumper hit - True if in contact with a collision object, False otherwise

  • rear bumper hit - True if in contact with a collision object, False otherwise

Return type

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

QLabsQCar2.set_velocity_and_request_state(forward, turn, headlights, leftTurnSignal, rightTurnSignal, brakeSignal, reverseSignal)[source]

Sets the velocity, turn angle in radians, and other car properties.

Parameters
  • forward (float) – Speed in m/s of a full-scale car. Multiply physical QCar speeds by 10 to get full scale speeds.

  • turn (float) – Turn angle in radians. Positive values turn right.

  • headlights (boolean/int) – If the type is a boolean set all the headlights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left middle, b2: left inside, b3: right outside, b4: right middle, b5: right inside).

  • leftTurnSignal (boolean/int) – If the type is a boolean set all the left turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • rightTurnSignal (boolean/int) – If the type is a boolean set all the right turn signals. If the type is an int, it will be treated as a bit mask for individual light control (b0: front, b1: rear).

  • brakeSignal (boolean/int) – This does not affect the motion of the vehicle. If the type is a boolean set all the brake lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left outside, b1: left inside, b2: right outside, b3: right inside).

  • reverseSignal (boolean/int) – If the type is a boolean set all the reverse lights. If the type is an int, it will be treated as a bit mask for individual light control (b0: left, b1: right).

Returns

  • status - True if successful, False otherwise

  • location

  • rotation - in radians

  • front bumper hit - True if in contact with a collision object, False otherwise

  • rear bumper hit - True if in contact with a collision object, False otherwise

Return type

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

QLabsQCar2.set_velocity_and_request_state_degrees(forward, turn, headlights, leftTurnSignal, rightTurnSignal, brakeSignal, reverseSignal)[source]

Sets the velocity, turn angle in degrees, and other car properties.

Parameters
  • forward – Speed in m/s of a full-scale car. Multiply physical QCar speeds by 10 to get full scale speeds.

  • turn (float) – Turn angle in degrees. Positive values turn right.

  • headlights (boolean) – Enable the headlights

  • leftTurnSignal (boolean) – Enable the left turn signal

  • rightTurnSignal (boolean) – Enable the right turn signal

  • brakeSignal (boolean) – Enable the brake lights (does not affect the motion of the vehicle)

  • reverseSignal (boolean) – Play a honking sound

Returns

  • status - True if successful, False otherwise

  • location

  • rotation - in radians

  • front bumper hit - True if in contact with a collision object, False otherwise

  • rear bumper hit - True if in contact with a collision object, False otherwise

Return type

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

QLabsQCar2.possess(camera=CAMERA_TRAILING)[source]

Possess (take control of) a QCar in QLabs with the selected camera.

Parameters

camera (uint32) – Pre-defined camera constant. See CAMERA constants for available options. Default is the trailing camera.

Returns

  • status - True if possessing the camera was successful, False otherwise

Return type

boolean

QLabsQCar2.ghost_mode(enable=True, color=[0, 1, 0])[source]

Ghost mode changes the selected QCar actor into a transparent colored version. This can be useful as a reference actor or indicating a change in state.

Parameters
  • enable (boolean) – Set the QCar to the defined transparent color, otherwise revert to the solid color scheme.

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

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsQCar2.set_led_strip_uniform(color=[0, 0, 0], waitForConfirmation=True)[source]

Sets the entire LED color strip to the RGB value specified.

Parameters

color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale. Values greater than 1 can be used to enhance the glow or bloom effect (try 50).

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsQCar2.set_led_strip_individual(color, waitForConfirmation=True)[source]

Sets the 33 LEDs in the color strip individually. Note that specifying individual LED’s has a slight impact on performance versus set_led_strip_uniform.

Parameters

color (float array[3][33]) – A 2D array Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale by 33 rows. Values greater than 1 can be used to enhance the glow or bloom effect (try 50).

Returns

  • status - True if successful, False otherwise

Return type

boolean

QLabsQCar2.get_image(camera)[source]

Request a JPG image from one of the QCar cameras.

Parameters

camera (uint32) – Pre-defined camera constant. See CAMERA constants for available options. Trailing and Overhead cameras cannot be selected.

Returns

  • status - True and image data if successful, False and empty otherwise

  • imageData - Image in a JPG format

Return type

boolean, byte array with jpg data

QLabsQCar2.get_lidar(samplePoints=400)[source]

Request LIDAR data from a QCar.

Parameters

samplePoints (uint32) – (Optional) Change the number of points per revolution of the LIDAR.

Returns

True, angles in radians, and distances in m if successful, False, none, and none otherwise

Return type

boolean, float array, float array

Parent Class (actor.py) Methods

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

Constructor Method

Parameters
  • qlabs (object) – A QuanserInteractiveLabs object

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

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

Spawns a new QCar 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 and only uniform scaling is recommended. Sensor scaling will be based on scale[0].

  • 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

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

Spawns a new QCar 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 and only uniform scaling is recommended. Sensor scaling will be based on scale[0].

  • 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

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

Spawns a new QCar 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 and only uniform scaling is recommended. Sensor scaling will be based on scale[0].

  • 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

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

Spawns a new QCar 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 and only uniform scaling is recommended. Sensor scaling will be based on scale[0].

  • 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

QLabsQCar2.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

QLabsQCar2.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

QLabsQCar2.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

QLabsQCar2.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]

QLabsQCar2.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]

Configurations

There is only one configuration of the QCar actor.

Connection Points

Image (Click for enlarged view)

Reference Frame Number

Parent Frame

Relative Transform to Parent (Location, Rotation)

Description

conn0

0

The base frame is located at ground level, centered between the two rear wheels.

conn1

1

0

[ 1.300,0,0] [0,0,0]

Centered between the front and rear axles on the ground.

conn2

2

0

[ 1.207,0,1.880] [0,0,0]

Top center of the LIDAR

Component Extrinsics

“Extrinsics” refer to the external relationship of an object with respect to a specific frame of reference (in this case the body center of the QCar). Sometimes it’s important to know specific distances and orientation of extrinsic components, for instance, this can be use for obstacle detection and camera calibration. You will find a list of the important extrinsics below.

Distances From Body Frame

The body frame is located between the front and rear axles on the ground plane. Distances of the QCar 2 in its virtual environment are 10 times larger than on the physical system so a QCar 2 spawned at a scale of 1 is equivalent size to a full-scale automobile. A QCar spawned at a scale of 0.1 will be equivalent to the size of a physical QCar.

The RealSense camera distance is considered from the front face of the camera at the location of the RGB sensor.

../_images/qcar2_bodyframe.png

Component

x (m)

y (m)

z (m)

CG

-0.11

0.029

0.814

Front axle

1.30

0

0.31

Rear axle

-1.30

0

0.31

CSI front

1.83

0

1.10

CSI left

0.12

0.33

1.10

CSI rear

-1.52

0

1.10

CSI right

0.12

-0.53

1.10

IMU

0.11

0

0.89

RealSense

0.95

0.32

1.72

RPLIDAR

-0.12

-0

1.93


Transformation Matrices

All transformation matrices are built off of the body frame and sensor frames for the QCar 2.

To read more about this check out our documentation here by clicking on resources button and looking inside the zip folder for src/user_manuals/qcar2/user_manual_system_hardware.pdf

../_images/extrinsics_qc2.png

QCar 2 Tutorial