forked from ros/ros_comm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
param.cpp
834 lines (709 loc) · 20.3 KB
/
param.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
/*
* Copyright (C) 2009, Willow Garage, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the names of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "ros/param.h"
#include "ros/master.h"
#include "ros/xmlrpc_manager.h"
#include "ros/this_node.h"
#include "ros/names.h"
#include <ros/console.h>
#include <boost/thread/mutex.hpp>
#include <boost/lexical_cast.hpp>
#include <vector>
#include <map>
namespace ros
{
namespace param
{
typedef std::map<std::string, XmlRpc::XmlRpcValue> M_Param;
M_Param g_params;
boost::mutex g_params_mutex;
S_string g_subscribed_params;
void set(const std::string& key, const XmlRpc::XmlRpcValue& v)
{
std::string mapped_key = ros::names::resolve(key);
XmlRpc::XmlRpcValue params, result, payload;
params[0] = this_node::getName();
params[1] = mapped_key;
params[2] = v;
{
// Lock around the execute to the master in case we get a parameter update on this value between
// executing on the master and setting the parameter in the g_params list.
boost::mutex::scoped_lock lock(g_params_mutex);
if (master::execute("setParam", params, result, payload, true))
{
// Update our cached params list now so that if get() is called immediately after param::set()
// we already have the cached state and our value will be correct
if (g_subscribed_params.find(mapped_key) != g_subscribed_params.end())
{
g_params[mapped_key] = v;
}
}
}
}
void set(const std::string& key, const std::string& s)
{
// construct xmlrpc_c::value object of the std::string and
// call param::set(key, xmlvalue);
XmlRpc::XmlRpcValue v(s);
ros::param::set(key, v);
}
void set(const std::string& key, const char* s)
{
// construct xmlrpc_c::value object of the std::string and
// call param::set(key, xmlvalue);
std::string sxx = std::string(s);
XmlRpc::XmlRpcValue v(sxx);
ros::param::set(key, v);
}
void set(const std::string& key, double d)
{
XmlRpc::XmlRpcValue v(d);
ros::param::set(key, v);
}
void set(const std::string& key, int i)
{
XmlRpc::XmlRpcValue v(i);
ros::param::set(key, v);
}
void set(const std::string& key, bool b)
{
XmlRpc::XmlRpcValue v(b);
ros::param::set(key, v);
}
template <class T>
void setImpl(const std::string& key, const std::vector<T>& vec)
{
// Note: the XmlRpcValue starts off as "invalid" and assertArray turns it
// into an array type with the given size
XmlRpc::XmlRpcValue xml_vec;
xml_vec.setSize(vec.size());
// Copy the contents into the XmlRpcValue
for(size_t i=0; i < vec.size(); i++) {
xml_vec[i] = vec.at(i);
}
set(key, xml_vec);
}
void set(const std::string& key, const std::vector<std::string>& vec)
{
setImpl(key, vec);
}
void set(const std::string& key, const std::vector<double>& vec)
{
setImpl(key, vec);
}
void set(const std::string& key, const std::vector<float>& vec)
{
setImpl(key, vec);
}
void set(const std::string& key, const std::vector<int>& vec)
{
setImpl(key, vec);
}
void set(const std::string& key, const std::vector<bool>& vec)
{
setImpl(key, vec);
}
template <class T>
void setImpl(const std::string& key, const std::map<std::string, T>& map)
{
// Note: the XmlRpcValue starts off as "invalid" and assertArray turns it
// into an array type with the given size
XmlRpc::XmlRpcValue xml_value;
const XmlRpc::XmlRpcValue::ValueStruct& xml_map = (const XmlRpc::XmlRpcValue::ValueStruct &)(xml_value);
// Copy the contents into the XmlRpcValue
for(typename std::map<std::string, T>::const_iterator it = map.begin(); it != map.end(); ++it) {
xml_value[it->first] = it->second;
}
set(key, xml_value);
}
void set(const std::string& key, const std::map<std::string, std::string>& map)
{
setImpl(key, map);
}
void set(const std::string& key, const std::map<std::string, double>& map)
{
setImpl(key, map);
}
void set(const std::string& key, const std::map<std::string, float>& map)
{
setImpl(key, map);
}
void set(const std::string& key, const std::map<std::string, int>& map)
{
setImpl(key, map);
}
void set(const std::string& key, const std::map<std::string, bool>& map)
{
setImpl(key, map);
}
bool has(const std::string& key)
{
XmlRpc::XmlRpcValue params, result, payload;
params[0] = this_node::getName();
params[1] = ros::names::resolve(key);
//params[1] = key;
// We don't loop here, because validateXmlrpcResponse() returns false
// both when we can't contact the master and when the master says, "I
// don't have that param."
if (!master::execute("hasParam", params, result, payload, false))
{
return false;
}
return payload;
}
bool del(const std::string& key)
{
std::string mapped_key = ros::names::resolve(key);
{
boost::mutex::scoped_lock lock(g_params_mutex);
S_string::iterator sub_it = g_subscribed_params.find(mapped_key);
if (sub_it != g_subscribed_params.end())
{
g_subscribed_params.erase(sub_it);
M_Param::iterator param_it = g_params.find(mapped_key);
if (param_it != g_params.end())
{
g_params.erase(param_it);
}
}
}
XmlRpc::XmlRpcValue params, result, payload;
params[0] = this_node::getName();
params[1] = mapped_key;
// We don't loop here, because validateXmlrpcResponse() returns false
// both when we can't contact the master and when the master says, "I
// don't have that param."
if (!master::execute("deleteParam", params, result, payload, false))
{
return false;
}
return true;
}
bool getImpl(const std::string& key, XmlRpc::XmlRpcValue& v, bool use_cache)
{
std::string mapped_key = ros::names::resolve(key);
if (use_cache)
{
boost::mutex::scoped_lock lock(g_params_mutex);
if (g_subscribed_params.find(mapped_key) != g_subscribed_params.end())
{
M_Param::iterator it = g_params.find(mapped_key);
if (it != g_params.end())
{
if (it->second.valid())
{
ROS_DEBUG_NAMED("cached_parameters", "Using cached parameter value for key [%s]", mapped_key.c_str());
v = it->second;
return true;
}
else
{
ROS_DEBUG_NAMED("cached_parameters", "Cached parameter is invalid for key [%s]", mapped_key.c_str());
return false;
}
}
}
else
{
// parameter we've never seen before, register for update from the master
if (g_subscribed_params.insert(mapped_key).second)
{
XmlRpc::XmlRpcValue params, result, payload;
params[0] = this_node::getName();
params[1] = XMLRPCManager::instance()->getServerURI();
params[2] = mapped_key;
if (!master::execute("subscribeParam", params, result, payload, false))
{
ROS_DEBUG_NAMED("cached_parameters", "Subscribe to parameter [%s]: call to the master failed", mapped_key.c_str());
g_subscribed_params.erase(mapped_key);
use_cache = false;
}
else
{
ROS_DEBUG_NAMED("cached_parameters", "Subscribed to parameter [%s]", mapped_key.c_str());
}
}
}
}
XmlRpc::XmlRpcValue params, result;
params[0] = this_node::getName();
params[1] = mapped_key;
// We don't loop here, because validateXmlrpcResponse() returns false
// both when we can't contact the master and when the master says, "I
// don't have that param."
bool ret = master::execute("getParam", params, result, v, false);
if (use_cache)
{
boost::mutex::scoped_lock lock(g_params_mutex);
ROS_DEBUG_NAMED("cached_parameters", "Caching parameter [%s] with value type [%d]", mapped_key.c_str(), v.getType());
g_params[mapped_key] = v;
}
return ret;
}
bool getImpl(const std::string& key, std::string& s, bool use_cache)
{
XmlRpc::XmlRpcValue v;
if (!getImpl(key, v, use_cache))
return false;
if (v.getType() != XmlRpc::XmlRpcValue::TypeString)
return false;
s = std::string(v);
return true;
}
bool getImpl(const std::string& key, double& d, bool use_cache)
{
XmlRpc::XmlRpcValue v;
if (!getImpl(key, v, use_cache))
{
return false;
}
if (v.getType() == XmlRpc::XmlRpcValue::TypeInt)
{
d = (int)v;
}
else if (v.getType() != XmlRpc::XmlRpcValue::TypeDouble)
{
return false;
}
else
{
d = v;
}
return true;
}
bool getImpl(const std::string& key, float& f, bool use_cache)
{
double d = static_cast<double>(f);
bool result = getImpl(key, d, use_cache);
if (result)
f = static_cast<float>(d);
return result;
}
bool getImpl(const std::string& key, int& i, bool use_cache)
{
XmlRpc::XmlRpcValue v;
if (!getImpl(key, v, use_cache))
{
return false;
}
if (v.getType() == XmlRpc::XmlRpcValue::TypeDouble)
{
double d = v;
if (fmod(d, 1.0) < 0.5)
{
d = floor(d);
}
else
{
d = ceil(d);
}
i = d;
}
else if (v.getType() != XmlRpc::XmlRpcValue::TypeInt)
{
return false;
}
else
{
i = v;
}
return true;
}
bool getImpl(const std::string& key, bool& b, bool use_cache)
{
XmlRpc::XmlRpcValue v;
if (!getImpl(key, v, use_cache))
return false;
if (v.getType() != XmlRpc::XmlRpcValue::TypeBoolean)
return false;
b = v;
return true;
}
bool get(const std::string& key, std::string& s)
{
return getImpl(key, s, false);
}
bool get(const std::string& key, double& d)
{
return getImpl(key, d, false);
}
bool get(const std::string& key, float& f)
{
return getImpl(key, f, false);
}
bool get(const std::string& key, int& i)
{
return getImpl(key, i, false);
}
bool get(const std::string& key, bool& b)
{
return getImpl(key, b, false);
}
bool get(const std::string& key, XmlRpc::XmlRpcValue& v)
{
return getImpl(key, v, false);
}
bool getCached(const std::string& key, std::string& s)
{
return getImpl(key, s, true);
}
bool getCached(const std::string& key, double& d)
{
return getImpl(key, d, true);
}
bool getCached(const std::string& key, float& f)
{
return getImpl(key, f, true);
}
bool getCached(const std::string& key, int& i)
{
return getImpl(key, i, true);
}
bool getCached(const std::string& key, bool& b)
{
return getImpl(key, b, true);
}
bool getCached(const std::string& key, XmlRpc::XmlRpcValue& v)
{
return getImpl(key, v, true);
}
template <class T> T xml_cast(XmlRpc::XmlRpcValue xml_value)
{
return static_cast<T>(xml_value);
}
template <class T> bool xml_castable(int XmlType)
{
return false;
}
template<> bool xml_castable<std::string>(int XmlType)
{
return XmlType == XmlRpc::XmlRpcValue::TypeString;
}
template<> bool xml_castable<double>(int XmlType)
{
return (
XmlType == XmlRpc::XmlRpcValue::TypeDouble ||
XmlType == XmlRpc::XmlRpcValue::TypeInt ||
XmlType == XmlRpc::XmlRpcValue::TypeBoolean );
}
template<> bool xml_castable<float>(int XmlType)
{
return (
XmlType == XmlRpc::XmlRpcValue::TypeDouble ||
XmlType == XmlRpc::XmlRpcValue::TypeInt ||
XmlType == XmlRpc::XmlRpcValue::TypeBoolean );
}
template<> bool xml_castable<int>(int XmlType)
{
return (
XmlType == XmlRpc::XmlRpcValue::TypeDouble ||
XmlType == XmlRpc::XmlRpcValue::TypeInt ||
XmlType == XmlRpc::XmlRpcValue::TypeBoolean );
}
template<> bool xml_castable<bool>(int XmlType)
{
return (
XmlType == XmlRpc::XmlRpcValue::TypeDouble ||
XmlType == XmlRpc::XmlRpcValue::TypeInt ||
XmlType == XmlRpc::XmlRpcValue::TypeBoolean );
}
template<> double xml_cast(XmlRpc::XmlRpcValue xml_value)
{
using namespace XmlRpc;
switch(xml_value.getType()) {
case XmlRpcValue::TypeDouble:
return static_cast<double>(xml_value);
case XmlRpcValue::TypeInt:
return static_cast<double>(static_cast<int>(xml_value));
case XmlRpcValue::TypeBoolean:
return static_cast<double>(static_cast<bool>(xml_value));
};
}
template<> float xml_cast(XmlRpc::XmlRpcValue xml_value)
{
using namespace XmlRpc;
switch(xml_value.getType()) {
case XmlRpcValue::TypeDouble:
return static_cast<float>(static_cast<double>(xml_value));
case XmlRpcValue::TypeInt:
return static_cast<float>(static_cast<int>(xml_value));
case XmlRpcValue::TypeBoolean:
return static_cast<float>(static_cast<bool>(xml_value));
};
}
template<> int xml_cast(XmlRpc::XmlRpcValue xml_value)
{
using namespace XmlRpc;
switch(xml_value.getType()) {
case XmlRpcValue::TypeDouble:
return static_cast<int>(static_cast<double>(xml_value));
case XmlRpcValue::TypeInt:
return static_cast<int>(xml_value);
case XmlRpcValue::TypeBoolean:
return static_cast<int>(static_cast<bool>(xml_value));
};
}
template<> bool xml_cast(XmlRpc::XmlRpcValue xml_value)
{
using namespace XmlRpc;
switch(xml_value.getType()) {
case XmlRpcValue::TypeDouble:
return static_cast<bool>(static_cast<double>(xml_value));
case XmlRpcValue::TypeInt:
return static_cast<bool>(static_cast<int>(xml_value));
case XmlRpcValue::TypeBoolean:
return static_cast<bool>(xml_value);
};
}
template <class T>
bool getImpl(const std::string& key, std::vector<T>& vec, bool cached)
{
XmlRpc::XmlRpcValue xml_array;
if(!getImpl(key, xml_array, cached)) {
return false;
}
// Make sure it's an array type
if(xml_array.getType() != XmlRpc::XmlRpcValue::TypeArray) {
return false;
}
// Resize the target vector (destructive)
vec.resize(xml_array.size());
// Fill the vector with stuff
for (int i = 0; i < xml_array.size(); i++) {
if(!xml_castable<T>(xml_array[i].getType())) {
return false;
}
vec[i] = xml_cast<T>(xml_array[i]);
}
return true;
}
bool get(const std::string& key, std::vector<std::string>& vec)
{
return getImpl(key, vec, false);
}
bool get(const std::string& key, std::vector<double>& vec)
{
return getImpl(key, vec, false);
}
bool get(const std::string& key, std::vector<float>& vec)
{
return getImpl(key, vec, false);
}
bool get(const std::string& key, std::vector<int>& vec)
{
return getImpl(key, vec, false);
}
bool get(const std::string& key, std::vector<bool>& vec)
{
return getImpl(key, vec, false);
}
bool getCached(const std::string& key, std::vector<std::string>& vec)
{
return getImpl(key, vec, true);
}
bool getCached(const std::string& key, std::vector<double>& vec)
{
return getImpl(key, vec, true);
}
bool getCached(const std::string& key, std::vector<float>& vec)
{
return getImpl(key, vec, true);
}
bool getCached(const std::string& key, std::vector<int>& vec)
{
return getImpl(key, vec, true);
}
bool getCached(const std::string& key, std::vector<bool>& vec)
{
return getImpl(key, vec, true);
}
template <class T>
bool getImpl(const std::string& key, std::map<std::string, T>& map, bool cached)
{
XmlRpc::XmlRpcValue xml_value;
if(!getImpl(key, xml_value, cached)) {
return false;
}
// Make sure it's a struct type
if(xml_value.getType() != XmlRpc::XmlRpcValue::TypeStruct) {
return false;
}
// Fill the map with stuff
for (XmlRpc::XmlRpcValue::ValueStruct::const_iterator it = xml_value.begin();
it != xml_value.end();
++it)
{
// Make sure this element is the right type
if(!xml_castable<T>(it->second.getType())) {
return false;
}
// Store the element
map[it->first] = xml_cast<T>(it->second);
}
return true;
}
bool get(const std::string& key, std::map<std::string, std::string>& map)
{
return getImpl(key, map, false);
}
bool get(const std::string& key, std::map<std::string, double>& map)
{
return getImpl(key, map, false);
}
bool get(const std::string& key, std::map<std::string, float>& map)
{
return getImpl(key, map, false);
}
bool get(const std::string& key, std::map<std::string, int>& map)
{
return getImpl(key, map, false);
}
bool get(const std::string& key, std::map<std::string, bool>& map)
{
return getImpl(key, map, false);
}
bool getCached(const std::string& key, std::map<std::string, std::string>& map)
{
return getImpl(key, map, true);
}
bool getCached(const std::string& key, std::map<std::string, double>& map)
{
return getImpl(key, map, true);
}
bool getCached(const std::string& key, std::map<std::string, float>& map)
{
return getImpl(key, map, true);
}
bool getCached(const std::string& key, std::map<std::string, int>& map)
{
return getImpl(key, map, true);
}
bool getCached(const std::string& key, std::map<std::string, bool>& map)
{
return getImpl(key, map, true);
}
bool search(const std::string& key, std::string& result_out)
{
return search(this_node::getName(), key, result_out);
}
bool search(const std::string& ns, const std::string& key, std::string& result_out)
{
XmlRpc::XmlRpcValue params, result, payload;
params[0] = ns;
// searchParam needs a separate form of remapping -- remapping on the unresolved name, rather than the
// resolved one.
std::string remapped = key;
M_string::const_iterator it = names::getUnresolvedRemappings().find(key);
if (it != names::getUnresolvedRemappings().end())
{
remapped = it->second;
}
params[1] = remapped;
// We don't loop here, because validateXmlrpcResponse() returns false
// both when we can't contact the master and when the master says, "I
// don't have that param."
if (!master::execute("searchParam", params, result, payload, false))
{
return false;
}
result_out = (std::string)payload;
return true;
}
void update(const std::string& key, const XmlRpc::XmlRpcValue& v)
{
std::string clean_key = names::clean(key);
ROS_DEBUG_NAMED("cached_parameters", "Received parameter update for key [%s]", clean_key.c_str());
boost::mutex::scoped_lock lock(g_params_mutex);
g_params[clean_key] = v;
}
void paramUpdateCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
{
result[0] = 1;
result[1] = std::string("");
result[2] = 0;
ros::param::update((std::string)params[1], params[2]);
}
void init(const M_string& remappings)
{
M_string::const_iterator it = remappings.begin();
M_string::const_iterator end = remappings.end();
for (; it != end; ++it)
{
const std::string& name = it->first;
const std::string& param = it->second;
if (name.size() < 2)
{
continue;
}
if (name[0] == '_' && name[1] != '_')
{
std::string local_name = "~" + name.substr(1);
bool success = false;
try
{
int32_t i = boost::lexical_cast<int32_t>(param);
ros::param::set(names::resolve(local_name), i);
success = true;
}
catch (boost::bad_lexical_cast&)
{
}
if (success)
{
continue;
}
try
{
double d = boost::lexical_cast<double>(param);
ros::param::set(names::resolve(local_name), d);
success = true;
}
catch (boost::bad_lexical_cast&)
{
}
if (success)
{
continue;
}
if (param == "true" || param == "True" || param == "TRUE")
{
ros::param::set(names::resolve(local_name), true);
}
else if (param == "false" || param == "False" || param == "FALSE")
{
ros::param::set(names::resolve(local_name), false);
}
else
{
ros::param::set(names::resolve(local_name), param);
}
}
}
XMLRPCManager::instance()->bind("paramUpdate", paramUpdateCallback);
}
} // namespace param
} // namespace ros