rossimu.cpp
Go to the documentation of this file.
1 #pragma warning(disable: 4996)
2 #pragma warning(disable: 4267)
3 
4 #define _USE_MATH_DEFINES
5 #include <math.h>
7 
8 
9 #include "ros/forwards.h"
10 #include "ros/publisher.h"
11 #include "ros/subscriber.h"
12 #include "ros/service_server.h"
13 #include "ros/service_client.h"
14 #include "ros/timer.h"
15 #include "ros/rate.h"
16 #include "ros/wall_timer.h"
17 #include "ros/advertise_options.h"
18 #include "ros/advertise_service_options.h"
19 #include "ros/subscribe_options.h"
20 #include "ros/service_client_options.h"
21 #include "ros/timer_options.h"
22 #include "ros/wall_timer_options.h"
23 #include "ros/spinner.h"
24 #include "ros/init.h"
25 
26 
27 //#include <boost/bind.hpp>
28 
29 #include <xmlrpcpp/XmlRpcValue.h>
30 
31 #ifndef _MSC_VER
32 #define __cdecl
33 #endif
34 std::string unknownNode = "????";
35 
37 {
38 public:
39  // Some accessor functions for the class, itself
40  bool hasTag(std::string tag)
41  {
42  std::map<std::string, std::string>::const_iterator find = mMapString.find(tag);
43  if (find != mMapString.end())
44  {
45  return(true);
46  }
47  else
48  {
49  return(false);
50  }
51 
52  }
53  std::string getVal(std::string tag) const
54  {
55  std::string s;
56  std::map<std::string, std::string>::const_iterator find = mMapString.find(tag);
57  if (find != mMapString.end())
58  {
59  // If we find it return the value.
60  return find->second;
61  }
62  return("");
63  }
64 
65  void setVal(std::string tag, std::string val)
66  {
67  mMapString[tag] = val;
68  }
69 
70  // The magic function, which allows access to the class from anywhere
71  // To get the value of the instance of the class, call:
72  // StringSingleton::Instance().GetString();
74  {
75  // This line only runs once, thus creating the only instance in existence
76  static MapStringSingleton *instance = new MapStringSingleton;
77  // dereferencing the variable here, saves the caller from having to use
78  // the arrow operator, and removes temptation to try and delete the
79  // returned instance.
80  return *instance; // always returns the same instance
81  }
82 
83 private:
84  // We need to make some given functions private to finish the definition of the singleton
85  MapStringSingleton() {} // default constructor available only to members or friends of this class
86 
87  // Note that the next two functions are not given bodies, thus any attempt
88  // to call them implicitly will return as compiler errors. This prevents
89  // accidental copying of the only instance of the class.
90  MapStringSingleton(const MapStringSingleton &old); // disallow copy constructor
91  const MapStringSingleton &operator=(const MapStringSingleton &old); //disallow assignment operator
92 
93  // Note that although this should be allowed,
94  // some compilers may not implement private destructors
95  // This prevents others from deleting our one single instance, which was otherwise created on the heap
97 private: // private data for an instance of this class
98  std::map<std::string, std::string> mMapString;
99 };
100 
101 namespace roswrap
102 {
103  namespace console
104  {
105  ROSCPP_DECL bool set_logger_level(const std::string& name, console::levels::Level level)
106  {
107  return(true);
108  }
109  }
110 
112  {
113  return;
114  }
115  ROSCPP_DECL void NodeHandle::setParam(const std::string& key, int d) const
116  {
117  char szTmp[255];
119  sprintf(szTmp, "%d", d);
120  single.setVal(key, szTmp);
121  }
122 
123  ROSCPP_DECL void NodeHandle::setParam(const std::string& key, double d) const
124  {
125  char szTmp[255];
127  sprintf(szTmp, "%le", d);
128  single.setVal(key, szTmp);
129 
130  // 00530 return param::set(resolveName(key), d);
131  }
132 
133  ROSCPP_DECL void NodeHandle::setParam(const std::string& key, bool b) const
134  {
136  single.setVal(key, b ? "true" : "false");
137  }
138  void NodeHandle::setParam(const std::string& key, const std::string& s) const
139  {
141  single.setVal(key, s);
142 
143  }
144  bool NodeHandle::getParam(const std::string& key, std::string& s) const
145  {
146  bool fnd = true;
148  fnd = single.hasTag(key);
149  s = single.getVal(key);
150  return(fnd);
151  }
152  bool NodeHandle::getParam(const std::string& key, double& d) const
153  {
154  bool fnd = true;
155  double dummy = 0.0;
156  std::string s;
158  fnd = single.hasTag(key);
159  if (fnd)
160  {
161  s = single.getVal(key);
162  sscanf(s.c_str(), "%le", &dummy);
163  d = dummy;
164  }
165  return(fnd);
166  }
167  bool NodeHandle::getParam(const std::string& key, float& d) const
168  {
169  bool fnd = true;
170  float dummy = 0.0;
171  std::string s;
173  fnd = single.hasTag(key);
174  if (fnd)
175  {
176  s = single.getVal(key);
177  sscanf(s.c_str(), "%e", &dummy);
178  d = dummy;
179  }
180  return(fnd);
181  }
182  bool NodeHandle::getParam(const std::string& key, int& d) const
183  {
184  bool fnd = true;
185  int dummy = -1;
186  std::string s;
188  fnd = single.hasTag(key);
189  if (fnd)
190  {
191  s = single.getVal(key);
192  sscanf(s.c_str(), "%d", &dummy);
193  d = dummy;
194  }
195  return(fnd);
196  }
197  bool NodeHandle::getParam(const std::string& key, bool& d) const
198  {
199  bool fnd = true;
200  bool dummy = false;
201  std::string s;
203  fnd = single.hasTag(key);
204  if (fnd)
205  {
206  s = single.getVal(key);
207  if (s.length() > 0)
208  {
209  if (s[0] == '1' || s[0] == 't' || s[0] == 'T')
210  dummy = true;
211  }
212  else
213  {
214  dummy = false;
215  }
216  d = dummy;
217  }
218  return(fnd);
219  }
220 }
221 
222 namespace roswrap
223 {
224  namespace console
225  {
226  }
227 
228 }
229 
230 void ros::init(int &, char * *, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const &, unsigned int)
231 {
232  Time::init();
233 }
234 
236 {
237 }
238 
239 void ros::console::print(class ros::console::FilterBase *, void *, enum ros::console::levels::Level, char const * src_file, int src_line, char const * fmt, char const *, ...)
240 {
241 }
242 
244 {
245  if(loc)
246  loc->level_ = level;
247 }
248 
250 {
251  if (loc && loc->level_ >= ros::console::levels::Level::Info)
252  loc->logger_enabled_ = true;
253 }
254 
255 void ros::spinOnce(void)
256 {
257  usleep(100000); // sleep 100 mikroseconds
258 }
259 
260 void ros::spin(void) // difference between spinOnce and spin?
261 {
262  while(ros::ok())
263  {
264  ros::spinOnce();
265  usleep(100000); // sleep 100 mikroseconds
266  }
267 }
268 
269 void ros::shutdown(void)
270 {
271 
272 }
273 bool ros::ok(void)
274 {
275  return(true);
276 }
278 {
279  return(false);
280 }
282 {
283 }
284 
286 {
287 }
288 
290 {
292  return(s);
293 }
294 
295 
296 
298 {
299  // printf("Publisher constructor called\n");
300 }
301 
303 {
304 }
305 
307 {
308 }
309 
310 bool ros::NodeHandle::getParamCached(const std::string& key, double& d) const
311 {
312  return(true);
313 }
314 bool ros::Publisher::Impl::isValid(void)const
315 {
316  return(true);
317 }
318 
319 void ros::Publisher::publish(class std::function<class ros::SerializedMessage __cdecl(void)> const &, class ros::SerializedMessage &)const
320 {
321 
322 }
323 
325 {
326 
327 }
328 
330 {
331 
332 }
333 
335 {
336 }
337 
338 bool ros::NodeHandle::ok(void)const
339 {
340  return(true);
341 }
342 
343 std::string const & ros::this_node::getName(void)
344 {
345 
346  return(unknownNode);
347 }
348 
349 
350 class ros::Publisher ros::NodeHandle::advertise(struct ros::AdvertiseOptions &opt)
351 {
352  ros::Publisher p;
353  return(p);
354 }
355 
356 void ros::console::print(class ros::console::FilterBase *, void *, enum ros::console::levels::Level msg_level, class std::basic_stringstream<char, struct std::char_traits<char>, class std::allocator<char> > const & msg, char const *, int, char const *)
357 {
358  if (msg_level >= ros::console::levels::Level::Info)
359  {
360  std::string level_str;
361  switch (msg_level)
362  {
364  level_str = "[DEBUG]";
365  break;
367  level_str = "[Info]";
368  break;
370  level_str = "[Warn]";
371  break;
373  level_str = "[Error]";
374  break;
376  level_str = "[Fatal]";
377  break;
378  default:
379  level_str = "[]";
380  break;
381  }
382  std::cout << level_str << ": " << msg.str() << std::endl;
383  }
384 }
385 
386 class ros::ServiceServer ros::NodeHandle::advertiseService(struct ros::AdvertiseServiceOptions &)
387 {
389  return(server);
390 }
391 
392 //sick_scan_xd::AbstractParser::AbstractParser(void)
393 //{
394 //}
395 
396 //sick_scan_xd::AbstractParser::~AbstractParser(void)
397 //{
398 //}
399 
400 void ros::console::initializeLogLocation(struct ros::console::LogLocation * loc, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const & msg, enum ros::console::levels::Level level)
401 {
402  if (loc)
403  loc->initialized_ = true;
404 }
405 
406 bool ros::NodeHandle::hasParam(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const &)const
407 {
408  return(true);
409 }
410 
411 
412 ros::NodeHandle::NodeHandle(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const &, class std::map<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >, struct std::less<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > >, class std::allocator<struct std::pair<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > > > > const &)
413 {
414 }
415 
416 std::string ros::Publisher::getTopic(void)const
417 {
418  std::string s;
419  return(s);
420 }
421 
423 {
424 
425 }
426 
427 
428 
429 // __printf(const char *format, ...)
430 int rossimu_error(const char *format, ...)
431 {
432  va_list arg;
433  int done;
434 
435  va_start(arg, format);
436  done = vfprintf(stdout, format, arg);
437  va_end(arg);
438 
439  return done;
440 }
441 
442 
444 {
445  // set all parameters, which are necessary for debugging without using roslaunch. Just start roscore at the beginning of your debug session
446  int tmpactive_echos = 1;
447  int tmpEcho_filter = 2;
448  bool tmpauto_reboot = true;
449  std::string tmpframe_id = "cloud";
450  std::string scannerName;
451  nhPriv.getParam("name", scannerName);
452  std::string tmphostname = "192.168.0.232";
453  bool tmpintensity = false;
454  if (scannerName.compare("sick_mrs_1xxx") == 0)
455  {
456  tmphostname = "192.168.0.4";
457  }
458  if (scannerName.compare("sick_mrs_6xxx") == 0)
459  {
460  tmpintensity = true;
461  tmphostname = "192.168.0.24";
462  }
463 
464  double tmpminang = -60 / 180.0 * M_PI; // MRS6124-TEST with +/- 30�
465  double tmpmaxang = +60 / 180.0 * M_PI;
466  std::string tmpport = "2112";
467  double tmprange_min = 0.01;
468  double tmprange_max = 25.0;
469  int tmpskip = 0;
470  double tmptime_offset = -0.001;
471  double tmptimelimit = 5;
472 
474 
475  nhPriv.setParam("active_echos", tmpactive_echos); // obsolete???
476  nhPriv.setParam("filter_echos", tmpEcho_filter);
477  nhPriv.setParam("auto_reboot", tmpauto_reboot);
478  nhPriv.setParam("hostname", tmphostname);
479  nhPriv.setParam("frame_id", tmpframe_id);
480  nhPriv.setParam("intensity", tmpintensity);
481  nhPriv.setParam("min_ang", tmpminang);
482  nhPriv.setParam("max_ang", tmpmaxang);
483  nhPriv.setParam("port", tmpport);
484  nhPriv.setParam("range_min", tmprange_min);
485  nhPriv.setParam("range_max", tmprange_max);
486  nhPriv.setParam("skip", tmpskip);
487  nhPriv.setParam("time_offset", tmptime_offset);
488  nhPriv.setParam("timelimit", tmptimelimit);
489  return(0);
490 }
491 
492 int fork()
493 {
494  return(0);
495 }
496 
497 #ifdef _MSC_VER
498 void sleep(int secs)
499 {
500  Sleep(secs * 1000);
501 }
502 #endif
ros::NodeHandle::setParam
void setParam(const std::string &key, bool b) const
ros::SerializedMessage
ros::console::levels::Error
Error
msg
msg
ros::Publisher
roswrap::console::set_logger_level
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
Definition: rossimu.cpp:105
rossimu_error
int rossimu_error(const char *format,...)
Definition: rossimu.cpp:430
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
alternate ROS initialization function.
__cdecl
#define __cdecl
Definition: rossimu.cpp:32
s
XmlRpcServer s
ros
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
roswrap::Subscriber::shutdown
void shutdown()
Unsubscribe the callback associated with this Subscriber.
Definition: rossimu.cpp:111
MapStringSingleton::~MapStringSingleton
~MapStringSingleton()
Definition: rossimu.cpp:96
ros::spinOnce
ROSCPP_DECL void spinOnce()
Process a single round of callbacks.
Definition: rossimu.cpp:255
ros::shutdown
ROSCPP_DECL void shutdown()
Disconnects everything and unregisters from the master. It is generally not necessary to call this fu...
Definition: rossimu.cpp:269
ros::NodeHandle::advertiseService
ServiceServer advertiseService(AdvertiseServiceOptions &ops)
Definition: rossimu.cpp:386
ros::console::initializeLogLocation
ROSCONSOLE_DECL void initializeLogLocation(LogLocation *loc, const std::string &name, Level level)
MapStringSingleton::getVal
std::string getVal(std::string tag) const
Definition: rossimu.cpp:53
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
Definition: rossimu.cpp:350
ros::ok
ROSCPP_DECL bool ok()
Check whether it's time to exit.
Definition: rossimu.cpp:273
ros::console::FilterBase
std::allocator
Definition: message_forward.h:41
sick_scan_common.h
ros::ServiceServer
dummy
uint16_t dummy
Definition: msgpack11.cpp:75
ros::Subscriber::Subscriber
Subscriber()
ros::console::setLogLocationLevel
ROSCONSOLE_DECL void setLogLocationLevel(LogLocation *loc, Level level)
Definition: rossimu.cpp:243
ros::ServiceServer::~ServiceServer
~ServiceServer()
Definition: rossimu.cpp:329
roswrap::param::init
void init(const M_string &remappings)
Definition: param_modi.cpp:809
ros::Subscriber::~Subscriber
~Subscriber()
Definition: rossimu.cpp:285
ros::console::levels::Debug
Debug
usleep
void usleep(__int64 usec)
Definition: usleep.c:3
MapStringSingleton::operator=
const MapStringSingleton & operator=(const MapStringSingleton &old)
api.setup.name
name
Definition: python/api/setup.py:12
MapStringSingleton::mMapString
std::map< std::string, std::string > mMapString
Definition: rossimu.cpp:98
unknownNode
std::string unknownNode
Definition: rossimu.cpp:34
MapStringSingleton::MapStringSingleton
MapStringSingleton()
Definition: rossimu.cpp:85
ros::ServiceServer::ServiceServer
ServiceServer()
roswrap::NodeHandle::setParam
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
Set an arbitrary XML/RPC value on the parameter server.
ros::Publisher::~Publisher
~Publisher()
Definition: rossimu.cpp:302
ros::NodeHandle::hasParam
bool hasParam(const std::string &key) const
d
d
roswrap::NodeHandle::getParam
bool getParam(const std::string &key, std::string &s) const
Get a string value from the parameter server.
Definition: rossimu.cpp:144
roswrap
Definition: param_modi.cpp:41
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
MapStringSingleton::hasTag
bool hasTag(std::string tag)
Definition: rossimu.cpp:40
ros::console::levels::Level
Level
ros::console::levels::Info
Info
fork
int fork()
Definition: rossimu.cpp:492
ros::NodeHandle::NodeHandle
NodeHandle(const NodeHandle &parent, const std::string &ns)
ros::this_node::getName
const ROSCPP_DECL std::string & getName()
Returns the name of the current node.
Definition: rossimu.cpp:343
ros::console::checkLogLocationEnabled
ROSCONSOLE_DECL void checkLogLocationEnabled(LogLocation *loc)
Definition: rossimu.cpp:249
ros::NodeHandle::ok
bool ok() const
Definition: rossimu.cpp:338
roswrap::console::levels::Level
Level
Definition: console_backend.h:41
ros::Publisher::getTopic
std::string getTopic() const
Definition: rossimu.cpp:416
MapStringSingleton
Definition: rossimu.cpp:36
ros::SubscribeOptions
ros::console::levels::Fatal
Fatal
ros::NodeHandle::getParamCached
bool getParamCached(const std::string &key, bool &b) const
ros::Publisher::Publisher
Publisher()
ros::Publisher::Impl::isValid
bool isValid() const
Definition: rossimu.cpp:314
ros::console::initialize
ROSCONSOLE_DECL void initialize()
Don't call this directly. Performs any required initialization/configuration. Happens automatically w...
Definition: rossimu.cpp:235
rossimu_settings
int rossimu_settings(ros::NodeHandle &nhPriv)
Definition: rossimu.cpp:443
ros::isShuttingDown
ROSCPP_DECL bool isShuttingDown()
Returns whether or not ros::shutdown() has been (or is being) called.
Definition: rossimu.cpp:277
MapStringSingleton::Instance
static MapStringSingleton & Instance()
Definition: rossimu.cpp:73
ros::NodeHandle::~NodeHandle
~NodeHandle()
Definition: rossimu.cpp:281
ros::console::levels::Warn
Warn
ros::spin
ROSCPP_DECL void spin()
Enter simple event loop.
Definition: rossimu.cpp:260
ros::serialization::throwStreamOverrun
ROSCPP_SERIALIZATION_DECL void throwStreamOverrun()
Definition: rossimu.cpp:324
ROSCPP_DECL
#define ROSCPP_DECL
Definition: roswrap/src/cfgsimu/sick_scan/ros/common.h:63
MapStringSingleton::setVal
void setVal(std::string tag, std::string val)
Definition: rossimu.cpp:65
ros::console::print
ROSCONSOLE_DECL void print(FilterBase *filter, void *logger, Level level, const char *file, int line, const char *function, const char *fmt,...) ROSCONSOLE_PRINTF_ATTRIBUTE(7
Definition: rossimu.cpp:239
sleep
void sleep(int secs)
test_server.server
server
Definition: test_server.py:219
ros::NodeHandle
ros::Subscriber
sick_scan_timing_dump_analyser.loc
loc
Definition: sick_scan_timing_dump_analyser.py:50
ros::console::LogLocation


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:10