-
Notifications
You must be signed in to change notification settings - Fork 1
/
central_node.cpp
765 lines (610 loc) · 23 KB
/
central_node.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
/*
Description: A node for sending and receiving sensorimotor data from the NAO robot.
Modified by Mehdi Tlili for the homework of the lecture:
Biologically inspired learning for humanoid robotics (BILHR)
*/
#include <ros/ros.h>
// ROS and OpenCV image processing
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Image.h>
#include <cv.h>
#include <highgui.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float32MultiArray.h>
#include <std_msgs/Int32.h>
#include "std_msgs/String.h"
#include <fstream>
// own files
#include "robot_config.h"
#include "cmac.h"
#include <time.h>
#include <math.h>
using namespace std;
using namespace cv;
using namespace sensor_msgs;
using namespace message_filters;
namespace enc = sensor_msgs::image_encodings;
// subscribers to tactile and touch sensors
ros::Subscriber tactile_sub;
ros::Subscriber bumper_sub;
// publisher to robot joints for sending the target joint angles
ros::Publisher target_joint_state_pub;
// joint stiffnesses
ros::Publisher stiffness_pub;
// received motor state of the HEAD
double motor_head_in[HEAD_JOINTS];
// received motor state of the LEFT ARM
double motor_l_arm_in[L_ARM_JOINTS];
// received motor state of the RIGHT ARM
double motor_r_arm_in[R_ARM_JOINTS];
// label of the GUI window showing the raw image of NAO's camera
static const char cam_window[] = "NAO Camera (raw image)";
//========================By Mehdi Tlili===========================//
//Flag for knowing which button was pushed last
int T2pushed = 0;
int T3pushed = 0;
int counterLArm = 0;
double initPosLArm[L_ARM_JOINTS];
double tempPos[L_ARM_JOINTS];
Point ballPos;
bool isSavingData;
bool isTestingData;
//=======================By Mehdi Tlili ==============================//
//==============================Added by Mehdi Tlili====================//
//Parameters for the CMAC neural network
int res = 50;
int na = 5;
int ny = 2;
int nx = 2;
double gamma_cmac = 0.1;
//Create cmac class
cmac nao(nx,ny,na,0,320,240,res);
//==============================Added by Mehdi Tlili====================//
//==============================BY Mehdi TLILI =====================//
// set the stiffness
void setStiffnessHead(float value)
{
cout << "setting stiffnesses (head) to " << value << endl;
BILHR_ros::JointState target_joint_stiffness;
// set stiffnesses of HEAD joints
target_joint_stiffness.name.clear();
target_joint_stiffness.name.push_back("Head");
target_joint_stiffness.effort.clear();
for (int i=0; i<HEAD_JOINTS; i++)
target_joint_stiffness.effort.push_back(value);
stiffness_pub.publish(target_joint_stiffness);
}
//==============================Added by Mehdi Tlili====================//
//==============================Added by Mehdi Tlili====================//
// set the stiffness for Left Arm
void setStiffnessLArm(float value)
{
cout << "setting stiffnesses (LArm) to " << value << endl;
BILHR_ros::JointState target_joint_stiffness;
// set stiffnesses of LArm joints
target_joint_stiffness.name.clear();
target_joint_stiffness.name.push_back("LArm");
target_joint_stiffness.effort.clear();
for (int i=0; i<L_ARM_JOINTS; i++)
target_joint_stiffness.effort.push_back(value);
stiffness_pub.publish(target_joint_stiffness);
}
//==============================Added by Mehdi Tlili====================//
//==============================Added by Mehdi Tlili====================//
void setStiffnessLArmCMAC(float value)
{
cout << "setting stiffnesses (LArm) to " << value << endl;
BILHR_ros::JointState target_joint_stiffness;
// set stiffnesses of LArm joints
target_joint_stiffness.name.clear();
target_joint_stiffness.name.push_back("LArm");
target_joint_stiffness.effort.clear();
for (int i=0; i<2; i++)
target_joint_stiffness.effort.push_back(0);
for (int i=2; i<L_ARM_JOINTS; i++)
target_joint_stiffness.effort.push_back(0.9);
stiffness_pub.publish(target_joint_stiffness);
}
//==============================Added by Mehdi Tlili====================//
//==============================Added by Mehdi Tlili====================//
void setStiffnessRArm(float value)
{
cout << "setting stiffnesses (RArm) to " << value << endl;
BILHR_ros::JointState target_joint_stiffness;
// set stiffnesses of LArm joints
target_joint_stiffness.name.clear();
target_joint_stiffness.name.push_back("RArm");
target_joint_stiffness.effort.clear();
for (int i=0; i<R_ARM_JOINTS; i++)
target_joint_stiffness.effort.push_back(value);
stiffness_pub.publish(target_joint_stiffness);
}
//==============================Added by Mehdi Tlili====================//
//==============================BY Mehdi TLILI =====================//
//Function to Save training data for CMAC
void saveTrainingData(const BILHR_ros::JointState::ConstPtr& joint_state)
{
// buffer for incoming message
std_msgs::Float32MultiArray buffer;
// extract the proprioceptive state of the LEFT ARM
buffer.data.clear();
for (int i=0; i<ROBOT_JOINTS; i++)
{
if (joint_state->name[i] == "LShoulderPitch")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LShoulderRoll")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
}
//Save the training data containing ball position and arm position
if(ballPos.x >0 && ballPos.y >0)
{
ofstream myfile;
myfile.open("/home/pcnao03/trainingData.txt",ios_base::app);
cout<<buffer.data.at(0)<<"\t"<<buffer.data.at(1)<<"\t"<<ballPos.x<<"\t"<<ballPos.y<<endl;
myfile <<buffer.data.at(0)<<"\t"<<buffer.data.at(1)<<"\t"<<ballPos.x<<"\t"<<ballPos.y<<"\n";
myfile.close();
}
}
//==============================Added by Mehdi Tlili====================//
// callback function for vision
void visionCB(const sensor_msgs::ImageConstPtr& msg)
{
// pointer on OpenCV image
cv_bridge::CvImagePtr cv_ptr;
cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
Mat HSVImage;
Mat ThreshImage;
try
{
// transform ROS image into OpenCV image
cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
//==============================Added by Mehdi Tlili====================//
//Transform the colors into HSV
cvtColor(cv_ptr->image,HSVImage,CV_BGR2HSV);
//for blue ball
//inRange(HSVImage,Scalar(80,90,70),Scalar(110,125,200),ThreshImage);
//for red ball
inRange(HSVImage,Scalar(170,160,60),Scalar(180,256,256),ThreshImage);
SimpleBlobDetector *blobs;
SimpleBlobDetector::Params params;
params.minArea = 50.0f;
params.filterByArea = true;
params.filterByInertia = false;
params.filterByColor = false;
params.filterByConvexity = false;
params.filterByCircularity = false;
params.minDistBetweenBlobs = 50.0f;
blobs = new SimpleBlobDetector(params);
blobs->create("SimpleBlobDetector");
vector<cv::KeyPoint> keypoints;
blobs->detect(ThreshImage,keypoints);
//printf("Size of blob = %d\n",keypoints.size());
double c_x = 0;
double c_y = 0;
//get centroid of the blob
if(keypoints.size() >0)
{
for(int i = 0;i<keypoints.size();i++)
{
c_x+=keypoints[i].pt.x;
c_y+=keypoints[i].pt.y;
}
c_x/=keypoints.size();
c_y/=keypoints.size();
Point pt;
pt.x = (int)c_x;
pt.y = (int)c_y;
//For training
ballPos.x = (int)c_x;
ballPos.y = (int)c_y;
circle(ThreshImage,pt,20,Scalar(255,0,0),3);
}
//==============================Added by Mehdi Tlili====================//
}
catch (cv_bridge::Exception& e) // throw an error msg. if conversion fails
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
//show the raw camera image
//imshow(cam_window, cv_ptr->image);
//show filtered HSV image containing the blob
imshow(cam_window,ThreshImage);
waitKey(1);
}
// callback function for bumpers
void bumperCB(const BILHR_ros::Bumper::ConstPtr& __bumper)
{
// check each bumper
cout << "bumper " << (int)__bumper->bumper << endl;
static bool left_bumper_flag = false;
static bool right_bumper_flag = false;
// check left bumper
if (((int)__bumper->bumper == 1) && ((int)__bumper->state == 1))
{
left_bumper_flag = !left_bumper_flag; // toggle flag
// do something, e.g.:
// set / reset stiffness
if (left_bumper_flag)
setStiffnessHead(0.005);
setStiffnessLArm(0.005);
setStiffnessRArm(0.005);
//T2pushed = 0;
//T1pushed = 0;
// else
// setStiffness(0.9);
}
// check right bumper
if (((int)__bumper->bumper == 0) && ((int)__bumper->state == 1))
{
//==============================Added by Mehdi Tlili====================//
right_bumper_flag = !right_bumper_flag; // toggle flag
setStiffnessHead(0.8);
//==============================Added by Mehdi Tlili====================//
}
}
// send commanded joint positions of the HEAD
void sendTargetJointStateHead(double* coordinates)
{
//double dummy[HEAD_JOINTS]; // dummy representing the comanded joint state
BILHR_ros::JointAnglesWithSpeed target_joint_state;
// specify the limb
target_joint_state.joint_names.clear();
target_joint_state.joint_names.push_back("Head");
// specifiy the angle
target_joint_state.joint_angles.clear();
for (int i=0; i<HEAD_JOINTS; i++)
target_joint_state.joint_angles.push_back(coordinates[i] /* array containing result */);
// set speed
target_joint_state.speed = 0.2;
// set the mode of joint change
target_joint_state.relative = 0;
// send to robot
target_joint_state_pub.publish(target_joint_state);
}
//==============================Added by Mehdi Tlili====================//
// send commanded joint positions of the LEFT ARM
void sendTargetJointStateLArm(double *coordinates)
{
BILHR_ros::JointAnglesWithSpeed target_joint_state;
// specify the limb
target_joint_state.joint_names.clear();
target_joint_state.joint_names.push_back("LArm");
// specifiy the angle
target_joint_state.joint_angles.clear();
for (int i=0; i<L_ARM_JOINTS; i++)
target_joint_state.joint_angles.push_back(coordinates[i] /* array containing result */);
// set speed
target_joint_state.speed = 0.2;
// set the mode of joint change
target_joint_state.relative = 0;
// send to robot
target_joint_state_pub.publish(target_joint_state);
cout << "Sent new position for left arm" << endl;
}
//==============================Added by Mehdi Tlili====================//
//==============================Added by Mehdi Tlili====================//
void sendTargetJointStateRArm(double *coordinates)
{
BILHR_ros::JointAnglesWithSpeed target_joint_state;
// specify the limb
target_joint_state.joint_names.clear();
target_joint_state.joint_names.push_back("RArm");
// specifiy the angle
target_joint_state.joint_angles.clear();
for (int i=0; i<R_ARM_JOINTS; i++)
target_joint_state.joint_angles.push_back(coordinates[i] /* array containing result */);
// set speed
target_joint_state.speed = 0.2;
// set the mode of joint change
target_joint_state.relative = 0;
// send to robot
target_joint_state_pub.publish(target_joint_state);
cout << "Sent new position for right arm" << endl;
}
//==============================Added by Mehdi Tlili====================//
// callback function for the head joints
void jointStateCB(const BILHR_ros::JointState::ConstPtr& joint_state)
{
// buffer for incoming message
std_msgs::Float32MultiArray buffer;
// index
int idx;
// extract the proprioceptive state of the HEAD
buffer.data.clear();
for (int i=0; i<ROBOT_JOINTS; i++)
{
if (joint_state->name[i] == "HeadYaw")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << ": " << joint_state->position[i] << endl;
}
if (joint_state->name[i] == "HeadPitch")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << ": " << joint_state->position[i] << endl;
}
}
// write data into array
idx = 0;
for(vector<float>::const_iterator iter = buffer.data.begin(); iter != buffer.data.end(); ++iter)
{
// store into temporary target motor state buffer
motor_head_in[idx] = *iter;
idx++;
}
// display data on terminal
/*cout << "Head joints: ";
for (int i=0; i<HEAD_JOINTS; i++)
cout << motor_head_in[i] << " ";
cout << endl;*/
// extract the proprioceptive state of the LEFT ARM
buffer.data.clear();
for (int i=0; i<ROBOT_JOINTS; i++)
{
if (joint_state->name[i] == "LShoulderPitch")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LShoulderRoll")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LElbowYaw")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LElbowRoll")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LWristYaw")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "LHand")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
}
// write data into array
idx = 0;
for(vector<float>::const_iterator iter = buffer.data.begin(); iter != buffer.data.end(); ++iter)
{
// store into temporary target motor state buffer
motor_l_arm_in[idx] = *iter;
idx++;
}
// extract the proprioceptive state of the RIGHT ARM
buffer.data.clear();
for (int i=0; i<ROBOT_JOINTS; i++)
{
if (joint_state->name[i] == "RShoulderPitch")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "RShoulderRoll")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "RElbowYaw")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "RElbowRoll")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "RWristYaw")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
if (joint_state->name[i] == "RHand")
{
buffer.data.push_back(joint_state->position[i]);
// cout << joint_state->name[i] << endl;
}
}
// write data into array
idx = 0;
for(vector<float>::const_iterator iter = buffer.data.begin(); iter != buffer.data.end(); ++iter)
{
// store into temporary target motor state buffer
motor_r_arm_in[idx] = *iter;
idx++;
}
//==============================Added by Mehdi Tlili====================//
//Save training data
if(isSavingData)
{
printf("Saving Data\n");
saveTrainingData(joint_state);
isSavingData = false;
}
//Test trained CMAC with the ball
if(isTestingData)
{
setStiffnessLArm(0.9);
printf("Testing Data\n");
double output1,output2;
double coordinates[6] = {0,0,0,0,-3.14,0};
if(ballPos.x >0 && ballPos.y >0)
{
nao.map(ballPos.x, ballPos.y,&output1,&output2);
cout<<"Joint1 = "<<output1<<endl<<"Joint2 = "<<output2<<endl;
coordinates[0] = output1;
coordinates[1] = output2;
sendTargetJointStateLArm(coordinates);
}
}
//==============================Added by Mehdi Tlili====================//
}
//callback function for tactile buttons (TBs) on the head
void tactileCB(const BILHR_ros::TactileTouch::ConstPtr& __tactile_touch)
{
// check TB 3 (rear)
if (((int)__tactile_touch->button == 3) && ((int)__tactile_touch->state == 1))
{
cout << "TB " << (int)__tactile_touch->button << " touched" << endl;
//==============================Added by Mehdi Tlili====================//
double a, b,c,d;
//Choose if for generating new training data or training CMAC with existing data
bool forTraining = true;
if(forTraining)
{
//Train CMAC From saved training data and do 100 iterations
for(int iter = 0;iter<100;iter++)
{
//cout<<"Iter training = "<<iter<<endl;
std::string line;
std::ifstream myfile ;
myfile.open("/home/pcnao03/trainingData.txt");
double x;
//cout<<"if file opened " <<myfile.is_open()<<endl;
while (!myfile.eof())
{
std::getline(myfile, line);
//cout<<line<<endl;
std::istringstream iss(line);
if (!(iss >> a >> b >>c >>d )) { break; }
cout <<"y1 = "<<c<<" y2 = "<<d<<endl;
try
{
nao.train(c,d,a,b);
}
catch(int e)
{
cout<<"error detected"<<endl;
}
}
myfile.close();
}
cout <<"Training finished"<<endl;
}
else
{
//Save new training data
isSavingData = true;
}
//==============================Added by Mehdi Tlili====================//
}
// check TB 2 (middle)
if (((int)__tactile_touch->button == 2) && ((int)__tactile_touch->state == 1))
{
cout << "TB " << (int)__tactile_touch->button << " touched" << endl;
//==============================Added by Mehdi Tlili====================//
//Put Nao in initial position for training or testing
setStiffnessHead(0.9);
setStiffnessLArmCMAC(0);
double tmp[6] = {0, 0, 0, 0, -3.14,0};
sendTargetJointStateLArm(tmp);
double tmp2[2] = {3.14/4 ,0};
sendTargetJointStateHead(tmp2);
//==============================Added by Mehdi Tlili====================//
}
// check TB 1 (front)
if (((int)__tactile_touch->button == 1) && ((int)__tactile_touch->state == 1))
{
cout << "TB " << (int)__tactile_touch->button << " touched" << endl;
//==============================Added by Mehdi Tlili====================//
//Testing only when pushing button
/* setStiffnessLArm(0.9);
printf("Testing Data\n");
double output1,output2;
double coordinates[6] = {0,0,0,0,-3.14,0};
if(ballPos.x >0 && ballPos.y >0)
{
nao.map(ballPos.x, ballPos.y,&output1,&output2);
cout<<"Joint1 = "<<output1<<endl<<"Joint2 = "<<output2<<endl;
coordinates[0] = output1;
coordinates[1] = output2;
sendTargetJointStateLArm(coordinates);
}*/
//continuous testing, makes the robot reach for the ball with his left arm continously
isTestingData = !isTestingData;
//==============================Added by Mehdi Tlili====================//
}
}
// send commanded joint positions of the RIGHT ARM
void sendTargetJointStateRArm(/* maybe a result as function argument */)
{
double dummy[R_ARM_JOINTS]; // dummy representing the comanded joint state
BILHR_ros::JointAnglesWithSpeed target_joint_state;
// specify the limb
target_joint_state.joint_names.clear();
target_joint_state.joint_names.push_back("RArm");
// specifiy the angle
target_joint_state.joint_angles.clear();
for (int i=0; i<R_ARM_JOINTS; i++)
target_joint_state.joint_angles.push_back(dummy[i] /* array containing result */);
// set speed
target_joint_state.speed = 0.2;
// set the mode of joint change
target_joint_state.relative = 0;
// send to robot
target_joint_state_pub.publish(target_joint_state);
}
// callback function for key events
void keyCB(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("key pushed: %s", msg->data.c_str());
// start the robot behaviour
if (*(msg->data.c_str()) == '0')
{
cout << "keyCB()" << endl;
}
}
int main(int argc, char** argv)
{
//Init node
ros::init(argc, argv, "central_node");
ros::NodeHandle central_node_nh;
// messaging with the NAO nodes
// advertise joint stiffnesses
stiffness_pub = central_node_nh.advertise<BILHR_ros::JointState>("joint_stiffness", 1);
// subscribe to the joint states
// the topic is the same as the one of the wrapper node of the NAO robot
ros::Subscriber joint_state_sub;
joint_state_sub = central_node_nh.subscribe("joint_states", 1, &jointStateCB);
// advertise the target joint states
target_joint_state_pub = central_node_nh.advertise<BILHR_ros::JointAnglesWithSpeed>("joint_angles", 1); // to NAO robot
// using image_transport to publish and subscribe to images
image_transport::ImageTransport image_tran(central_node_nh);
// subscribe to the raw camera image
image_transport::Subscriber image_sub;
image_sub = image_tran.subscribe("image_raw", 1, &visionCB);
// subscribe to tactile and touch sensors
tactile_sub = central_node_nh.subscribe("tactile_touch", 1, tactileCB);
bumper_sub = central_node_nh.subscribe("bumper", 1, bumperCB);
// set up the subscriber for the keyboard
ros::Subscriber key_sub;
key_sub = central_node_nh.subscribe("key", 5, keyCB);
// create a GUI window for the raw camera image
namedWindow(cam_window, 0);
isTestingData = false;
ros::spin();
return 0;
}