38 #include <visp3/core/vpConfig.h>
39 #include <visp3/core/vpException.h>
40 #include <visp3/core/vpTime.h>
41 #include <visp3/sensor/vpForceTorqueAtiNetFTSensor.h>
46 #ifdef VISP_HAVE_FUNC_INET_NTOP
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49 typedef struct response_struct
51 uint32_t rdt_sequence;
66 :
vpUDPClient(), m_counts_per_force(1000000), m_counts_per_torque(1000000000), m_scaling_factor(1), m_ft_bias(6, 0),
67 m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false)
76 :
vpUDPClient(hostname, port), m_counts_per_force(1000000), m_counts_per_torque(1000000000), m_scaling_factor(1),
77 m_ft_bias(6, 0), m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false)
95 for (
unsigned int i = 0; i < 10; ++i) {
97 unsigned char request[8];
98 *(uint16_t *)&request[0] = htons(0x1234);
99 *(uint16_t *)&request[2] = htons(0x0002);
100 *(uint32_t *)&request[4] = htonl(0);
103 if (
send(request, len) != len) {
106 std::cout <<
"wait: " << i << std::endl;
131 unsigned char request[8];
132 *(uint16_t *)&request[0] = htons(0x1234);
133 *(uint16_t *)&request[2] = htons(0x0000);
134 *(uint32_t *)&request[4] = htonl(0);
137 if (
send(request, len) != len) {
180 for (
unsigned int i = 0; i < n_counts; i++) {
240 unsigned char response[36];
242 if (
receive((
void *)response, 36)) {
243 resp.rdt_sequence = ntohl(*(uint32_t *)&response[0]);
244 resp.ft_sequence = ntohl(*(uint32_t *)&response[4]);
245 resp.status = ntohl(*(uint32_t *)&response[8]);
246 for (
int i = 0; i < 6; i++) {
247 resp.FTData[i] = ntohl(*(int32_t *)&response[12 + i * 4]);
256 for (
int i = 0; i < 3; i++) {
257 m_ft[i] = resp.FTData[i] * force_factor;
259 for (
int i = 3; i < 6; i++) {
260 m_ft[i] = resp.FTData[i] * torque_factor;
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
bool m_is_streaming_started
vpColVector getForceTorque() const
unsigned long m_counts_per_force
unsigned long m_scaling_factor
void bias(unsigned int n_counts=50)
unsigned long m_data_count_prev
unsigned long m_data_count
virtual ~vpForceTorqueAtiNetFTSensor() VP_OVERRIDE
unsigned long m_counts_per_torque
vpForceTorqueAtiNetFTSensor()
bool waitForNewData(unsigned int timeout=50)
This class implements a basic (IPv4) User Datagram Protocol (UDP) client.
int receive(std::string &msg, int timeoutMs=0)
int send(const std::string &msg)
VISP_EXPORT void sleepMs(double t)
VISP_EXPORT double measureTimeMs()