36 this->
interface = interface;
47 Response response = interface->submitCmd(0x30,
nullptr, 0,
false);
66 printf(
"res_x = %d, res_y = %d, cell_width = %d, cell_height = %d, fullscale = %X\n",
79 for (y = 0; y < height; y++)
81 printf(
"%03X", matrix[y * width]);
83 for (
x = 1;
x < width;
x++)
85 printf(
", %03X", matrix[y * width +
x]);
95 unsigned char payload[1];
97 Response response = interface->submitCmd(0x20, payload,
sizeof(payload),
false);
98 return getFrameData(&response);
104 Response response = interface->receiveWithoutChecks();
106 if (response.
cmdId == 0x21)
108 response = interface->receiveWithoutChecks();
111 if (response.
cmdId == 0x00)
113 return getPeriodicFrameData(&response);
118 str(boost::format(
"Response ID (%02X) does not match submitted command ID (%02X)") %
119 (
int)response.
cmdId % (
int)0x00));
124TactileSensor::getPeriodicFrameData(
Response* response)
131 int count = (response->
len - offset) / 2;
133 std::shared_ptr<std::vector<short>>
data;
134 data.reset(
new std::vector<short>(count, 0));
137 for (i = 0; i < count; i++)
139 short value = response->
getShort(i * 2 + offset);
147TactileSensor::getFrameData(
Response* response)
154 int count = (response->
len - offset) / 2;
156 std::shared_ptr<std::vector<short>>
data;
157 data.reset(
new std::vector<short>(count, 0));
159 for (i = 0; i < count; i++)
165 return FrameData(
data, count);
171 unsigned char payload[3];
173 payload[1] = delay_ms & 0xFF;
174 payload[2] = (delay_ms >> 8) & 0xFF;
175 interface->fireAndForgetCmd(0x21, payload,
sizeof(payload),
false);
183 interface->fireAndForgetCmd(0x22,
nullptr, 0,
false);
186 while (waitCount > 0)
188 Response response = interface->receiveWithoutChecks();
190 if (response.
cmdId == 0x22)
198 "stopPeriodicFrameAcquisition :: Discarding Response with ID 0x%02X") %
211 unsigned char payload[1];
214 Response response = interface->submitCmd(0x23, payload,
sizeof(payload),
false);
225 unsigned char payload[4];
230 Response response = interface->submitCmd(0x31, payload,
sizeof(payload),
false);
250 unsigned char payload[2];
251 payload[0] = threshold & 0xFF;
252 payload[1] = (threshold >> 8) & 0xFF;
253 Response response = interface->submitCmd(0x34, payload,
sizeof(payload),
false);
261 Response response = interface->submitCmd(0x35,
nullptr, 0,
false);
275 unsigned char payload[1];
277 Response response = interface->submitCmd(0x36, payload,
sizeof(payload),
false);
289 Response response = interface->submitCmd(0x37,
nullptr, 0,
false);
292 unsigned char gain = response.
getByte(2);
302 Response response = interface->submitCmd(0x38,
nullptr, 0,
false);
305 std::string type = std::string((
char*)response.
data.data() + 2, response.
len - 2);
312 Response response = interface->submitCmd(0x46,
nullptr, 0,
false);
314 short value = (short)response.
getShort(2);
321 Response response = interface->submitCmd(0x50,
nullptr, 0,
false);
339 std::cout << boost::format(
"System Type=%1%, Hardware Revision=%2%, Firmware "
340 "Version=%3%.%4%.%5%.%6% (0x%7$04X), Serial Number=%8%") %
348 unsigned char* payload = (
unsigned char*)tag.c_str();
349 Response response = interface->submitCmd(0x51, payload, tag.length(),
false);
357 Response response = interface->submitCmd(0x52,
nullptr, 0,
false);
360 std::string tag = std::string((
char*)response.
data.data() + 2, response.
len - 2);
367 Response response = interface->submitCmd(0x52,
nullptr, 0,
false);
376 tag = std::string((
char*)response.
data.data() + 2, response.
len - 2);
389 return interface->toString();
395 return strm << a.interface;
std::ostream & operator<<(std::ostream &strm, const TactileSensor &a)
std::string getInterfaceInfo()
static void printMatrix(short *matrix, int width, int height)
int getAcquisitionMask(char **mask, int *mask_len)
void startPeriodicFrameAcquisition(unsigned short delay_ms)
tac_system_information_t getSystemInformation()
bool tryGetDeviceTag(std::string &tag)
float readDeviceTemperature()
PeriodicFrameData receicePeriodicFrame()
void setAquisitionWindow(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
int loop(char *data, int data_len)
unsigned short getThreshold()
void setThreshold(short threshold)
TactileSensor(std::shared_ptr< AbstractInterface > interface)
std::string getDeviceTag()
static void printMatrixInfo(tac_matrix_info_t *mi)
tac_matrix_info_t getMatrixInformation()
void tareSensorMatrix(unsigned char operation)
void setFrontEndGain(unsigned char gain)
int setAdvanvedAcquisitionMask(char *mask)
static void printSystemInformation(tac_system_information_t si)
void stopPeriodicFrameAcquisition(void)
std::string getSensorType()
FrameData readSingleFrame()
void setDeviceTag(std::string tag)
unsigned char getFrontEndGain()
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< Value > value()
unsigned short getShort(int index)
unsigned int getUInt(int index)
unsigned char getByte(int index)
std::vector< unsigned char > data
void ensureMinLength(int len)