@@ -48,29 +48,38 @@ inline std::vector<std::vector<int>> definition_to_sampling_block(
4848
4949inline SamplingBlocksDefinition merge_sampling_block_definitions (
5050 const SamplingBlocksDefinition& definition_A,
51- const SamplingBlocksDefinition& definition_B)
51+ const SamplingBlocksDefinition& definition_B,
52+ const std::string& prefixB)
5253{
5354 SamplingBlocksDefinition merged = definition_A;
5455
5556 for (auto block_definition_B : definition_B)
5657 {
57- auto block_B = block_definition_B.begin ();
58+ std::map<std::string, std::vector<std::string>> prefixed_block_definition_B;
59+ for (auto block : block_definition_B)
60+ {
61+ for (auto value : block.second )
62+ {
63+ prefixed_block_definition_B[block.first ].push_back (prefixB + value);
64+ }
65+ }
5866
67+ auto block_B = prefixed_block_definition_B.begin ();
5968 bool added = false ;
6069 for (auto & block_definition_A : merged)
6170 {
6271 auto block_A = block_definition_A.begin ();
6372 if (block_A->first == block_B->first )
6473 {
65- block_A->second .insert (std::end (block_A->second ),
66- std::begin (block_B->second ),
67- std::end (block_B->second ));
68- added = true ;
74+ block_A->second .insert (std::end (block_A->second ),
75+ std::begin (block_B->second ),
76+ std::end (block_B->second ));
77+ added = true ;
6978 }
7079 }
7180 if (!added)
7281 {
73- merged.push_back (block_definition_B );
82+ merged.push_back (prefixed_block_definition_B );
7483 }
7584 }
7685
@@ -101,16 +110,26 @@ inline std::vector<double> extract_ordered_values(
101110 std::vector<double > ordered_values (parameter_map.size ());
102111 for (auto entry : parameter_map)
103112 {
104- if (kinematics->name_to_index (entry.first ) > ordered_values.size ())
113+ std::string joint_name = entry.first ;
114+ if (kinematics->name_to_index (joint_name) > ordered_values.size ())
105115 {
106116 ROS_ERROR (
107117 " Joint index exceeds number of read joints. "
108118 " Did you forget to merge joint lists?" );
109119 exit (-1 );
110120 }
111- ordered_values[kinematics->name_to_index (entry. first )] = entry.second ;
121+ ordered_values[kinematics->name_to_index (joint_name )] = entry.second ;
112122 }
113123
114124 return ordered_values;
115125}
126+
127+ inline void insert_map_with_prefixed_keys (
128+ const std::map<std::string, double >& new_values,
129+ const std::string& prefix,
130+ std::map<std::string, double >& destination){
131+ for (auto new_value: new_values){
132+ destination[prefix + new_value.first ] = new_value.second ;
133+ }
134+ }
116135}
0 commit comments