Visual Servoing Platform  version 3.2.1 under development (2019-08-19)
vpForceTorqueAtiNetFTSensor Class Reference

#include <visp3/sensor/vpForceTorqueAtiNetFTSensor.h>

+ Inheritance diagram for vpForceTorqueAtiNetFTSensor:

Public Member Functions

 vpForceTorqueAtiNetFTSensor ()
 
 vpForceTorqueAtiNetFTSensor (const std::string &hostname, const int port)
 
virtual ~vpForceTorqueAtiNetFTSensor ()
 
void bias (unsigned int n_counts=50)
 
unsigned long getCountsPerForce () const
 
unsigned long getCountsPerTorque () const
 
unsigned long getDataCounter () const
 
unsigned long getScalingFactor () const
 
vpColVector getForceTorque () const
 
void setCountsPerForce (unsigned long counts)
 
void setCountsPerTorque (unsigned long counts)
 
void setScalingFactor (unsigned long scaling_factor)
 
bool startStreaming ()
 
void stopStreaming ()
 
void unbias ()
 
bool waitForNewData (unsigned int timeout=50)
 
Inherited functionalities from vpUDPClient
void init (const std::string &hostname, const int port)
 
int receive (std::string &msg, const int timeoutMs=0)
 
int receive (void *msg, size_t len, const int timeoutMs=0)
 
int send (const std::string &msg)
 
int send (const void *msg, size_t len)
 

Protected Attributes

unsigned long m_counts_per_force
 
unsigned long m_counts_per_torque
 
unsigned long m_scaling_factor
 
vpColVector m_ft_bias
 
unsigned long m_data_count
 
unsigned long m_data_count_prev
 
vpColVector m_ft
 
bool m_is_streaming_started
 
bool m_is_init
 

Detailed Description

Interface for ATI force/torque sensor using Net F/T over UDP.

The Network Force/Torque (Net F/T) sensor system measures six components of force and torque (Fx, Fy, Fz, Tx, Ty, Tz). The Net F/T provides an EtherNet/IP communication interface and is compatible with standard Ethernet. The Net F/T system is available with any of ATI transducer models. The Net F/T's web browser interface allows for easy configuration and set up via the Ethernet connection present on all NetBox models.

This class was tested with ATI Nano 43 F/T sensor connected to a NetBox. To use this class, you don't need to install any specific third-party.

To use this class, connect an Ethernet cable to the NetBox. The default IP address of the Net F/T is: 192.168.1.1. The default Ethernet port is 49152. You can use your favorite web browser on http://192.168.1.1 to modify Net F/T sensor settings and select sensor calibration configuration.

The following example shows how to use this class to get F/T measurements.

#include <iostream>
#include <visp3/sensor/vpForceTorqueAtiNetFTSensor.h>
int main(int argc, char **argv)
{
vpForceTorqueAtiNetFTSensor ati_net_ft("192.168.1.1", 49152);
ati_net_ft.startStreaming();
ati_net_ft.bias();
while (1) {
double t = vpTime::measureTimeMs();
if (ati_net_ft.waitForNewData()) {
vpColVector ft = ati_net_ft.getForceTorque();
std::cout << "F/T: " << ft.t() << std::endl;
}
std::cout << "Loop time: " << vpTime::measureTimeMs() - t << " ms" << std::endl;
}
}

It produces the following output:

F/T: -0.00150018 0.0030764 -0.00791356 -8.22294e-06 4.18799e-05 1.078288e-05
Loop time: 0.03393554688 ms
...

where 3 first values are forces Fx, Fy, Fz in N and the 3 last are torques Tx, Ty, Tz in Nm.

Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 101 of file vpForceTorqueAtiNetFTSensor.h.

Constructor & Destructor Documentation

◆ vpForceTorqueAtiNetFTSensor() [1/2]

vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor ( )

Default constructor that set counts per force to 1000000, counts per torque to 1000000000 and scaling factor to 1. Note that counts per force, counts per torque and scaling factor are used to transform force / torque in user units (N and Nm). These default values could be changed using setCountsPerForce(), setCountsPerTorque() and setScalingFactor().

Definition at line 59 of file vpForceTorqueAtiNetFTSensor.cpp.

◆ vpForceTorqueAtiNetFTSensor() [2/2]

vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor ( const std::string &  hostname,
const int  port 
)

Constructor that initializes an Eternet UDP connection to a given hostname and port.

Parameters
hostname: Device hostname or IP address.
port: Ethernet port.

Definition at line 70 of file vpForceTorqueAtiNetFTSensor.cpp.

◆ ~vpForceTorqueAtiNetFTSensor()

vpForceTorqueAtiNetFTSensor::~vpForceTorqueAtiNetFTSensor ( )
virtual

Destructor that stops Net F/T streaming and closes the Ethernet connection with the device.

