31 #include <boost/lexical_cast.hpp> 32 #include <boost/algorithm/string/trim.hpp> 40 using boost::lexical_cast;
52 std::string trimmed = responseBuffer.substr(1);
60 T parsed = lexical_cast<T>(trimmed);
122 ROS_INFO(
"Sending command to reset PTU.");
128 std::string actual_response, expected_response(
"!T!T!P!P*");
131 for (
int i = 0; i < 300; i++)
137 ROS_INFO(
"PTU reset command response received.");
138 ser_->
read(actual_response, expected_response.length());
139 return (actual_response == expected_response);
143 ROS_WARN(
"PTU reset command response not received before timeout.");
152 std::string buffer =
sendCommand(std::string() + type +
"r ");
154 if (buffer.length() < 3 || buffer[0] !=
'*')
160 double z = parseResponse<double>(buffer);
162 return z * M_PI / 180;
170 std::string buffer =
sendCommand(std::string() + type + limType +
" ");
172 if (buffer.length() < 3 || buffer[0] !=
'*')
178 return parseResponse<int>(buffer);
187 std::string buffer =
sendCommand(std::string() + type +
"p ");
189 if (buffer.length() < 3 || buffer[0] !=
'*')
218 std::string buffer =
sendCommand(std::string() + type +
"p" +
219 lexical_cast<std::string>(count) +
" ");
221 if (buffer.empty() || buffer[0] !=
'*')
243 std::string buffer =
sendCommand(std::string() + type +
"s ");
245 if (buffer.length() < 3 || buffer[0] !=
'*')
247 ROS_ERROR(
"Error getting pan-tilt speed");
267 ROS_ERROR(
"Pan Tilt Speed Value out of Range: %c %f(%d) (%d-%d)\n",
272 std::string buffer =
sendCommand(std::string() + type +
"s" +
273 lexical_cast<std::string>(count) +
" ");
275 if (buffer.empty() || buffer[0] !=
'*')
277 ROS_ERROR(
"Error setting pan-tilt speed\n");
290 std::string buffer =
sendCommand(std::string(
"c") + type +
" ");
292 if (buffer.empty() || buffer[0] !=
'*')
294 ROS_ERROR(
"Error setting pan-tilt move mode");
309 if (buffer.length() < 3 || buffer[0] !=
'*')
315 if (buffer[2] ==
'p')
317 else if (buffer[2] ==
'i')
float getPosition(char type)
size_t readline(std::string &buffer, size_t size=65536, std::string eol="\n")
bool setPosition(char type, float pos, bool Block=false)
int TMin
Min Tilt in Counts.
int PMin
Min Pan in Counts.
bool Lim
Position Limits enabled.
int getLimit(char type, char limType)
float getResolution(char type)
#define ROS_ERROR_THROTTLE(rate,...)
int PSMin
Min Pan Speed in Counts/second.
int TSMax
Max Tilt Speed in Counts/second.
#define ROS_DEBUG_STREAM(args)
int PMax
Max Pan in Counts.
TFSIMD_FORCE_INLINE const tfScalar & z() const
T parseResponse(std::string responseBuffer)
float tr
tilt resolution (rads/count)
int PSMax
Max Pan Speed in Counts/second.
std::string sendCommand(std::string command)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
float getSpeed(char type)
size_t read(uint8_t *buffer, size_t size)
int TSMin
Min Tilt Speed in Counts/second.
float pr
pan resolution (rads/count)
bool setSpeed(char type, float speed)
int TMax
Max Tilt in Counts.
size_t write(const uint8_t *data, size_t size)