@@ -123,15 +123,15 @@ CallbackReturn GenericSystem::on_init(
123
123
124
124
// Initialize storage for standard interfaces
125
125
initialize_storage_vectors (
126
- joint_commands_, joint_states_ , standard_interfaces_, get_hardware_info ().joints );
126
+ joint_command_values_, joint_state_values_ , standard_interfaces_, get_hardware_info ().joints );
127
127
// set all values without initial values to 0
128
128
for (auto i = 0u ; i < get_hardware_info ().joints .size (); i++)
129
129
{
130
130
for (auto j = 0u ; j < standard_interfaces_.size (); j++)
131
131
{
132
- if (std::isnan (joint_states_ [j][i]))
132
+ if (std::isnan (joint_state_values_ [j][i]))
133
133
{
134
- joint_states_ [j][i] = 0.0 ;
134
+ joint_state_values_ [j][i] = 0.0 ;
135
135
}
136
136
}
137
137
}
@@ -148,7 +148,7 @@ CallbackReturn GenericSystem::on_init(
148
148
149
149
// Initialize storage for non-standard interfaces
150
150
initialize_storage_vectors (
151
- other_commands_, other_states_ , other_interfaces_, get_hardware_info ().joints );
151
+ other_command_values_, other_state_values_ , other_interfaces_, get_hardware_info ().joints );
152
152
153
153
// when following offset is used on custom interface then find its index
154
154
if (!custom_interface_with_following_offset_.empty ())
@@ -186,7 +186,8 @@ CallbackReturn GenericSystem::on_init(
186
186
}
187
187
}
188
188
initialize_storage_vectors (
189
- sensor_mock_commands_, sensor_states_, sensor_interfaces_, get_hardware_info ().sensors );
189
+ sensor_mock_command_values_, sensor_state_values_, sensor_interfaces_,
190
+ get_hardware_info ().sensors );
190
191
191
192
// search for gpio interfaces
192
193
for (const auto & gpio : get_hardware_info ().gpios )
@@ -202,13 +203,13 @@ CallbackReturn GenericSystem::on_init(
202
203
if (use_mock_gpio_command_interfaces_)
203
204
{
204
205
initialize_storage_vectors (
205
- gpio_mock_commands_, gpio_states_ , gpio_interfaces_, get_hardware_info ().gpios );
206
+ gpio_mock_command_values_, gpio_state_values_ , gpio_interfaces_, get_hardware_info ().gpios );
206
207
}
207
208
// Real gpio command interfaces
208
209
else
209
210
{
210
211
initialize_storage_vectors (
211
- gpio_commands_, gpio_states_ , gpio_interfaces_, get_hardware_info ().gpios );
212
+ gpio_command_values_, gpio_state_values_ , gpio_interfaces_, get_hardware_info ().gpios );
212
213
}
213
214
214
215
return CallbackReturn::SUCCESS;
@@ -226,10 +227,12 @@ std::vector<hardware_interface::StateInterface> GenericSystem::export_state_inte
226
227
{
227
228
// Add interface: if not in the standard list then use "other" interface list
228
229
if (!get_interface (
229
- joint.name , standard_interfaces_, interface.name , i, joint_states_, state_interfaces))
230
+ joint.name , standard_interfaces_, interface.name , i, joint_state_values_,
231
+ state_interfaces))
230
232
{
231
233
if (!get_interface (
232
- joint.name , other_interfaces_, interface.name , i, other_states_, state_interfaces))
234
+ joint.name , other_interfaces_, interface.name , i, other_state_values_,
235
+ state_interfaces))
233
236
{
234
237
throw std::runtime_error (
235
238
" Interface is not found in the standard nor other list. "
@@ -241,15 +244,16 @@ std::vector<hardware_interface::StateInterface> GenericSystem::export_state_inte
241
244
242
245
// Sensor state interfaces
243
246
if (!populate_interfaces (
244
- get_hardware_info ().sensors , sensor_interfaces_, sensor_states_, state_interfaces, true ))
247
+ get_hardware_info ().sensors , sensor_interfaces_, sensor_state_values_, state_interfaces,
248
+ true ))
245
249
{
246
250
throw std::runtime_error (
247
251
" Interface is not found in the standard nor other list. This should never happen!" );
248
252
};
249
253
250
254
// GPIO state interfaces
251
255
if (!populate_interfaces (
252
- get_hardware_info ().gpios , gpio_interfaces_, gpio_states_ , state_interfaces, true ))
256
+ get_hardware_info ().gpios , gpio_interfaces_, gpio_state_values_ , state_interfaces, true ))
253
257
{
254
258
throw std::runtime_error (" Interface is not found in the gpio list. This should never happen!" );
255
259
}
@@ -269,11 +273,11 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
269
273
{
270
274
// Add interface: if not in the standard list than use "other" interface list
271
275
if (!get_interface (
272
- joint.name , standard_interfaces_, interface.name , i, joint_commands_ ,
276
+ joint.name , standard_interfaces_, interface.name , i, joint_command_values_ ,
273
277
command_interfaces))
274
278
{
275
279
if (!get_interface (
276
- joint.name , other_interfaces_, interface.name , i, other_commands_ ,
280
+ joint.name , other_interfaces_, interface.name , i, other_command_values_ ,
277
281
command_interfaces))
278
282
{
279
283
throw std::runtime_error (
@@ -290,7 +294,7 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
290
294
if (use_mock_sensor_command_interfaces_)
291
295
{
292
296
if (!populate_interfaces (
293
- get_hardware_info ().sensors , sensor_interfaces_, sensor_mock_commands_ ,
297
+ get_hardware_info ().sensors , sensor_interfaces_, sensor_mock_command_values_ ,
294
298
command_interfaces, true ))
295
299
{
296
300
throw std::runtime_error (
@@ -302,8 +306,8 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
302
306
if (use_mock_gpio_command_interfaces_)
303
307
{
304
308
if (!populate_interfaces (
305
- get_hardware_info ().gpios , gpio_interfaces_, gpio_mock_commands_, command_interfaces ,
306
- true ))
309
+ get_hardware_info ().gpios , gpio_interfaces_, gpio_mock_command_values_ ,
310
+ command_interfaces, true ))
307
311
{
308
312
throw std::runtime_error (
309
313
" Interface is not found in the gpio list. This should never happen!" );
@@ -313,7 +317,8 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
313
317
else
314
318
{
315
319
if (!populate_interfaces (
316
- get_hardware_info ().gpios , gpio_interfaces_, gpio_commands_, command_interfaces, false ))
320
+ get_hardware_info ().gpios , gpio_interfaces_, gpio_command_values_, command_interfaces,
321
+ false ))
317
322
{
318
323
throw std::runtime_error (
319
324
" Interface is not found in the gpio list. This should never happen!" );
@@ -487,7 +492,7 @@ return_type GenericSystem::read(const rclcpp::Time & /*time*/, const rclcpp::Dur
487
492
return return_type::OK;
488
493
};
489
494
490
- for (size_t j = 0 ; j < joint_states_ [POSITION_INTERFACE_INDEX].size (); ++j)
495
+ for (size_t j = 0 ; j < joint_state_values_ [POSITION_INTERFACE_INDEX].size (); ++j)
491
496
{
492
497
if (calculate_dynamics_)
493
498
{
@@ -496,71 +501,71 @@ return_type GenericSystem::read(const rclcpp::Time & /*time*/, const rclcpp::Dur
496
501
case ACCELERATION_INTERFACE_INDEX:
497
502
{
498
503
// currently we do backward integration
499
- joint_states_ [POSITION_INTERFACE_INDEX][j] += // apply offset to positions only
500
- joint_states_ [VELOCITY_INTERFACE_INDEX][j] * period.seconds () +
504
+ joint_state_values_ [POSITION_INTERFACE_INDEX][j] += // apply offset to positions only
505
+ joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] * period.seconds () +
501
506
(custom_interface_with_following_offset_.empty () ? position_state_following_offset_
502
507
: 0.0 );
503
508
504
- joint_states_ [VELOCITY_INTERFACE_INDEX][j] +=
505
- joint_states_ [ACCELERATION_INTERFACE_INDEX][j] * period.seconds ();
509
+ joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] +=
510
+ joint_state_values_ [ACCELERATION_INTERFACE_INDEX][j] * period.seconds ();
506
511
507
- if (!std::isnan (joint_commands_ [ACCELERATION_INTERFACE_INDEX][j]))
512
+ if (!std::isnan (joint_command_values_ [ACCELERATION_INTERFACE_INDEX][j]))
508
513
{
509
- joint_states_ [ACCELERATION_INTERFACE_INDEX][j] =
510
- joint_commands_ [ACCELERATION_INTERFACE_INDEX][j];
514
+ joint_state_values_ [ACCELERATION_INTERFACE_INDEX][j] =
515
+ joint_command_values_ [ACCELERATION_INTERFACE_INDEX][j];
511
516
}
512
517
break ;
513
518
}
514
519
case VELOCITY_INTERFACE_INDEX:
515
520
{
516
521
// currently we do backward integration
517
- joint_states_ [POSITION_INTERFACE_INDEX][j] += // apply offset to positions only
518
- joint_states_ [VELOCITY_INTERFACE_INDEX][j] * period.seconds () +
522
+ joint_state_values_ [POSITION_INTERFACE_INDEX][j] += // apply offset to positions only
523
+ joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] * period.seconds () +
519
524
(custom_interface_with_following_offset_.empty () ? position_state_following_offset_
520
525
: 0.0 );
521
526
522
- if (!std::isnan (joint_commands_ [VELOCITY_INTERFACE_INDEX][j]))
527
+ if (!std::isnan (joint_command_values_ [VELOCITY_INTERFACE_INDEX][j]))
523
528
{
524
- const double old_velocity = joint_states_ [VELOCITY_INTERFACE_INDEX][j];
529
+ const double old_velocity = joint_state_values_ [VELOCITY_INTERFACE_INDEX][j];
525
530
526
- joint_states_ [VELOCITY_INTERFACE_INDEX][j] =
527
- joint_commands_ [VELOCITY_INTERFACE_INDEX][j];
531
+ joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] =
532
+ joint_command_values_ [VELOCITY_INTERFACE_INDEX][j];
528
533
529
- joint_states_ [ACCELERATION_INTERFACE_INDEX][j] =
530
- (joint_states_ [VELOCITY_INTERFACE_INDEX][j] - old_velocity) / period.seconds ();
534
+ joint_state_values_ [ACCELERATION_INTERFACE_INDEX][j] =
535
+ (joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] - old_velocity) / period.seconds ();
531
536
}
532
537
break ;
533
538
}
534
539
case POSITION_INTERFACE_INDEX:
535
540
{
536
- if (!std::isnan (joint_commands_ [POSITION_INTERFACE_INDEX][j]))
541
+ if (!std::isnan (joint_command_values_ [POSITION_INTERFACE_INDEX][j]))
537
542
{
538
- const double old_position = joint_states_ [POSITION_INTERFACE_INDEX][j];
539
- const double old_velocity = joint_states_ [VELOCITY_INTERFACE_INDEX][j];
543
+ const double old_position = joint_state_values_ [POSITION_INTERFACE_INDEX][j];
544
+ const double old_velocity = joint_state_values_ [VELOCITY_INTERFACE_INDEX][j];
540
545
541
- joint_states_ [POSITION_INTERFACE_INDEX][j] = // apply offset to positions only
542
- joint_commands_ [POSITION_INTERFACE_INDEX][j] +
546
+ joint_state_values_ [POSITION_INTERFACE_INDEX][j] = // apply offset to positions only
547
+ joint_command_values_ [POSITION_INTERFACE_INDEX][j] +
543
548
(custom_interface_with_following_offset_.empty () ? position_state_following_offset_
544
549
: 0.0 );
545
550
546
- joint_states_ [VELOCITY_INTERFACE_INDEX][j] =
547
- (joint_states_ [POSITION_INTERFACE_INDEX][j] - old_position) / period.seconds ();
551
+ joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] =
552
+ (joint_state_values_ [POSITION_INTERFACE_INDEX][j] - old_position) / period.seconds ();
548
553
549
- joint_states_ [ACCELERATION_INTERFACE_INDEX][j] =
550
- (joint_states_ [VELOCITY_INTERFACE_INDEX][j] - old_velocity) / period.seconds ();
554
+ joint_state_values_ [ACCELERATION_INTERFACE_INDEX][j] =
555
+ (joint_state_values_ [VELOCITY_INTERFACE_INDEX][j] - old_velocity) / period.seconds ();
551
556
}
552
557
break ;
553
558
}
554
559
}
555
560
}
556
561
else
557
562
{
558
- for (size_t k = 0 ; k < joint_states_ [POSITION_INTERFACE_INDEX].size (); ++k)
563
+ for (size_t k = 0 ; k < joint_state_values_ [POSITION_INTERFACE_INDEX].size (); ++k)
559
564
{
560
- if (!std::isnan (joint_commands_ [POSITION_INTERFACE_INDEX][k]))
565
+ if (!std::isnan (joint_command_values_ [POSITION_INTERFACE_INDEX][k]))
561
566
{
562
- joint_states_ [POSITION_INTERFACE_INDEX][k] = // apply offset to positions only
563
- joint_commands_ [POSITION_INTERFACE_INDEX][k] +
567
+ joint_state_values_ [POSITION_INTERFACE_INDEX][k] = // apply offset to positions only
568
+ joint_command_values_ [POSITION_INTERFACE_INDEX][k] +
564
569
(custom_interface_with_following_offset_.empty () ? position_state_following_offset_
565
570
: 0.0 );
566
571
}
@@ -571,53 +576,53 @@ return_type GenericSystem::read(const rclcpp::Time & /*time*/, const rclcpp::Dur
571
576
// do loopback on all other interfaces - starts from 1 or 3 because 0, 1, 3 are position,
572
577
// velocity, and acceleration interface
573
578
if (
574
- mirror_command_to_state (joint_states_, joint_commands_, calculate_dynamics_ ? 3 : 1 ) !=
575
- return_type::OK)
579
+ mirror_command_to_state (
580
+ joint_state_values_, joint_command_values_, calculate_dynamics_ ? 3 : 1 ) != return_type::OK)
576
581
{
577
582
return return_type::ERROR;
578
583
}
579
584
580
585
for (const auto & mimic_joint : get_hardware_info ().mimic_joints )
581
586
{
582
- for (auto i = 0u ; i < joint_states_ .size (); ++i)
587
+ for (auto i = 0u ; i < joint_state_values_ .size (); ++i)
583
588
{
584
- joint_states_ [i][mimic_joint.joint_index ] =
589
+ joint_state_values_ [i][mimic_joint.joint_index ] =
585
590
mimic_joint.offset +
586
- mimic_joint.multiplier * joint_states_ [i][mimic_joint.mimicked_joint_index ];
591
+ mimic_joint.multiplier * joint_state_values_ [i][mimic_joint.mimicked_joint_index ];
587
592
}
588
593
}
589
594
590
- for (size_t i = 0 ; i < other_states_ .size (); ++i)
595
+ for (size_t i = 0 ; i < other_state_values_ .size (); ++i)
591
596
{
592
- for (size_t j = 0 ; j < other_states_ [i].size (); ++j)
597
+ for (size_t j = 0 ; j < other_state_values_ [i].size (); ++j)
593
598
{
594
599
if (
595
600
i == index_custom_interface_with_following_offset_ &&
596
- !std::isnan (joint_commands_ [POSITION_INTERFACE_INDEX][j]))
601
+ !std::isnan (joint_command_values_ [POSITION_INTERFACE_INDEX][j]))
597
602
{
598
- other_states_ [i][j] =
599
- joint_commands_ [POSITION_INTERFACE_INDEX][j] + position_state_following_offset_;
603
+ other_state_values_ [i][j] =
604
+ joint_command_values_ [POSITION_INTERFACE_INDEX][j] + position_state_following_offset_;
600
605
}
601
- else if (!std::isnan (other_commands_ [i][j]))
606
+ else if (!std::isnan (other_command_values_ [i][j]))
602
607
{
603
- other_states_ [i][j] = other_commands_ [i][j];
608
+ other_state_values_ [i][j] = other_command_values_ [i][j];
604
609
}
605
610
}
606
611
}
607
612
608
613
if (use_mock_sensor_command_interfaces_)
609
614
{
610
- mirror_command_to_state (sensor_states_, sensor_mock_commands_ );
615
+ mirror_command_to_state (sensor_state_values_, sensor_mock_command_values_ );
611
616
}
612
617
613
618
if (use_mock_gpio_command_interfaces_)
614
619
{
615
- mirror_command_to_state (gpio_states_, gpio_mock_commands_ );
620
+ mirror_command_to_state (gpio_state_values_, gpio_mock_command_values_ );
616
621
}
617
622
else
618
623
{
619
624
// do loopback on all gpio interfaces
620
- mirror_command_to_state (gpio_states_, gpio_commands_ );
625
+ mirror_command_to_state (gpio_state_values_, gpio_command_values_ );
621
626
}
622
627
623
628
return return_type::OK;
0 commit comments