See also
stopStreaming()

Definition at line 145 of file vpForceTorqueAtiNetFTSensor.cpp.

References m_is_streaming_started, and stopStreaming().

Member Function Documentation

◆ bias()

void vpForceTorqueAtiNetFTSensor::bias ( unsigned int  n_counts = 50)

Bias F/T sensor. Bias value is a mean over a given number of counts.

Warning
This function is blocking. Between 2 successive counts we wait for 5 ms.
Parameters
n_counts: Number of counts used to bias.
See also
unbias()
Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 159 of file vpForceTorqueAtiNetFTSensor.cpp.

References getForceTorque(), m_ft_bias, vpUDPClient::m_is_init, m_is_streaming_started, vpException::notInitialized, and waitForNewData().

◆ getCountsPerForce()

unsigned long vpForceTorqueAtiNetFTSensor::getCountsPerForce ( ) const
inline
Returns
Counts per force used to tranform measured data in N.
See also
getCountsPerTorque(), getForceTorque()

Definition at line 113 of file vpForceTorqueAtiNetFTSensor.h.

◆ getCountsPerTorque()

unsigned long vpForceTorqueAtiNetFTSensor::getCountsPerTorque ( ) const
inline
Returns
Counts per torque used to tranform measured data in Nm.
See also
getCountsPerForce(), getForceTorque()

Definition at line 118 of file vpForceTorqueAtiNetFTSensor.h.

◆ getDataCounter()

unsigned long vpForceTorqueAtiNetFTSensor::getDataCounter ( ) const
inline
Returns
Data counter. Each call to waitForNewData() will increment data counter when a new data is received.

Definition at line 122 of file vpForceTorqueAtiNetFTSensor.h.

◆ getForceTorque()

vpColVector vpForceTorqueAtiNetFTSensor::getForceTorque ( ) const

Return force / torque measurements in user units, respectively N and Nm.

To obtain the force and torque values in user units (N and Nm), each received force value is internally multiplied by the scaling factor and divided by the counts per force and each received torque value is internally multiplied by the scaling factor and divided by the counts per torque.

Returns
A 6-dim vector that contains the 3 forces and 3 torques [Fx, Fy, Fz, Tx, Ty, Tz] with forces in N and torques in Nm.
Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 200 of file vpForceTorqueAtiNetFTSensor.cpp.

References m_data_count, m_data_count_prev, m_ft, vpUDPClient::m_is_init, m_is_streaming_started, and vpException::notInitialized.

Referenced by bias().

◆ getScalingFactor()

unsigned long vpForceTorqueAtiNetFTSensor::getScalingFactor ( ) const
inline
Returns
Scaling factor to transform measured data in user units (N and Nm).
See also
getCountsPerForce(), getCountsPerTorque(), getForceTorque()

Definition at line 127 of file vpForceTorqueAtiNetFTSensor.h.

◆ init()

void vpUDPClient::init ( const std::string &  hostname,
const int  port 
)
inherited

Initialize a (IPv4) UDP client.

Parameters
hostname: Server hostname or IP address.
port: Server port number.
Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 116 of file vpUDPClient.cpp.

References vpException::fatalError, and vpUDPClient::m_is_init.

Referenced by vpUDPClient::vpUDPClient().

◆ receive() [1/2]

int vpUDPClient::receive ( std::string &  msg,
const int  timeoutMs = 0 
)
inherited

Receive data sent by the server.

Parameters
msg: ASCII message or byte data.
timeoutMs: Timeout in millisecond (if zero, the call is blocking).
Returns
The message length / size of the byte array sent received, or -1 if there is an error, or 0 if there is a timeout.
Note
To transform the ASCII representation of an integer:
int val = atoi(msg.c_str());
//or
std::istringstream ss(msg);
ss >> val;
To convert from a byte array to an integer:
int val = *reinterpret_cast<const int *>(msg.c_str());
Examples:
testUDPClient.cpp.

Definition at line 193 of file vpUDPClient.cpp.

References vpUDPClient::m_is_init, and vpException::notInitialized.

Referenced by waitForNewData().

◆ receive() [2/2]

int vpUDPClient::receive ( void *  msg,
size_t  len,
const int  timeoutMs = 0 
)
inherited

Receive data sent by the server.

Parameters
msg: A message to send over the network.
len: Message length.
timeoutMs: Timeout in millisecond (if zero, the call is blocking).
Returns
The message length / size of the byte array sent received, or -1 if there is an error, or 0 if there is a timeout.

Definition at line 239 of file vpUDPClient.cpp.

References vpUDPClient::m_is_init, and vpException::notInitialized.

◆ send() [1/2]

int vpUDPClient::send ( const std::string &  msg)
inherited

Send data to the server.

