-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathkugle_driver_node.cpp
More file actions
2219 lines (1936 loc) · 113 KB
/
Copy pathkugle_driver_node.cpp
File metadata and controls
2219 lines (1936 loc) · 113 KB
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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2018-2019 Thomas Jespersen, TKJ Electronics. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the MIT License
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for further details.
*
* Contact information
* ------------------------------------------
* Thomas Jespersen, TKJ Electronics
* Web : http://www.tkjelectronics.dk
* e-mail : thomasj@tkjelectronics.dk
* ------------------------------------------
*/
#include <ros/ros.h>
#include <dynamic_reconfigure/server.h>
#include "LSPC.h"
#include "MessageTypes.h"
#include <string>
#include <thread>
#include <boost/thread/recursive_mutex.hpp>
#include <future>
#include <boost/bind.hpp>
#include <fstream> // for file output (std::ofstream)
#include <boost/filesystem.hpp> // for directory creation (boost::filesystem)
#include <chrono>
#include <cstdint>
#include <tuple>
#include <cmath>
#include "Queue.hpp"
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <locale>
#include <stdio.h>
#include <stdlib.h>
#include <tf/tf.h>
#include <tf/LinearMath/Quaternion.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
/*#include <tf2/LinearMath/Quaternion.h>
#include <tf2/LinearMath/Transform.h>
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_listener.h>*/
#include <geometry_msgs/TransformStamped.h>
/* Include messages */
#include <geometry_msgs/Quaternion.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/MagneticField.h>
#include <sensor_msgs/BatteryState.h>
#include <std_msgs/String.h>
/* Include generated Services */
#include <kugle_srvs/SetParameter.h>
#include <kugle_srvs/GetParameter.h>
#include <kugle_srvs/DumpParameters.h>
#include <kugle_srvs/StoreParameters.h>
#include <kugle_srvs/CalibrateIMU.h>
#include <kugle_srvs/CalibrateAccelerometer.h>
#include <kugle_srvs/Reboot.h>
#include <kugle_srvs/EnterBootloader.h>
#include <kugle_srvs/RestartController.h>
/* Include generated Message Types */
#include <kugle_msgs/ControllerInfo.h>
#include <kugle_msgs/Encoders.h>
#include <kugle_msgs/StateEstimate.h>
#include <kugle_msgs/powerManagmentInfo.h>
#include <kugle_msgs/Euler.h>
#include <kugle_msgs/Vector2.h>
#include <kugle_msgs/ControllerDebug.h>
#include <kugle_msgs/BalanceControllerReference.h>
/* Include generated Dynamic Reconfigure parameters */
#include <kugle_driver/ParametersConfig.h>
// For CLion to update/capture the changes made to generated services, message types and parameters, open the "build" folder and run "make"
/* Global variables */
Queue<std::tuple<lspc::ParameterLookup::type_t, uint8_t, bool>> SetParameterResponse;
Queue<std::shared_ptr<std::vector<uint8_t>>> GetParameterResponse;
Queue<std::shared_ptr<std::vector<uint8_t>>> DumpParametersResponse;
Queue<bool> StoreParametersResponse;
Queue<bool> CalibrateIMUResponse;
Queue<bool> RestartControllerResponse;
lspc::ParameterTypes::controllerMode_t currentControllerMode = lspc::ParameterTypes::UNKNOWN_MODE;
std::mutex reconfigureMutex;
std::shared_ptr<dynamic_reconfigure::Server<kugle_driver::ParametersConfig>> reconfigureServer;
kugle_driver::ParametersConfig reconfigureConfig;
bool MATLAB_log = false;
void LSPC_Callback_StateEstimates(ros::Publisher& pubOdom, ros::Publisher& pubStateEstimate, tf::TransformBroadcaster& tfBroadcaster, std::shared_ptr<tf::TransformListener> tfListener, const std::vector<uint8_t>& payload)
{
const lspc::MessageTypesToPC::StateEstimates_t * msg = reinterpret_cast<const lspc::MessageTypesToPC::StateEstimates_t *>(payload.data());
if (sizeof(*msg) != payload.size()) {
ROS_DEBUG("Error parsing StateEstimates message");
return;
}
tf::Quaternion q_attitude;
q_attitude.setW(msg->q.w);
q_attitude.setX(msg->q.x);
q_attitude.setY(msg->q.y);
q_attitude.setZ(msg->q.z);
tf::Quaternion dq;
dq.setW(msg->dq.w);
dq.setX(msg->dq.x);
dq.setY(msg->dq.y);
dq.setZ(msg->dq.z);
tf::Transform attitudeTf;
attitudeTf.setIdentity();
attitudeTf.setRotation(q_attitude);
/* Lookup static transform between contact_point to ball (will be the height/z-offset from contact point to center of ball */
tf::Vector3 ball_offset(0,0,0);
tf::StampedTransform transformStatic;
try{
tfListener->lookupTransform("contact_point", "ball", ros::Time(0), transformStatic);
ball_offset.setX(transformStatic.getOrigin().x());
ball_offset.setY(transformStatic.getOrigin().y());
ball_offset.setZ(transformStatic.getOrigin().z());
}
catch (tf::TransformException &ex) {
//ROS_WARN("%s",ex.what());
}
/* Send transfrom from "odom" frame to "contact_point" frame */
geometry_msgs::TransformStamped tf_contact_point_msg;
tf_contact_point_msg.header.frame_id = "odom";
tf_contact_point_msg.child_frame_id = "contact_point";
tf_contact_point_msg.header.stamp = ros::Time::now();
tf_contact_point_msg.transform.translation.x = msg->pos.x; // inertial frame position
tf_contact_point_msg.transform.translation.y = msg->pos.y;
tf_contact_point_msg.transform.translation.z = 0.0;
tf_contact_point_msg.transform.rotation.w = 1;
tf_contact_point_msg.transform.rotation.x = 0;
tf_contact_point_msg.transform.rotation.y = 0;
tf_contact_point_msg.transform.rotation.z = 0;
tfBroadcaster.sendTransform(tf_contact_point_msg);
/* Compute heading from received attitude quaternion */
// We define the heading angle as the angle to the projection of the body (base_link) x-axis, projected down to the 2D plane in the inertial frame
tf::Vector3 xVector = attitudeTf(tf::Vector3(1,0,0));
float heading = atan2(xVector.y(), xVector.x());
tf::Quaternion q_heading = tf::createQuaternionFromYaw(heading); // rotate around z-axis
/* Send transfrom from "ball" frame to "heading" frame */
geometry_msgs::TransformStamped tf_heading_msg;
tf_heading_msg.header.frame_id = "ball";
tf_heading_msg.child_frame_id = "heading";
tf_heading_msg.header.stamp = ros::Time::now();
tf_heading_msg.transform.translation.x = 0;
tf_heading_msg.transform.translation.y = 0;
tf_heading_msg.transform.translation.z = 0.0;
tf_heading_msg.transform.rotation.w = q_heading.w();
tf_heading_msg.transform.rotation.x = q_heading.x();
tf_heading_msg.transform.rotation.y = q_heading.y();
tf_heading_msg.transform.rotation.z = q_heading.z();
tfBroadcaster.sendTransform(tf_heading_msg);
/* Compute roll/pitch quaternion which represents the tilt in heading frame */
// Remember quaternions are multipled from left to right, start with Unit quaternion all the way from left and then right multiplying
// The combined attitude quaternion is constructed as:
// q = q_heading o q_tilt
// Since we need to first rotate into heading frame and then tilt from there
// Hence the tilt quaternion is compute as:
// q_tilt = inv(q_heading) o q
tf::Quaternion tiltQuaternion = q_heading.inverse() * q_attitude;
/* Send transfrom from "heading" frame to "base_link" frame */
geometry_msgs::TransformStamped tf_tilt_msg;
tf_tilt_msg.header.frame_id = "heading";
tf_tilt_msg.child_frame_id = "base_link";
tf_tilt_msg.header.stamp = ros::Time::now();
tf_tilt_msg.transform.translation.x = 0;
tf_tilt_msg.transform.translation.y = 0;
tf_tilt_msg.transform.translation.z = 0.0;
tf_tilt_msg.transform.rotation.w = tiltQuaternion.w();
tf_tilt_msg.transform.rotation.x = tiltQuaternion.x();
tf_tilt_msg.transform.rotation.y = tiltQuaternion.y();
tf_tilt_msg.transform.rotation.z = tiltQuaternion.z();
tfBroadcaster.sendTransform(tf_tilt_msg);
/* Compute angular velocity from quaternion derivative */
// We need the angular velocity in inertial frame
// dq = 1/2 * q o q_omega_body
// q_omega_body = 2*inv(q) o dq
tf::Quaternion q_omega_body = q_attitude.inverse() * dq * 2;
/* Compute velocity in body frame for odometry message */
// v_body = devec * (q* o vec*v_inertial o q)
// v_body = devec * Phi(q)^T * Gamma(q) * vec*v_inertial
tf::Quaternion q_vel_inertial(msg->vel.x, msg->vel.y, 0, 0); // x,y,z,w
tf::Quaternion q_vel_body = q_attitude.inverse() * q_vel_inertial * q_attitude;
/* Send odometry message */
// This represents an estimate of a position and velocity in free space.
// The pose in this message should be specified in the coordinate frame given by header.frame_id
// The twist in this message should be specified in the coordinate frame given by the child_frame_id
nav_msgs::Odometry odom_msg;
odom_msg.header.stamp = ros::Time::now();
odom_msg.header.frame_id = "odom";
odom_msg.child_frame_id = "base_link";
odom_msg.pose.pose.position.x = msg->pos.x; // inertial frame position
odom_msg.pose.pose.position.y = msg->pos.y;
odom_msg.pose.pose.position.z = ball_offset.z();
odom_msg.pose.pose.orientation.w = q_attitude.w();
odom_msg.pose.pose.orientation.x = q_attitude.x();
odom_msg.pose.pose.orientation.y = q_attitude.y();
odom_msg.pose.pose.orientation.z = q_attitude.z();
odom_msg.twist.twist.linear.x = q_vel_body.x(); // body frame velocity
odom_msg.twist.twist.linear.y = q_vel_body.y();
odom_msg.twist.twist.linear.z = q_vel_body.z();
odom_msg.twist.twist.angular.x = q_omega_body.x();
odom_msg.twist.twist.angular.y = q_omega_body.y();
odom_msg.twist.twist.angular.z = q_omega_body.z();
pubOdom.publish(odom_msg);
/* Send state estimate message */
kugle_msgs::StateEstimate stateEstimate_msg;
stateEstimate_msg.receive_time = ros::Time::now();
stateEstimate_msg.mcu_time = msg->time;
stateEstimate_msg.q.w = msg->q.w;
stateEstimate_msg.q.x = msg->q.x;
stateEstimate_msg.q.y = msg->q.y;
stateEstimate_msg.q.z = msg->q.z;
stateEstimate_msg.dq.w = msg->dq.w;
stateEstimate_msg.dq.x = msg->dq.x;
stateEstimate_msg.dq.y = msg->dq.y;
stateEstimate_msg.dq.z = msg->dq.z;
stateEstimate_msg.position[0] = msg->pos.x;
stateEstimate_msg.position[1] = msg->pos.y;
stateEstimate_msg.velocity[0] = msg->vel.x;
stateEstimate_msg.velocity[1] = msg->vel.y;
pubStateEstimate.publish(stateEstimate_msg);
}
void LSPC_Callback_SystemInfo(const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("System info received");
const lspc::MessageTypesToPC::SystemInfo_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::SystemInfo_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing SystemInfo message");
return;
}
}
std::string ParseControllerType(lspc::ParameterTypes::controllerType_t type)
{
if (type == lspc::ParameterTypes::LQR_CONTROLLER) return "LQR_CONTROLLER";
else if (type == lspc::ParameterTypes::SLIDING_MODE_CONTROLLER) return "SLIDING_MODE_CONTROLLER";
else if (type == lspc::ParameterTypes::FEEDBACK_LINEARIZATION_CONTROLLER) return "FEEDBACK_LINEARIZATION_CONTROLLER";
else return "UNKNOWN_CONTROLLER";
}
lspc::ParameterTypes::controllerType_t ParseControllerType2(std::string type)
{
if (!type.compare("LQR_CONTROLLER")) return lspc::ParameterTypes::LQR_CONTROLLER;
else if (!type.compare("SLIDING_MODE_CONTROLLER")) return lspc::ParameterTypes::SLIDING_MODE_CONTROLLER;
else if (!type.compare("FEEDBACK_LINEARIZATION_CONTROLLER")) return lspc::ParameterTypes::FEEDBACK_LINEARIZATION_CONTROLLER;
else return lspc::ParameterTypes::UNKNOWN_CONTROLLER;
}
std::string ParseControllerMode(lspc::ParameterTypes::controllerMode_t mode)
{
if (mode == lspc::ParameterTypes::OFF) return "OFF";
else if (mode == lspc::ParameterTypes::QUATERNION_CONTROL) return "QUATERNION_CONTROL";
else if (mode == lspc::ParameterTypes::VELOCITY_CONTROL) return "VELOCITY_CONTROL";
else if (mode == lspc::ParameterTypes::PATH_FOLLOWING) return "PATH_FOLLOWING";
else return "UNKNOWN_MODE";
}
lspc::ParameterTypes::controllerMode_t ParseControllerMode2(std::string mode)
{
if (!mode.compare("OFF")) return lspc::ParameterTypes::OFF;
else if (!mode.compare("QUATERNION_CONTROL")) return lspc::ParameterTypes::QUATERNION_CONTROL;
else if (!mode.compare("VELOCITY_CONTROL")) return lspc::ParameterTypes::VELOCITY_CONTROL;
else if (!mode.compare("PATH_FOLLOWING")) return lspc::ParameterTypes::PATH_FOLLOWING;
else return lspc::ParameterTypes::UNKNOWN_MODE;
}
lspc::ParameterTypes::slidingManifoldType_t ParseManifoldType2(std::string type)
{
if (!type.compare("Q_DOT_INERTIAL_MANIFOLD")) return lspc::ParameterTypes::Q_DOT_INERTIAL_MANIFOLD;
else if (!type.compare("Q_DOT_BODY_MANIFOLD")) return lspc::ParameterTypes::Q_DOT_BODY_MANIFOLD;
else if (!type.compare("OMEGA_INERTIAL_MANIFOLD")) return lspc::ParameterTypes::OMEGA_INERTIAL_MANIFOLD;
else if (!type.compare("OMEGA_BODY_MANIFOLD")) return lspc::ParameterTypes::OMEGA_BODY_MANIFOLD;
else if (!type.compare("VELOCITY_AND_Q_DOT_MANIFOLD")) return lspc::ParameterTypes::VELOCITY_AND_Q_DOT_MANIFOLD;
else return lspc::ParameterTypes::UNKNOWN_MANIFOLD;
}
std::string ParseManifoldType(lspc::ParameterTypes::slidingManifoldType_t type)
{
if (type == lspc::ParameterTypes::Q_DOT_INERTIAL_MANIFOLD) return "Q_DOT_INERTIAL_MANIFOLD";
else if (type == lspc::ParameterTypes::Q_DOT_BODY_MANIFOLD) return "Q_DOT_BODY_MANIFOLD";
else if (type == lspc::ParameterTypes::OMEGA_INERTIAL_MANIFOLD) return "OMEGA_INERTIAL_MANIFOLD";
else if (type == lspc::ParameterTypes::OMEGA_BODY_MANIFOLD) return "OMEGA_BODY_MANIFOLD";
else if (type == lspc::ParameterTypes::VELOCITY_AND_Q_DOT_MANIFOLD) return "VELOCITY_AND_Q_DOT_MANIFOLD";
else return "UNKNOWN_MANIFOLD";
}
std::string ParsePowerButtonMode(lspc::ParameterTypes::powerButtonMode_t mode)
{
if (mode == lspc::ParameterTypes::POWER_OFF) return "POWER_OFF";
else if (mode == lspc::ParameterTypes::START_STOP_QUATERNION_CONTROL) return "START_STOP_QUATERNION_CONTROL";
else if (mode == lspc::ParameterTypes::START_STOP_VELOCITY_CONTROL) return "START_STOP_VELOCITY_CONTROL";
else return "UNKNOWN_BUTTON_MODE";
}
lspc::ParameterTypes::powerButtonMode_t ParsePowerButtonMode2(std::string mode)
{
if (!mode.compare("POWER_OFF")) return lspc::ParameterTypes::POWER_OFF;
else if (!mode.compare("START_STOP_QUATERNION_CONTROL")) return lspc::ParameterTypes::START_STOP_QUATERNION_CONTROL;
else if (!mode.compare("START_STOP_VELOCITY_CONTROL")) return lspc::ParameterTypes::START_STOP_VELOCITY_CONTROL;
else return lspc::ParameterTypes::UNKNOWN_BUTTON_MODE;
}
void LSPC_Callback_ControllerInfo(ros::Publisher& pubControllerInfo, const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("Controller info received");
const lspc::MessageTypesToPC::ControllerInfo_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::ControllerInfo_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing ControllerInfo message");
return;
}
currentControllerMode = msgRaw->mode;
kugle_msgs::ControllerInfo msg;
msg.receive_time = ros::Time::now();
msg.type = ParseControllerType(msgRaw->type);
msg.mode = ParseControllerMode(msgRaw->mode);
msg.mcu_time = msgRaw->time;
msg.compute_time = msgRaw->compute_time;
msg.torque[0] = msgRaw->torque1;
msg.torque[1] = msgRaw->torque2;
msg.torque[2] = msgRaw->torque3;
msg.delivered_torque[0] = msgRaw->delivered_torque1;
msg.delivered_torque[1] = msgRaw->delivered_torque2;
msg.delivered_torque[2] = msgRaw->delivered_torque3;
pubControllerInfo.publish(msg);
if (reconfigureMutex.try_lock()) {
if (reconfigureConfig.type != msgRaw->type || reconfigureConfig.mode != msgRaw->mode) {
reconfigureConfig.type = int(msgRaw->type);
reconfigureConfig.mode = int(msgRaw->mode);
reconfigureServer->updateConfig(reconfigureConfig);
}
reconfigureMutex.unlock();
}
}
void LSPC_Callback_ControllerDebug(ros::Publisher& pubControllerDebug, const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("Controller debug received");
const lspc::MessageTypesToPC::ControllerDebug_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::ControllerDebug_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing ControllerDebug message");
return;
}
kugle_msgs::ControllerDebug msg;
msg.receive_time = ros::Time::now();
msg.mcu_time = msgRaw->time;
msg.orient.roll = msgRaw->orient.roll;
msg.orient.pitch = msgRaw->orient.pitch;
msg.orient.yaw = msgRaw->orient.yaw;
msg.orient_ref.roll = msgRaw->orient_ref.roll;
msg.orient_ref.pitch = msgRaw->orient_ref.pitch;
msg.orient_ref.yaw = msgRaw->orient_ref.yaw;
msg.orient_integral.roll = msgRaw->orient_integral.roll;
msg.orient_integral.pitch = msgRaw->orient_integral.pitch;
msg.orient_integral.yaw = msgRaw->orient_integral.yaw;
msg.omega.x = msgRaw->omega.x;
msg.omega.y = msgRaw->omega.y;
msg.omega.z = msgRaw->omega.z;
msg.omega_ref.x = msgRaw->omega_ref.x;
msg.omega_ref.y = msgRaw->omega_ref.y;
msg.omega_ref.z = msgRaw->omega_ref.z;
msg.vel.x = msgRaw->vel.x;
msg.vel.y = msgRaw->vel.y;
msg.vel_kinematics.x = msgRaw->vel_kinematics.x;
msg.vel_kinematics.y = msgRaw->vel_kinematics.y;
msg.vel_ref.x = msgRaw->vel_ref.x;
msg.vel_ref.y = msgRaw->vel_ref.y;
msg.torque[0] = msgRaw->torque[0];
msg.torque[1] = msgRaw->torque[1];
msg.torque[2] = msgRaw->torque[2];
msg.S[0] = msgRaw->S[0];
msg.S[1] = msgRaw->S[1];
msg.S[2] = msgRaw->S[2];
pubControllerDebug.publish(msg);
}
void LSPC_Callback_RawSensor_IMU_MPU9250(ros::Publisher& pubIMU, ros::Publisher& pubMag, const std::vector<uint8_t>& payload)
{
const lspc::MessageTypesToPC::RawSensor_IMU_MPU9250_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::RawSensor_IMU_MPU9250_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing RawSensor_IMU_MPU9250 message");
return;
}
sensor_msgs::Imu msg;
msg.header.stamp = ros::Time::now(); // consider to use msgRaw->time ???
/* Raw orientation not provided by IMU */
msg.orientation.w = 0;
msg.orientation.x = 0;
msg.orientation.y = 0;
msg.orientation.z = 0;
msg.orientation_covariance[0] = -1;
/* Insert accelerometer values */
msg.linear_acceleration.x = msgRaw->accelerometer.x;
msg.linear_acceleration.y = msgRaw->accelerometer.y;
msg.linear_acceleration.z = msgRaw->accelerometer.z;
for (int i = 0; i < 9; i++) msg.linear_acceleration_covariance[i] = msgRaw->accelerometer.cov[i];
/* Insert gyroscope values */
msg.angular_velocity.x = msgRaw->gyroscope.x;
msg.angular_velocity.y = msgRaw->gyroscope.y;
msg.angular_velocity.z = msgRaw->gyroscope.z;
for (int i = 0; i < 9; i++) msg.angular_velocity_covariance[i] = msgRaw->gyroscope.cov[i];
/* Insert magnetometer values */
sensor_msgs::MagneticField msgMag;
msgMag.header.stamp = msg.header.stamp;
msgMag.magnetic_field.x = msgRaw->magnetometer.x;
msgMag.magnetic_field.y = msgRaw->magnetometer.y;
msgMag.magnetic_field.z = msgRaw->magnetometer.z;
for (int i = 0; i < 9; i++) msgMag.magnetic_field_covariance[i] = msgRaw->magnetometer.cov[i];
pubIMU.publish(msg);
pubMag.publish(msgMag);
}
void LSPC_Callback_RawSensor_IMU_MTI200(const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("Received Raw Sensor - IMU MTI200");
}
void LSPC_Callback_RawSensor_Battery(ros::Publisher& pubBattery, const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("Received Raw Sensor - Battery");
const lspc::MessageTypesToPC::RawSensor_Battery_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::RawSensor_Battery_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing BatteryInfo message");
return;
}
sensor_msgs::BatteryState msg;
msg.header.stamp = ros::Time::now();
msg.power_supply_status = msgRaw->power_supply_status;
msg.power_supply_health = msgRaw->power_supply_health;
msg.power_supply_technology = msgRaw->power_supply_technology;
msg.current = msgRaw->current;
///sprintf(msg.serial_number,"%x",msgRaw->serial_number) // converts to hexadecimal base.
msg.serial_number = std::to_string(msgRaw->serial_number);
msg.capacity = msgRaw->capacity;
msg.charge = msgRaw->charge;
msg.design_capacity = msgRaw->design_capacity;
msg.location = msgRaw->location;
msg.percentage = msgRaw->percentage;
msg.present = msgRaw->present;
msg.voltage = msgRaw->voltage;
//ros::Publisher pub_battery = n->advertise<sensor_msgs::BatteryState>("battery", 50);
//(*lspcObj)->registerCallback(lspc::MessageTypesToPC::RawSensor_Battery, boost::bind(&LSPC_Callback_RawSensor_Battery, pub_battery, _1));
pubBattery.publish(msg);
}
void LSPC_Callback_powerManagmentInfo(ros::Publisher& pubPowerManagmentInfo, const std::vector<uint8_t>& payload)
{
//ROS_DEBUG_STREAM("Received powerManagment info");
const lspc::MessageTypesToPC::powerManagment_info_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::powerManagment_info_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing powerManagment_info message");
return;
}
kugle_msgs::powerManagmentInfo msg;
msg.receive_time = ros::Time::now();
msg.mcu_time = msgRaw->time;
msg.batteryAssamblyChargePercentage = msgRaw->batteryAssamblyChargePercentage;
msg.batteryAssamblyTotalCharge = msgRaw->batteryAssamblyTotalCharge;
msg.batteryAssamblyTotalCapacity = msgRaw->batteryAssamblyTotalCapacity;
msg.nBatteries = msgRaw->nBatteries;
msg.power_supply_status = msgRaw->power_supply_status;
msg.power_supply_health = msgRaw->power_supply_health;
msg.batteryAssamblyGettingOld = msgRaw->batteryAssamblyGettingOld;
pubPowerManagmentInfo.publish(msg);
}
void LSPC_Callback_RawSensor_Encoders(ros::Publisher& pubEncoders, const std::vector<uint8_t>& payload)
{
const lspc::MessageTypesToPC::RawSensor_Encoders_t * msgRaw = reinterpret_cast<const lspc::MessageTypesToPC::RawSensor_Encoders_t *>(payload.data());
if (sizeof(*msgRaw) != payload.size()) {
ROS_DEBUG("Error parsing RawSensor_Encoders message");
return;
}
kugle_msgs::Encoders msg;
msg.receive_time = ros::Time::now();
msg.mcu_time = msgRaw->time;
msg.angle_wheel1 = msgRaw->angle1;
msg.angle_wheel2 = msgRaw->angle2;
msg.angle_wheel3 = msgRaw->angle3;
pubEncoders.publish(msg);
}
void LSPC_Callback_CPUload(ros::Publisher& pubLoad, const std::vector<uint8_t>& payload)
{
std::string message(payload.data(), payload.data() + payload.size());
ROS_DEBUG_STREAM("Microprocessor CPU Load\n" << message);
/* Publish data to topic as well */
std_msgs::String msg;
msg.data = "\n" + message;
pubLoad.publish(msg);
}
void LSPC_Callback_ArrayDump(std::shared_ptr<std::ofstream> log_file, const std::vector<uint8_t>& payload)
{
int numberOfFloats = payload.size() / 4;
const float * floatArray = reinterpret_cast<const float *>(payload.data());
if (log_file->is_open()) {
for (int i = 0; i < numberOfFloats; i++) {
if (i > 0) *log_file << "\t";
*log_file << std::setprecision(10) << floatArray[i];
}
*log_file << std::endl;
}
}
void LSPC_Callback_Debug(ros::Publisher& pubDebug, const std::vector<uint8_t>& payload)
{
std::string message(payload.data(), payload.data() + payload.size());
ROS_DEBUG_STREAM("Debug message:\n" << message);
/* Publish data to topic as well */
std_msgs::String msg;
msg.data = "\n" + message;
pubDebug.publish(msg);
}
long int GetCurrentMicroseconds()
{
struct timeval tp;
gettimeofday(&tp, NULL);
long int us = tp.tv_sec * 1000000 + tp.tv_usec;
return us;
}
long int GetCurrentMicroseconds2()
{
std::chrono::microseconds us = std::chrono::duration_cast< std::chrono::microseconds >(
std::chrono::system_clock::now().time_since_epoch()
);
return us.count();
}
std::string GetFormattedTimestampCurrent()
{
std::string output;
std::stringstream ss;
int64_t utime = GetCurrentMicroseconds();
std::time_t seconds = utime / 1000000;
int milliseconds = (utime % 1000000) / 1000;
std::tm* t = std::localtime(&seconds);
ss << std::put_time(t, "%Y-%m-%d_%H-%M-%S");
ss << boost::format("-%03d") % milliseconds;
output = ss.str();
return output;
}
void ROS_Callback_cmd_vel(const geometry_msgs::Twist::ConstPtr& msg, std::shared_ptr<std::timed_mutex> lspcMutex, std::shared_ptr<lspc::Socket *> lspcObj) {
if (!lspcMutex->try_lock_for(std::chrono::milliseconds(100))) return; // could not get lock
if ((*lspcObj)->isOpen()) {
//ROS_DEBUG_STREAM("Sending cmd_vel to Kugle as both VelocityReference_Heading and AngularVelocityReference_Body");
lspc::MessageTypesFromPC::VelocityReference_t payload;
payload.frame = lspc::ParameterTypes::HEADING_FRAME;
payload.vel.x = msg->linear.x;
payload.vel.y = msg->linear.y;
payload.vel.yaw = msg->angular.z;
std::vector<uint8_t> payloadPacked((uint8_t *)&payload, (uint8_t *)&payload+sizeof(payload)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::VelocityReference, payloadPacked);
lspc::MessageTypesFromPC::AngularVelocityReference_t payload2;
payload2.frame = lspc::ParameterTypes::BODY_FRAME;
payload2.omega.x = msg->angular.x;
payload2.omega.y = msg->angular.y;
payload2.omega.z = msg->angular.z;
std::vector<uint8_t> payloadPacked2((uint8_t *)&payload2, (uint8_t *)&payload2+sizeof(payload2)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::AngularVelocityReference, payloadPacked2);
}
lspcMutex->unlock();
}
void ROS_Callback_cmd_vel_inertial(const geometry_msgs::Twist::ConstPtr& msg, std::shared_ptr<std::timed_mutex> lspcMutex, std::shared_ptr<lspc::Socket *> lspcObj) {
if (!lspcMutex->try_lock_for(std::chrono::milliseconds(100))) return; // could not get lock
if ((*lspcObj)->isOpen()) {
//ROS_DEBUG_STREAM("Sending cmd_vel_inertial to Kugle as both VelocityReference_Inertial and AngularVelocityReference_Inertial");
lspc::MessageTypesFromPC::VelocityReference_t payload;
payload.frame = lspc::ParameterTypes::INERTIAL_FRAME;
payload.vel.x = msg->linear.x;
payload.vel.y = msg->linear.y;
payload.vel.yaw = msg->angular.z;
std::vector<uint8_t> payloadPacked((uint8_t *)&payload, (uint8_t *)&payload+sizeof(payload)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::VelocityReference, payloadPacked);
lspc::MessageTypesFromPC::AngularVelocityReference_t payload2;
payload2.frame = lspc::ParameterTypes::INERTIAL_FRAME;
payload2.omega.x = msg->angular.x;
payload2.omega.y = msg->angular.y;
payload2.omega.z = msg->angular.z;
std::vector<uint8_t> payloadPacked2((uint8_t *)&payload2, (uint8_t *)&payload2+sizeof(payload2)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::AngularVelocityReference, payloadPacked2);
}
lspcMutex->unlock();
}
void ROS_Callback_cmd_quaternion(const geometry_msgs::Quaternion::ConstPtr& msg, std::shared_ptr<std::timed_mutex> lspcMutex, std::shared_ptr<lspc::Socket *> lspcObj) {
if (!lspcMutex->try_lock_for(std::chrono::milliseconds(100))) return; // could not get lock
if ((*lspcObj)->isOpen()) {
//ROS_DEBUG_STREAM("Sending cmd_quaternion to Kugle");
lspc::MessageTypesFromPC::QuaternionReference_t payload;
payload.q.w = msg->w;
payload.q.x = msg->x;
payload.q.y = msg->y;
payload.q.z = msg->z;
std::vector<uint8_t> payloadPacked((uint8_t *)&payload, (uint8_t *)&payload+sizeof(payload)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::QuaternionReference, payloadPacked);
}
lspcMutex->unlock();
}
void ROS_Callback_cmd_combined(const kugle_msgs::BalanceControllerReference::ConstPtr& msg, std::shared_ptr<std::timed_mutex> lspcMutex, std::shared_ptr<lspc::Socket *> lspcObj) {
if (!lspcMutex->try_lock_for(std::chrono::milliseconds(100))) return; // could not get lock
if ((*lspcObj)->isOpen()) {
//ROS_DEBUG_STREAM("Sending cmd_quaternion to Kugle");
lspc::MessageTypesFromPC::BalanceControllerReference_t payload;
payload.frame = lspc::ParameterTypes::BODY_FRAME;
payload.q.w = msg->q.w;
payload.q.x = msg->q.x;
payload.q.y = msg->q.y;
payload.q.z = msg->q.z;
payload.omega.x = msg->omega.x;
payload.omega.y = msg->omega.y;
payload.omega.z = msg->omega.z;
std::vector<uint8_t> payloadPacked((uint8_t *)&payload, (uint8_t *)&payload+sizeof(payload)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::BalanceControllerReference, payloadPacked);
}
lspcMutex->unlock();
}
void ROS_Callback_cmd_combined_inertial(const kugle_msgs::BalanceControllerReference::ConstPtr& msg, std::shared_ptr<std::timed_mutex> lspcMutex, std::shared_ptr<lspc::Socket *> lspcObj) {
if (!lspcMutex->try_lock_for(std::chrono::milliseconds(100))) return; // could not get lock
if ((*lspcObj)->isOpen()) {
//ROS_DEBUG_STREAM("Sending cmd_quaternion to Kugle");
lspc::MessageTypesFromPC::BalanceControllerReference_t payload;
payload.frame = lspc::ParameterTypes::INERTIAL_FRAME;
payload.q.w = msg->q.w;
payload.q.x = msg->q.x;
payload.q.y = msg->q.y;
payload.q.z = msg->q.z;
payload.omega.x = msg->omega.x;
payload.omega.y = msg->omega.y;
payload.omega.z = msg->omega.z;
std::vector<uint8_t> payloadPacked((uint8_t *)&payload, (uint8_t *)&payload+sizeof(payload)); // this method of "serializing" requires that PC runs Little Endian (which most PC processors do = Intel x86, AMD 64 etc.)
(*lspcObj)->send(lspc::MessageTypesFromPC::BalanceControllerReference, payloadPacked);
}
lspcMutex->unlock();
}
bool ParseParamTypeAndID(const std::string in_type, const std::string in_param, lspc::ParameterLookup::type_t& out_type, uint8_t& out_param, lspc::ParameterLookup::ValueType_t& out_valueType, uint8_t& out_arraySize)
{
if (!in_type.compare("debug")) out_type = lspc::ParameterLookup::debug;
else if (!in_type.compare("behavioural")) out_type = lspc::ParameterLookup::behavioural;
else if (!in_type.compare("controller")) out_type = lspc::ParameterLookup::controller;
else if (!in_type.compare("estimator")) out_type = lspc::ParameterLookup::estimator;
else if (!in_type.compare("model")) out_type = lspc::ParameterLookup::model;
else if (!in_type.compare("test")) out_type = lspc::ParameterLookup::test;
else {
ROS_DEBUG("Parameter lookup: Type not found");
return false; // not found
}
/* Arrays not supported yet, so set array size to 1 always */
out_arraySize = 1;
/* Parse parameter text */
if (out_type == lspc::ParameterLookup::debug) {
if (!in_param.compare("EnableDumpMessages")) {
out_param = lspc::ParameterLookup::EnableDumpMessages;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EnableRawSensorOutput")) {
out_param = lspc::ParameterLookup::EnableRawSensorOutput;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("UseFilteredIMUinRawSensorOutput")) {
out_param = lspc::ParameterLookup::UseFilteredIMUinRawSensorOutput;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("DisableMotorOutput")) {
out_param = lspc::ParameterLookup::DisableMotorOutput;
out_valueType = lspc::ParameterLookup::_bool;
}
else {
ROS_DEBUG("Parameter lookup: Parameter not found (type=%s, param=%s)", in_type.c_str(), in_param.c_str());
return false;
}
}
else if (out_type == lspc::ParameterLookup::behavioural) {
if (!in_param.compare("IndependentHeading")) {
out_param = lspc::ParameterLookup::IndependentHeading;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("YawVelocityBraking")) {
out_param = lspc::ParameterLookup::YawVelocityBraking;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("StepTestEnabled")) {
out_param = lspc::ParameterLookup::StepTestEnabled;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("SineTestEnabled")) {
out_param = lspc::ParameterLookup::SineTestEnabled;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("CircleTestEnabled")) {
out_param = lspc::ParameterLookup::CircleTestEnabled;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("PowerButtonMode")) {
out_param = lspc::ParameterLookup::PowerButtonMode;
out_valueType = lspc::ParameterLookup::_uint8;
}
else {
ROS_DEBUG("Parameter lookup: Parameter not found (type=%s, param=%s)", in_type.c_str(), in_param.c_str());
return false;
}
}
else if (out_type == lspc::ParameterLookup::controller) {
if (!in_param.compare("type")) {
out_param = lspc::ParameterLookup::type;
out_valueType = lspc::ParameterLookup::_uint8;
}
else if (!in_param.compare("mode")) {
out_param = lspc::ParameterLookup::mode;
out_valueType = lspc::ParameterLookup::_uint8;
}
else if (!in_param.compare("EnableTorqueLPF")) {
out_param = lspc::ParameterLookup::EnableTorqueLPF;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("MotorFailureDetection")) {
out_param = lspc::ParameterLookup::MotorFailureDetection;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("ManifoldType")) {
out_param = lspc::ParameterLookup::ManifoldType;
out_valueType = lspc::ParameterLookup::_uint8;
}
else if (!in_param.compare("ContinousSwitching")) {
out_param = lspc::ParameterLookup::ContinousSwitching;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EquivalentControl")) {
out_param = lspc::ParameterLookup::EquivalentControl;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("eta")) {
out_param = lspc::ParameterLookup::eta;
out_valueType = lspc::ParameterLookup::_float;
out_arraySize = 3;
}
else if (!in_param.compare("epsilon")) {
out_param = lspc::ParameterLookup::epsilon;
out_valueType = lspc::ParameterLookup::_float;
out_arraySize = 3;
}
else if (!in_param.compare("K")) {
out_param = lspc::ParameterLookup::K;
out_valueType = lspc::ParameterLookup::_float;
out_arraySize = 3;
}
else if (!in_param.compare("Kx")) {
out_param = lspc::ParameterLookup::Kx;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Ky")) {
out_param = lspc::ParameterLookup::Ky;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kz")) {
out_param = lspc::ParameterLookup::Kz;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kf")) {
out_param = lspc::ParameterLookup::Kf;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfp_x")) {
out_param = lspc::ParameterLookup::Kfp_x;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfp_y")) {
out_param = lspc::ParameterLookup::Kfp_x;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfp_z")) {
out_param = lspc::ParameterLookup::Kfp_z;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfv_x")) {
out_param = lspc::ParameterLookup::Kfv_x;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfv_y")) {
out_param = lspc::ParameterLookup::Kfv_y;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kfv_z")) {
out_param = lspc::ParameterLookup::Kfv_z;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kv_x")) {
out_param = lspc::ParameterLookup::Kv_x;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kv_y")) {
out_param = lspc::ParameterLookup::Kv_y;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kvi_x")) {
out_param = lspc::ParameterLookup::Kvi_x;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("Kvi_y")) {
out_param = lspc::ParameterLookup::Kvi_y;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("gamma")) {
out_param = lspc::ParameterLookup::gamma;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("AngularVelocityClamps")) {
out_param = lspc::ParameterLookup::AngularVelocityClamps;
out_valueType = lspc::ParameterLookup::_float;
out_arraySize = 3;
}
else if (!in_param.compare("AngularVelocityClampsEnabled")) {
out_param = lspc::ParameterLookup::AngularVelocityClampsEnabled;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("DisableQdot")) {
out_param = lspc::ParameterLookup::DisableQdot;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("DisableQdotInEquivalentControl")) {
out_param = lspc::ParameterLookup::DisableQdotInEquivalentControl;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("DisableOmegaXYInEquivalentControl")) {
out_param = lspc::ParameterLookup::DisableOmegaXYInEquivalentControl;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("VelocityControl_AccelerationLimit")) {
out_param = lspc::ParameterLookup::VelocityControl_AccelerationLimit;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_MaxTilt")) {
out_param = lspc::ParameterLookup::VelocityController_MaxTilt;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_MaxIntegralCorrection")) {
out_param = lspc::ParameterLookup::VelocityController_MaxIntegralCorrection;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_VelocityClamp")) {
out_param = lspc::ParameterLookup::VelocityController_VelocityClamp;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_IntegralGain")) {
out_param = lspc::ParameterLookup::VelocityController_IntegralGain;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_AngleLPFtau")) {
out_param = lspc::ParameterLookup::VelocityController_AngleLPFtau;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityController_OmegaLPFtau")) {
out_param = lspc::ParameterLookup::VelocityController_OmegaLPFtau;
out_valueType = lspc::ParameterLookup::_float;
}
else if (!in_param.compare("VelocityControl_UseOmegaRef")) {
out_param = lspc::ParameterLookup::VelocityControl_UseOmegaRef;
out_valueType = lspc::ParameterLookup::_bool;
}
else {
ROS_DEBUG("Parameter lookup: Parameter not found (type=%s, param=%s)", in_type.c_str(), in_param.c_str());
return false;
}
}
else if (out_type == lspc::ParameterLookup::estimator) {
if (!in_param.compare("EnableSensorLPFfilters")) {
out_param = lspc::ParameterLookup::EnableSensorLPFfilters;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EnableSoftwareLPFfilters")) {
out_param = lspc::ParameterLookup::EnableSoftwareLPFfilters;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("UseMadgwick")) {
out_param = lspc::ParameterLookup::UseMadgwick;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EstimateBias")) {
out_param = lspc::ParameterLookup::EstimateBias;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("SensorDrivenQEKF")) {
out_param = lspc::ParameterLookup::SensorDrivenQEKF;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("UseVelocityEstimator")) {
out_param = lspc::ParameterLookup::UseVelocityEstimator;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("UseCoRvelocity")) {
out_param = lspc::ParameterLookup::UseCoRvelocity;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EnableVelocityLPF")) {
out_param = lspc::ParameterLookup::EnableVelocityLPF;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EnableWheelSlipDetector")) {
out_param = lspc::ParameterLookup::EnableWheelSlipDetector;
out_valueType = lspc::ParameterLookup::_bool;
}
else if (!in_param.compare("EstimateCOM")) {
out_param = lspc::ParameterLookup::EstimateCOM;
out_valueType = lspc::ParameterLookup::_bool;