Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpForceTorqueIitSensor Class Reference

#include <visp3/sensor/vpForceTorqueIitSensor.h>

Public Member Functions

 vpForceTorqueIitSensor ()
 
 ~vpForceTorqueIitSensor ()
 
void bias ()
 
bool connected (int timeout_ms=0) const
 
vpColVector getForceTorque (bool filtered=false)
 
void startStreaming ()
 
void stopStreaming ()
 

Protected Member Functions

void acquisitionLoop ()
 
void close ()
 
void join ()
 

Protected Attributes

ftSensorLib m_ftLib
 
int m_numSensorsInLib
 
vpColVector m_ft
 
vpColVector m_ft_filt
 
ftSensorsConnected m_ftSensorsData {}
 
std::atomic< bool > m_acquisitionEnabled
 
std::atomic< bool > m_dataValid
 
bool m_connected
 
std::thread m_acquisitionThread
 
std::chrono::time_point< std::chrono::system_clock > m_timeCur
 
std::chrono::time_point< std::chrono::system_clock > m_timePrev
 
std::mutex m_mutex
 
int m_warmupMilliseconds
 

Detailed Description

This class is a wrapper over six axis load measurement (forces and torques) from IIT (ISTITUTO ITALIANO DI TECNOLOGIA) sell by Alberobotics.

The following example shows how to use this class to stream force-torque data at 1kHz and print a measurement each second.

#include <iostream>
#include <visp3/core/vpTime.h>
#include <visp3/sensor/vpForceTorqueIitSensor.h>
int main()
{
#ifdef VISP_HAVE_FT_IIT_SDK
if ( ! iit_ft.connected() ) {
std::cout << "Unable to connect to IIT force-torque sensor" << std::endl;
return EXIT_SUCCESS;
}
iit_ft.bias();
iit_ft.startStreaming();
for(int i=0; i < 10; i++) {
ft = iit_ft.getForceTorque();
std::cout << ft.t() << std::endl;
}
iit_ft.stopStreaming();
#else
std::cout << "ViSP is not build with IIT force-torque SDK support" << std::endl;
#endif
return EXIT_SUCCESS;
}

Once build, in the same folder as the binary you should find a configuration file named configurationSettings.ini.

  • Such a file is provided in $VISP_WS/modules/sensor/test/force-torque/configurationSettings.ini with default settings.
    ; Configuration Settings for FT Sensor LIB
    [GENERAL] ; General Settings
    NUM_SENSORS = 1 ; Number of Connected FT Sensors
    MULTI_SENSOR_MODE = false ; Multi Sensor Mode: if "true", the library
    ; will use the BASE_SETTINGS in order to
    ; initialize the communication with the number of
    ; sensors (NUM_SENSORS) it is initialized with.
    ; If "false", then the library will check
    ; the "USE_DEFAULT_SETTINGS".
    USE_DEFAULT_SETTINGS = true ; If "true", the library will use the
    ; DEFAULT_SETTINGS. Note that the sensor
    ; needs to be in the "DEF" IP position.
    ; If "false", the library will use the
    ; USER_SETTINGS to initialize the communication
    ; with the sensor.
    BROADCAST_POLICY = 255 ; Sensor Broadcast Policy: 255
    BROADCAST_RATE = 2 ; Sensor Broadcast Rate: represents number of multiples of 0.5 msec,
    ; with minimum value of 2 e.g. 2*0.5 = 1 msec
    LOCAL_IFACE_IP = 192.168.1.100 ; Host Computer's local interface IP
    LOCAL_PORT = 2000 ; Host Computer's local interface IP
    LOCAL_IFACE = enp0s20f0u1u3 ; Host Computer's local interface name (it is required only in Linux)
    [DEFAULT_SETTINGS] ; DEFAULT SETTINGS FOR USE IN SINGLE_SENSOR_MODE when USE_DEFAULT_SETTINGS=true
    DEFAULT_IP = 192.168.1.1 ; Default Sensor IP
    DEFAULT_PORT = 23 ; Default UDP Port
    [USER_SETTINGS] ; USER SETTINGS FOR USE IN SINGLE_SENSOR_MODE when USE_DEFAULT_SETTINGS=false
    USER_IP = 192.168.1.1 ; User Sensor IP
    USER_PORT = 2000 ; User UDP Port
    [BASE_SETTINGS] ; BASE SETTINGS FOR USE IN MULTI_SENSOR_MODE when MULTI_SENSOR_MODE=true
    BASE_IP = 169.254.89.20 ; Base Sensor IP
    BASE_PORT = 22 ; Base UDP Port
    BASE_FIRST_BOARD_NUMBER = 1 ; Base First Sensor Board Number. range 1-9
  • To modify default settings you need first to identify your Ethernet link:
    $ ifconfig
    enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255
  • and then modify accordingly the following lines:
    LOCAL_IFACE_IP = 192.168.100.100       ; Host Computer's local interface IP
    LOCAL_IFACE = enp0s31f6                ; Host Computer's local interface name (it is required only in Linux)
  • The sensor default IP is set to 192.168.1.1. Browsing to this address with Firefox allows to modify it's default IP address. If the new sensor IP address is for example 192.168.100.10, you need to modify the following line:
    USE_DEFAULT_SETTINGS = false           ; If "true", the library will use the
                                           ; DEFAULT_SETTINGS. Note that the sensor
                                           ; needs to be in the "DEF" IP position.
                                           ; If "false", the library will use the
                                           ; USER_SETTINGS to initialize the communication
                                           ; with the sensor.
    [USER_SETTINGS]                        ; USER SETTINGS FOR USE IN SINGLE_SENSOR_MODE when USE_DEFAULT_SETTINGS=false
    USER_IP = 192.168.100.10               ; User Sensor IP