Parameters
msg: ASCII message or byte data.
Returns
The message length / size of the byte array sent.
Note
To send the ASCII representation of an integer:
int val = 1024;
std::ostringstream os;
os << val;
server.send(os.str(), hostname, port);
To send directly the byte data (assuming the same integer representation on the server and the client):
int val = 1024;
char data[sizeof(val)];
memcpy(data, &val, sizeof(val));
std::string msg(data, sizeof(val)); //required to avoid the string being splitted with the first \0 character
server.send(msg, hostname, port);
Examples:
testUDPClient.cpp.

Definition at line 300 of file vpUDPClient.cpp.

References vpUDPClient::m_is_init, and vpException::notInitialized.

Referenced by startStreaming(), and stopStreaming().

◆ send() [2/2]

int vpUDPClient::send ( const void *  msg,
size_t  len 
)
inherited

Send data to the server.

Parameters
msg: Message to send.
len: Message length.
Returns
The message length / size of the byte array sent.

Definition at line 329 of file vpUDPClient.cpp.

References vpUDPClient::m_is_init, and vpException::notInitialized.

◆ setCountsPerForce()

void vpForceTorqueAtiNetFTSensor::setCountsPerForce ( unsigned long  counts)
inline

Set counts per force value. Default value is 1000000.

Parameters
counts: Counts per force.
See also
setCountsPerTorque(), setScalingFactor()

Definition at line 134 of file vpForceTorqueAtiNetFTSensor.h.

◆ setCountsPerTorque()

void vpForceTorqueAtiNetFTSensor::setCountsPerTorque ( unsigned long  counts)
inline

Set counts per torque value. Default value is 1000000000.

Parameters
counts: Counts per torque.
See also
setCountsPerForce(), setScalingFactor()

Definition at line 140 of file vpForceTorqueAtiNetFTSensor.h.

◆ setScalingFactor()

void vpForceTorqueAtiNetFTSensor::setScalingFactor ( unsigned long  scaling_factor)
inline

Set scaling factor. Default value is 1.

Parameters
scaling_factor: scaling factor.
See also
setCountsPerForce(), setCountsPerTorque()

Definition at line 146 of file vpForceTorqueAtiNetFTSensor.h.

◆ startStreaming()

bool vpForceTorqueAtiNetFTSensor::startStreaming ( )

Start high-speed real-time Net F/T streaming.

Returns
True if streaming was started, false otherwise.
Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 80 of file vpForceTorqueAtiNetFTSensor.cpp.

References vpUDPClient::m_is_init, m_is_streaming_started, vpException::notInitialized, vpUDPClient::send(), and waitForNewData().

◆ stopStreaming()

void vpForceTorqueAtiNetFTSensor::stopStreaming ( )

Stop high-speed real-time Net F/T streaming.

Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 116 of file vpForceTorqueAtiNetFTSensor.cpp.

References vpUDPClient::m_is_init, m_is_streaming_started, vpException::notInitialized, and vpUDPClient::send().

Referenced by ~vpForceTorqueAtiNetFTSensor().

◆ unbias()

void vpForceTorqueAtiNetFTSensor::unbias ( )

Unbias F/T sensor.

See also
bias()
Examples:
testForceTorqueAtiNetFTSensor.cpp.

Definition at line 188 of file vpForceTorqueAtiNetFTSensor.cpp.

References m_ft_bias.

◆ waitForNewData()

bool vpForceTorqueAtiNetFTSensor::waitForNewData ( unsigned int  timeout = 50)

Member Data Documentation

◆ m_counts_per_force

unsigned long vpForceTorqueAtiNetFTSensor::m_counts_per_force
protected

Definition at line 154 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by waitForNewData().

◆ m_counts_per_torque

unsigned long vpForceTorqueAtiNetFTSensor::m_counts_per_torque
protected

Definition at line 155 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by waitForNewData().

◆ m_data_count

unsigned long vpForceTorqueAtiNetFTSensor::m_data_count
protected

Definition at line 158 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by getForceTorque(), and waitForNewData().

◆ m_data_count_prev

unsigned long vpForceTorqueAtiNetFTSensor::m_data_count_prev
protected

Definition at line 159 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by getForceTorque(), and waitForNewData().

◆ m_ft

vpColVector vpForceTorqueAtiNetFTSensor::m_ft
protected

Definition at line 160 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by getForceTorque(), and waitForNewData().

◆ m_ft_bias

vpColVector vpForceTorqueAtiNetFTSensor::m_ft_bias
protected

Definition at line 157 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by bias(), unbias(), and waitForNewData().

◆ m_is_init

◆ m_is_streaming_started

bool vpForceTorqueAtiNetFTSensor::m_is_streaming_started
protected

◆ m_scaling_factor

unsigned long vpForceTorqueAtiNetFTSensor::m_scaling_factor
protected

Definition at line 156 of file vpForceTorqueAtiNetFTSensor.h.

Referenced by waitForNewData().