PosCon3D

class compas_fab.fab.sensors.baumer.PosCon3D(serial, address)[source]

Bases: compas_fab.fab.sensors.base.SerialSensor

Provides an interface for the Baumer PosCon3D edge measurement sensor. The sensor has different interfaces to retrieve its data. This class provides access to the serial interface (RS-485).

This class is a context manager type, so it’s best used in combination with the with statement to ensure resource deallocation.

The protocol of the sensor when operated via RS-485 indicates that access to it must be locked programmatically before starting operations and unlocked on completion. This is handled automatically if you use this class on a with statement, otherwise, the methods begin() and end() must be invoked by hand.

Parameters:
  • serial (serial.Serial) – Instance of the serial port used to communicate with the sensor.
  • address (int) – PosCon3D sensors have an address assigned, which defaults to 1. There’s also a broadcast address (PosCon3D.BROADCAST_ADDRESS) that can be used to query the address of the sensor connected to the RS-485 bus. Only one sensor can be in the bus when using the broadcast address to query for sensor’s address.

Examples

>>> from serial import Serial                                                   
>>> with Serial('COM5', 57600, timeout=1) as serial:                            
>>>     with PosCon3D(serial, PosCon3D.BROADCAST_ADDRESS) as broadcast_query:   
...         addr = broadcast_query.get_address()                                
...                                                                             
...     with PosCon3D(serial, addr) as sensor:                                  
...         sensor.set_measurement_type('Edge L rise')                          
...         sensor.set_precision(2)                                             
...         data = sensor.get_measurement()                                     
BROADCAST_ADDRESS = 0
MEASUREMENT_TYPES = ('Edge L rise', 'Edge L fall', 'Edge R rise', 'Edge R fall', 'Width', 'Center width', 'Gap', 'Center gap')
QUALITY = {0: 'Valid', 1: 'Low signal', 2: 'No edge', 3: 'Low signal, no edge', 4: 'No signal'}
activate_flex_mount(reference_thickness)[source]

Activates the FLEX Mount feature of the sensor to allow positioning it on an angled installation. The reference thickness is only required if the surface is uneven and an additional leveling auxiliary plate as been added.

adjust_to_dark_object(is_dark_object)[source]

Adjusts the sensor to detect darker or lighter surfaces.

begin()[source]

Locks the sensor to start RS-485 communication.

Note

This method only needs to be called if not using a with statement to handle lifetime of the PosCon3D instance.

deactivate_flex_mount()[source]

Deactivates the FLEX Mount feature.

end()[source]

Unlocks the sensor from RS-485 communication.

Note

This method only needs to be called if not using a with statement to handle lifetime of the PosCon3D instance.

get_address()[source]

Gets the address of the RS-485 sensors currently connected to the bus. This command is only really useful when this class is initialized with the broadcast address, with the purpose of retrieving the address of a sensor connected.

Returns:int – Address of the PosCon3D sensor connected to the RS-485 bus.

Note

Only one PosCon3D sensor can be connected to the bus for this operation to succeed.

get_live_monitor_data()[source]

Retrieves the distance to the surface in the center of the laser beam and the angle at which it’s found.

Returns:list – angle and distance to the reference surface.

Note

This function is designed to aid in the installation of the sensor at an angle.

get_measurement()[source]

Retrieves the current measurement of the sensor according to the current settings.

Returns:tuple – The current measurement and additionally a value indicating the quality of the measured value.
send_command(address, command, data=None)[source]

Sends a command to the sensor’s address specified. The command can optionally contain a data string.

This method is mostly for internal use, as the higher-level API is exposed via dedicated methods.

Parameters:
  • address (int) – PosCon3D sensors have an address assigned, which defaults to 1. There’s also a broadcast address (PosCon3D.BROADCAST_ADDRESS) that can be used to query the address of the sensor connected to the RS-485 bus. Only one sensor can be in the bus when using the broadcast address to query for sensor’s address.
  • command (string) – A string indicating the command number to be executed.
  • data (string) – An optional string of data that is sent together with the command.
Returns:

Result of the command. It can be a list or a single value depending on the operation.

set_edge_height(height)[source]

Defines the minimum height of an edge to be detected.

Parameters:height (float) – Minimum edge height.
set_flex_mount(angle, distance)[source]

Sets the FLEX Mount feature to a specific angle and distance.

set_measurement_type(measurement_type)[source]

Defines the measurement type to use.

Measurement type Function
“Edge L rise” Edge
“Edge L fall” Edge
“Edge R rise” Edge
“Edge R fall” Edge
“Width” Width
“Center width” Width
“Gap” Gap
“Center gap” Gap
Parameters:measurement_type (string) – Measurement type.
set_precision(precision)[source]

Defines the precision the sensor will use to determine edges:

Value Precision Function values
0 Standard Median=off, Moving Average=off
1 High Median=7, Moving Average=16
2 Very High Median=15, Moving Average=128
Parameters:precision (int) – Sensor precision to use.

Note

The higher the precision, the slower the measurement gets.