When running a binary that uses vpForceTorqueIitSensor class,

  • if you experience the following error:
    $ cd $VISP_WS/modules/sensor
    $ ./testForceTorqueIitSensor-simple
    ./testForceTorqueIitSensor-simple: error while loading shared libraries: libftSensorLib.so.0.0.1: cannot open shared
    object file: No such file or directory
  • it means that you need to add the location of the library in LD_LIBRARY_PATH environment variable. This could be achieved running:
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VISP_WS/3rdparty/FT_SDK_01_4/linux/ubuntu16.04/ftSensorLibReleaseExamples/library/bin/lin-x86_64/release
    where $VISP_WS/3rdparty/FT_SDK_01_4 contains IIT SDK.

To configure the sensor, you may access the sensor through the web interface using uour favorite browser.

vpForceTorqueIitSensor-ethernet.png
Examples:
testForceTorqueIitSensor.cpp.

Definition at line 146 of file vpForceTorqueIitSensor.h.

Constructor & Destructor Documentation

◆ vpForceTorqueIitSensor()

vpForceTorqueIitSensor::vpForceTorqueIitSensor ( )

Default constructor.

Establish communication with sensor(-s) and start data acquisition thread.

Definition at line 54 of file vpForceTorqueIitSensor.cpp.

References m_connected, m_ftLib, and m_numSensorsInLib.

◆ ~vpForceTorqueIitSensor()

vpForceTorqueIitSensor::~vpForceTorqueIitSensor ( )

Destructor that stops streaming

Definition at line 93 of file vpForceTorqueIitSensor.cpp.

References close().

Member Function Documentation

◆ acquisitionLoop()

void vpForceTorqueIitSensor::acquisitionLoop ( )
protected

Acquisition loop. Warm up the sensor

Definition at line 108 of file vpForceTorqueIitSensor.cpp.

References m_acquisitionEnabled, m_dataValid, m_ft, m_ft_filt, m_ftLib, m_ftSensorsData, m_mutex, m_timeCur, m_timePrev, and m_warmupMilliseconds.

Referenced by startStreaming().

◆ bias()

void vpForceTorqueIitSensor::bias ( )

Bias all sensors by TCP.

Examples:
testForceTorqueIitSensor.cpp.

Definition at line 159 of file vpForceTorqueIitSensor.cpp.

References m_ftLib.

◆ close()

void vpForceTorqueIitSensor::close ( )
protected

Stops data streaming.

Definition at line 83 of file vpForceTorqueIitSensor.cpp.

References m_acquisitionEnabled, m_dataValid, and m_ftLib.

Referenced by ~vpForceTorqueIitSensor().

◆ connected()

bool vpForceTorqueIitSensor::connected ( int  timeout_ms = 0) const

Return true if communication established with at least one sensor.

Parameters
timeout_ms: Timeout in milliseconds.

If you get the following error:

[ ERROR: ] Connection failed! Error Connection refused

it means probably that you didn't set the right parameters in the configuration file configurationSettings.ini. See class description to get some hints.

Examples:
testForceTorqueIitSensor.cpp.

Definition at line 172 of file vpForceTorqueIitSensor.cpp.

References vpChrono::getDurationMs(), m_connected, vpTime::sleepMs(), and vpChrono::start().

◆ getForceTorque()

