63 #define _WIN32_WINNT 0x0501 64 #pragma warning(disable: 4996) 65 #pragma warning(disable: 4267) 81 #include "sick_scan/rosconsole_simu.hpp" 83 #define _USE_MATH_DEFINES 122 bool getTagVal(std::string tagVal, std::string &tag, std::string &val)
126 pos = tagVal.find(
":=");
129 if (pos == std::string::npos)
135 tag = tagVal.substr(0, pos);
136 val = tagVal.substr(pos + 2);
145 ROS_INFO(
"Caught signal %d\n", signalRecv);
147 ROS_INFO(
"You are leaving the following version of this node:");
175 bool doInternalDebug =
false;
176 bool emulSensor =
false;
177 for (
int i = 0; i < argc; i++)
179 std::string s = argv[i];
182 if (tag.compare(
"__internalDebug") == 0)
185 sscanf(val.c_str(),
"%d", &debugState);
188 doInternalDebug =
true;
191 if (tag.compare(
"__emulSensor") == 0)
194 sscanf(val.c_str(),
"%d", &dummyState);
209 std::string scannerName;
210 if (
false == nhPriv.
getParam(
"scanner_type", scannerName))
212 ROS_ERROR(
"cannot find parameter ""scanner_type"" in the param set. Please specify scanner_type.");
213 ROS_ERROR(
"Try to set %s as fallback.\n", nodeName.c_str());
214 scannerName = nodeName;
221 nhPriv.
setParam(
"name", scannerName);
222 rossimu_settings(nhPriv);
224 nhPriv.
setParam(
"hostname",
"192.168.0.4");
225 nhPriv.
setParam(
"imu_enable",
true);
226 nhPriv.
setParam(
"cloud_topic",
"pt_cloud");
232 std::string hostname;
233 if (nhPriv.
getParam(
"hostname", hostname))
237 bool changeIP =
false;
239 if (nhPriv.
getParam(
"new_IP_address", sNewIp))
244 nhPriv.
param<std::string>(
"port", port,
"2112");
247 nhPriv.
param(
"timelimit", timelimit, 5);
249 bool subscribe_datagram;
251 nhPriv.
param(
"subscribe_datagram", subscribe_datagram,
false);
252 nhPriv.
param(
"device_number", device_number, 0);
258 char colaDialectId =
'A';
260 if (nhPriv.
getParam(
"range_min", param))
264 if (nhPriv.
getParam(
"range_max", param))
268 if (nhPriv.
getParam(
"time_increment", param))
276 bool use_binary_protocol =
true;
277 if (
true == nhPriv.
getParam(
"emul_sensor", emulSensor))
279 ROS_INFO(
"Found emul_sensor overwriting default settings. Emulation: %s", emulSensor ?
"True" :
"False");
281 if (
true == nhPriv.
getParam(
"use_binary_protocol", use_binary_protocol))
283 ROS_INFO(
"Found sopas_protocol_type param overwriting default protocol:");
284 if (use_binary_protocol ==
true)
286 ROS_INFO(
"Binary protocol activated");
292 nhPriv.
setParam(
"sopas_protocol_type",
true);
293 use_binary_protocol =
true;
294 ROS_WARN(
"This scanner type does not support ASCII communication.\n" 295 "Binary communication has been activated.\n" 296 "The parameter \"sopas_protocol_type\" has been set to \"True\".");
300 ROS_INFO(
"ASCII protocol activated");
316 bool start_services =
false;
320 sick_scan::SickScanConfig cfg;
327 ROS_INFO(
"Start initialising scanner [Ip: %s] [Port: %s]", hostname.c_str(), port.c_str());
336 ROS_ERROR(
"TCP is not switched on. Probably hostname or port not set. Use roslaunch to start node.");
343 s->setEmulSensor(
true);
348 if (
true == nhPriv.
getParam(
"start_services", start_services) &&
true == start_services)
351 ROS_INFO(
"SickScanServices: ros services initialized");
355 signal(SIGINT, SIG_DFL);
377 result = s->loopOnce();
386 ROS_ERROR(
"Invalid run state in main loop");
void set_range_max(float max)
Setting maximum range.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
static std::string versionInfo
std::string getVersionInfo()
static bool isInitialized
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int mainGenericLaser(int argc, char **argv, std::string nodeName)
Internal Startup routine.
void my_handler(int signalRecv)
int getNumberOfLayers(void)
Getting number of scanner layers.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool getTagVal(std::string tagVal, std::string &tag, std::string &val)
splitting expressions like <tag>:=into <tag> and
bool getUseBinaryProtocol(void)
flag to decide between usage of ASCII-sopas or BINARY-sopas
ScannerBasicParam * getCurrentParamPtr()
Gets Pointer to parameter object.
bool getParam(const std::string &key, std::string &s) const
void set_time_increment(float time)
setting time increment between shots
void set_range_min(float min)
Setting minimum range.
ROSCPP_DECL void shutdown()
void setUseBinaryProtocol(bool _useBinary)
flag to decide between usage of ASCII-sopas or BINARY-sopas
ROSCPP_DECL void spinOnce()
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
static sick_scan::SickScanCommonTcp * s
void setVersionInfo(std::string _versionInfo)