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 val1 = htons(0x1234);
99 uint16_t val2 = htons(0x0002);
100 uint32_t val3 = htons(0);
101 memcpy(&request[0], &val1,
sizeof(val1));
102 memcpy(&request[2], &val2,
sizeof(val2));
103 memcpy(&request[4], &val3,
sizeof(val3));
106 if (
send(request, len) != len) {
109 std::cout <<
"wait: " << i << std::endl;
134 unsigned char request[8];
135 uint16_t val1 = htons(0x1234);
136 uint16_t val2 = htons(0x0002);
137 uint32_t val3 = htons(0);
138 memcpy(&request[0], &val1,
sizeof(val1));
139 memcpy(&request[2], &val2,
sizeof(val2));
140 memcpy(&request[4], &val3,
sizeof(val3));
143 if (
send(request, len) != len) {
186 for (
unsigned int i = 0; i < n_counts; i++) {
246 unsigned char response[36];
248 if (
receive((
void *)response, 36)) {
249 uint32_t resp1, resp2, resp3;
250 memcpy(&resp1, &response[0],
sizeof(uint32_t));
251 memcpy(&resp2, &response[4],
sizeof(uint32_t));
252 memcpy(&resp3, &response[8],
sizeof(uint32_t));
253 resp.rdt_sequence = ntohl(resp1);
254 resp.ft_sequence = ntohl(resp2);
255 resp.status = ntohl(resp3);
257 for (
int i = 0; i < 6; i++) {
259 memcpy(&resp4, &response[12 + i * 4],
sizeof(int32_t));
260 resp.FTData[i] = ntohl(resp4);
269 for (
int i = 0; i < 3; i++) {
270 m_ft[i] = resp.FTData[i] * force_factor;
272 for (
int i = 3; i < 6; i++) {
273 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()