vpColVector vpForceTorqueIitSensor::getForceTorque ( bool  filtered = false)

Get force-torque data in SI units.

Parameters
[in]filtered: When true return filtered force-torque measurements, when false return raw data. If no filter is configured while getting filtered measurements, the SDK will retun the raw data. To configure the filter, you must access the sensor through the web interface. The default ip address is 192.168.1.1 if in default mode. Once in the web interface select NETWORK SETTINGS and you can configure the Data Filtering Settings:
  • Filter Type: Low-Pass or High-Pass Butterworth
  • Filter Order: 1, 2 or 3
  • Cut-off Frequency: frequency in Hz
Returns
A 6-dim vector $[F_x \; F_y \; F_z \; T_x \; T_y \; T_z]^T$ with forces $F_x$, $F_y$, $F_z$ in N, and torques $T_x$, $T_y$, $T_z$ in Nm.

As shown in the next image, our sensor has IP 192.168.100.10. Filtering is configured as Low-Pass, with a 3 order filter and a 10 Hz cutt-off frequency.

vpForceTorqueIitSensor-ethernet.png
Examples:
testForceTorqueIitSensor.cpp.

Definition at line 205 of file vpForceTorqueIitSensor.cpp.

References m_ft, m_ft_filt, and m_mutex.

◆ join()

void vpForceTorqueIitSensor::join ( )
protected

Join acquisition thread.

Definition at line 98 of file vpForceTorqueIitSensor.cpp.

References m_acquisitionThread.

◆ startStreaming()

void vpForceTorqueIitSensor::startStreaming ( )

Start acquisition thread and wait until data are available.

Examples:
testForceTorqueIitSensor.cpp.

Definition at line 220 of file vpForceTorqueIitSensor.cpp.

References acquisitionLoop(), m_acquisitionEnabled, m_acquisitionThread, m_dataValid, and vpTime::wait().

◆ stopStreaming()

void vpForceTorqueIitSensor::stopStreaming ( )

Stop acquisition thread.

Examples:
testForceTorqueIitSensor.cpp.

Definition at line 233 of file vpForceTorqueIitSensor.cpp.

References m_acquisitionEnabled, and m_acquisitionThread.

Member Data Documentation

◆ m_acquisitionEnabled

std::atomic<bool> vpForceTorqueIitSensor::m_acquisitionEnabled
protected

Definition at line 173 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), close(), startStreaming(), and stopStreaming().

◆ m_acquisitionThread

std::thread vpForceTorqueIitSensor::m_acquisitionThread
protected

Definition at line 177 of file vpForceTorqueIitSensor.h.

Referenced by join(), startStreaming(), and stopStreaming().

◆ m_connected

bool vpForceTorqueIitSensor::m_connected
protected

Definition at line 175 of file vpForceTorqueIitSensor.h.

Referenced by connected(), and vpForceTorqueIitSensor().

◆ m_dataValid

std::atomic<bool> vpForceTorqueIitSensor::m_dataValid
protected

Definition at line 174 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), close(), and startStreaming().

◆ m_ft

vpColVector vpForceTorqueIitSensor::m_ft
protected

Definition at line 168 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), and getForceTorque().

◆ m_ft_filt

vpColVector vpForceTorqueIitSensor::m_ft_filt
protected

Definition at line 169 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), and getForceTorque().

◆ m_ftLib

ftSensorLib vpForceTorqueIitSensor::m_ftLib
protected

Definition at line 165 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), bias(), close(), and vpForceTorqueIitSensor().

◆ m_ftSensorsData

ftSensorsConnected vpForceTorqueIitSensor::m_ftSensorsData {}
protected

Definition at line 171 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop().

◆ m_mutex

std::mutex vpForceTorqueIitSensor::m_mutex
protected

Definition at line 180 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop(), and getForceTorque().

◆ m_numSensorsInLib

int vpForceTorqueIitSensor::m_numSensorsInLib
protected

Definition at line 166 of file vpForceTorqueIitSensor.h.

Referenced by vpForceTorqueIitSensor().

◆ m_timeCur

std::chrono::time_point<std::chrono::system_clock> vpForceTorqueIitSensor::m_timeCur
protected

Definition at line 178 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop().

◆ m_timePrev

std::chrono::time_point<std::chrono::system_clock> vpForceTorqueIitSensor::m_timePrev
protected

Definition at line 178 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop().

◆ m_warmupMilliseconds

int vpForceTorqueIitSensor::m_warmupMilliseconds
protected

Definition at line 181 of file vpForceTorqueIitSensor.h.

Referenced by acquisitionLoop().