zlp_viz module

This module contains utility classes and methods to run a projections visualizer.

class z_laser_viz.zlp_viz.ZLPVisualizer[source]

Bases: object

This class implement the functions related with projection elements.

cs_marker_array

coordinate systems’ markers list (origin axes and frame of each system)

Type:list
pe_marker_array

markers list of projection elements

Type:list
active_cs

name of active reference system

Type:str
cs_reference

auxiliar variable to differentiate and find the origin axes and frames markers

Type:str
STD_WAIT_TIME

predefined number of projection seconds in reference system definition

Type:int
figures_list

list with the figures’ identificator names

Type:list
__init__()[source]

Initialize the ZLPVisualizer object.

open_services()[source]

Open ROS services for visualizer.

projection_start_cb(req)[source]

Callback of ROS service to start projection of elements related to the active reference system on the surface.

Parameters:req (object) – trigger request ROS service object
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
projection_stop_cb(req)[source]

Callback of ROS service to stop projection of all elements.

Parameters:req (object) – trigger request ROS service object
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
manual_define_coord_sys_cb(req)[source]

Callback of ROS service to define a new reference system, stating the points coordinates manually by the user.

Parameters:req (object) – object with the necessary info to define a new coordinate system
Returns:the first value in the returned tuple is a list of the user reference points T0, T1, T2, T3, the second is a bool success value and the third s an information message string
Return type:tuple[list, bool, str]
timer_cb(timer)[source]

Timer for controlling the projection pause between the reference systems’s different markers.

update_cs_markers()[source]

Change projection between origin axes and frame markers.

base_marker(cs_name)[source]

Initialize the common and basic parameters of a marker.

Parameters:cs_name (object) – name of the reference system with which the marker is associated
Returns:marker initialized
Return type:object
coord_sys_axes(cs_points)[source]

Create the origin axes markers.

Parameters:cs_points (object) – object with the x,y,z position of the reference points from the reference system
Returns:the first value in the returned tuple is the x-axis marker and the second is the y-axis marker
Return type:tuple[object, object]
coord_sys_frame(cs_points)[source]

Create the frame marker.

Parameters:cs_points (object) – object with the x,y,z position of the reference points from the reference system
Returns:frame marker
Return type:object
set_coord_sys_cb(req)[source]

Callback of ROS service to set the indicated reference system as ‘active reference system’.

Parameters:req (object) – object with the necessary parameters to identify a coordinate system
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
show_coord_sys_cb(req)[source]

Callback of ROS service to project reference points, origin axes and frame of the active reference system.

Parameters:req (object) – object with the necessary parameters to identify a reference system
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
remove_coord_sys_cb(req)[source]

Callback of ROS service to remove a reference system.

Parameters:req (object) – object with the necessary parameters to identify a reference system
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
add_fig_cb(msg)[source]

Callback of ROS topic to define a new projection element.

Parameters:msg (object) – object with the necessary parameters to define a new projection element
line_eq(length, ang)[source]

Calculate points array of a new line from its parametrics equation.

Parameters:
  • length (float) – line length
  • ang (float) – line angle slope
Returns:

list of calculated points

Return type:

list

circle_eq(radius, start_ang, end_ang)[source]

Calculate points array of a new circle or arc from its parametrics equation.

Parameters:
  • radius (float) – circle or arc radius
  • start_ang (float) – arc start angle
  • end_ang (float) – arc end angle
Returns:

list of calculated points

Return type:

list

oval_eq(a, b, angle)[source]

Calculate points array of a new ellipse from its parametrics equation.

Parameters:
  • a (float) – ellipse width
  • b (float) – ellipse height
  • angle (float) – rotation angle
Returns:

list of calculated points

Return type:

list

hide_proj_elem_cb(req)[source]

Callback of ROS service to hide specific projection element from active reference system.

Parameters:req (object) – object with the necessary parameters to identify a projection element
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
unhide_proj_elem_cb(req)[source]

Callback of ROS service to unhide specific projection element from active reference system.

Parameters:req (object) – object with the necessary parameters to identify a projection element
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
remove_proj_elem_cb(req)[source]

Callback of ROS service to remove specific figure from active reference system.

Parameters:req (object) – object with the necessary parameters to identify a projection element
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
translate(marker, dx=0, dy=0, dz=0)[source]

Translate marker from one position to another.

Parameters:
  • marker (object) – marker object to translate
  • dx (float) – offset in x direction
  • dy (float) – offset in y direction
  • dz (float) – offset in z direction
compute_step()[source]

Calculate the resolution step of the active reference system.

Returns:resolution step (real dimension system {P} in mm / user dimension system {T})
Return type:float
rotate(marker, angle)[source]

Rotate marker an angle.

Parameters:
  • marker (object) – marker object to rotate
  • angle (float) – rotation angle [degrees]
quat_multiply(q1, q0)[source]

Calculate the product of two quaternions.

Returns:object with the x,y,z,w values of the result quaternion
Return type:object
scale(marker, factor, proj_elem_params)[source]

Scale size of marker by redefining figure equation.

Parameters:
  • marker (object) – marker object to scale
  • factor (float) – scale factor
  • proj_elem_params (object) – object with the parameters of the projection element to transform
on_press(key, marker, proj_elem_params)[source]

Check if the key pressed if one of the list and execute the respective tasks.

Parameters:
  • key (enum) – key pressed
  • marker (object) – monitored marker object
  • proj_elem_params (object) – object with the parameters of the projection element to monitor
on_release(key)[source]

Remove current stored key, on release.

Parameters:key (enum) – key pressed
marker_from_name(name)[source]

Find marker object in the markers array with the name.

Parameters:name (str) – name of the marker
Returns:marker found
Return type:object
init_keyboard_listener_cb(msg)[source]

Start keyboard listener for monitoring key presses.

Parameters:msg (object) – object with the necessary parameters to identify a projection element
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]