dashboard.cpp
Go to the documentation of this file.
1 
9 Dashboard::Dashboard(ros::NodeHandle* nh, QWidget* parent)
10  : QMainWindow(parent), ui(new Ui::Dashboard), nh(nh)
11 {
12  ui->setupUi(this);
14  x = 0;
15  y = 0;
16  z = 0;
25 
26  ui->modeSelection->addItem(QString("Remote Control"), QVariant());
27  ui->modeSelection->addItem(QString("Follow Wall"), QVariant());
28  ui->modeSelection->addItem(QString("Roundtrip w. Obstacles"), QVariant());
29  ui->modeSelection->addItem(QString("Park Car"), QVariant());
30  ui->modeSelection->addItem(QString("Lane Detection"), QVariant());
31  ui->modeSelection->addItem(QString("Exploration"), QVariant());
32 
34 }
35 
37 
39 {
40  if (nh->hasParam("dashboard/mode_control_topic"))
41  {
42  nh->getParam("dashboard/mode_control_topic", modeControlTopic);
43  }
44  else
45  {
47  }
48  if (nh->hasParam("dashboard/steering_command_topic"))
49  {
50  nh->getParam("dashboard/steering_command_topic", steeringCommandTopic);
51  }
52  else
53  {
55  }
56  if (nh->hasParam("dashboard/motor_command_topic"))
57  {
58  nh->getParam("dashboard/motor_command_topic", motorCommandTopic);
59  }
60  else
61  {
63  }
64  if (nh->hasParam("dashboard/imu_topic"))
65  {
66  nh->getParam("dashboard/imu_topic", imuTopic);
67  }
68  else
69  {
71  }
72  if (nh->hasParam("dashboard/magnetic_topic"))
73  {
74  nh->getParam("dashboard/magnetic_topic", magneticTopic);
75  }
76  else
77  {
79  }
80  if (nh->hasParam("dashboard/usr_topic"))
81  {
82  nh->getParam("dashboard/usr_topic", usrTopic);
83  }
84  else
85  {
87  }
88  if (nh->hasParam("dashboard/usl_topic"))
89  {
90  nh->getParam("dashboard/usl_topic", uslTopic);
91  }
92  else
93  {
95  }
96  if (nh->hasParam("dashboard/usf_topic"))
97  {
98  nh->getParam("dashboard/usf_topic", usfTopic);
99  }
100  else
101  {
103  }
104  if (nh->hasParam("dashboard/hallcnt_topic"))
105  {
106  nh->getParam("dashboard/hallcnt_topic", hallCntTopic);
107  }
108  else
109  {
111  }
112  if (nh->hasParam("dashboard/halldt_topic"))
113  {
114  nh->getParam("dashboard/halldt_topic", hallDtTopic);
115  }
116  else
117  {
119  }
120  if (nh->hasParam("dashboard/halldt8_topic"))
121  {
122  nh->getParam("dashboard/halldt8_topic", hallDt8Topic);
123  }
124  else
125  {
127  }
128  if (nh->hasParam("dashboard/sys_bat_topic"))
129  {
130  nh->getParam("dashboard/sys_bat_topic", vsBatTopic);
131  }
132  else
133  {
135  }
136  if (nh->hasParam("dashboard/drv_bat_topic"))
137  {
138  nh->getParam("dashboard/drv_bat_topic", vdBatTopic);
139  }
140  else
141  {
143  }
144  if (nh->hasParam("dashboard/get_car_id_service"))
145  {
146  nh->getParam("dashboard/get_car_id_service", getCarIdService);
147  }
148  else
149  {
151  }
152  if (nh->hasParam("dashboard/get_firmware_service"))
153  {
154  nh->getParam("dashboard/get_firmware_service", getFirmwareService);
155  }
156  else
157  {
159  }
160  if (nh->hasParam("dashboard/get_sid_service"))
161  {
162  nh->getParam("dashboard/get_sid_service", getSidService);
163  }
164  else
165  {
167  }
168  if (nh->hasParam("dashboard/image_color_topic"))
169  {
170  nh->getParam("dashboard/image_color_topic", imageColorTopic);
171  }
172  else
173  {
175  }
176  if (nh->hasParam("dashboard/image_depth_topic"))
177  {
178  nh->getParam("dashboard/image_depth_topic", imageDepthTopic);
179  }
180  else
181  {
183  }
184  if (nh->hasParam("dashboard/toggle_kinect_service"))
185  {
186  nh->getParam("dashboard/toggle_kinect_service", toggleKinectService);
187  }
188  else
189  {
191  }
192  if (nh->hasParam("dashboard/toggle_motor_service"))
193  {
194  nh->getParam("dashboard/toggle_motor_service", toggleMotorService);
195  }
196  else
197  {
199  }
200  if (nh->hasParam("dashboard/toggle_us_service"))
201  {
202  nh->getParam("dashboard/toggle_us_service", toggleUSService);
203  }
204  else
205  {
207  }
208  if (nh->hasParam("dashboard/toggle_daq_service"))
209  {
210  nh->getParam("dashboard/toggle_daq_service", toggleDAQService);
211  }
212  else
213  {
215  }
216  if (nh->hasParam("dashboard/video_feed"))
217  {
218  nh->getParam("dashboard/video_feed", videoFeedMode);
219  }
220  else
221  {
223  }
224  if (nh->hasParam("dashboard/max_fwd_speed"))
225  {
226  nh->getParam("dashboard/max_fwd_speed", maxForwardSpeed);
227  }
228  else
229  {
231  }
232  if (nh->hasParam("dashboard/max_bwd_speed"))
233  {
234  nh->getParam("dashboard/max_bwd_speed", maxReverseSpeed);
235  }
236  else
237  {
239  }
240  if (nh->hasParam("dashboard/max_left_steer"))
241  {
242  nh->getParam("dashboard/max_left_steer", maxLeftSteering);
243  }
244  else
245  {
247  }
248  if (nh->hasParam("dashboard/max_right_steer"))
249  {
250  nh->getParam("dashboard/max_right_steer", maxRightSteering);
251  }
252  else
253  {
255  }
256  if (nh->hasParam("dashboard/steering_step"))
257  {
258  nh->getParam("dashboard/steering_step", steeringStep);
259  }
260  else
261  {
263  }
264  if (nh->hasParam("dashboard/speed_step"))
265  {
266  nh->getParam("dashboard/speed_step", speedStep);
267  }
268  else
269  {
271  }
272  if (nh->hasParam("dashboard/odom_topic"))
273  {
274  nh->getParam("dashboard/odom_topic", odomTopic);
275  }
276  else
277  {
279  }
280  leftSgn = boost::math::sign(maxLeftSteering);
281  rightSgn = boost::math::sign(maxRightSteering);
282  fwdSgn = boost::math::sign(maxForwardSpeed);
283  bwdSgn = boost::math::sign(maxReverseSpeed);
284 }
285 
287 {
288  ui->speedSlider->setMaximum(maxForwardSpeed);
289  ui->speedSlider->setMinimum(maxReverseSpeed);
290  ui->speedSlider->setSingleStep(speedStep);
291  ui->speedSlider->setSliderPosition(0);
292  ui->speedSlider->setValue(0);
293  ui->maxSpeed->setText(QString(std::to_string(maxForwardSpeed).c_str()));
294  ui->minSpeed->setText(QString(std::to_string(maxReverseSpeed).c_str()));
295  ui->steeringSlider->setMaximum(maxRightSteering);
296  ui->steeringSlider->setMinimum(maxLeftSteering);
297  ui->steeringSlider->setSingleStep(steeringStep);
298  ui->steeringSlider->setSliderPosition(0);
299  ui->steeringSlider->setValue(0);
300  ui->maxRightSteering->setText(
301  QString(std::to_string(maxRightSteering).c_str()));
302  ui->maxLeftSteering->setText(
303  QString(std::to_string(maxLeftSteering).c_str()));
304 }
305 
307 {
308  modeControl = nh->advertise<string_msg>(modeControlTopic, 10);
310  motorCommand = nh->advertise<int16_msg>(motorCommandTopic, 1);
311  imuSub = nh->subscribe<imu_msg>(
312  imuTopic, 10, boost::bind(&Dashboard::imuCallback, this, _1));
313  magneticSub = nh->subscribe<magnetic_msg>(
314  magneticTopic, 10, boost::bind(&Dashboard::magneticCallback, this, _1));
315  usrSub = nh->subscribe<range_msg>(
316  usrTopic, 10, boost::bind(&Dashboard::usrCallback, this, _1));
317  uslSub = nh->subscribe<range_msg>(
318  uslTopic, 10, boost::bind(&Dashboard::uslCallback, this, _1));
319  usfSub = nh->subscribe<range_msg>(
320  usfTopic, 10, boost::bind(&Dashboard::usfCallback, this, _1));
321  hallCntSub = nh->subscribe<uint8_msg>(
322  hallCntTopic, 10, boost::bind(&Dashboard::hallCntCallback, this, _1));
323  hallDtSub = nh->subscribe<float64_msg>(
324  hallDtTopic, 10, boost::bind(&Dashboard::hallDtCallback, this, _1));
325  hallDt8Sub = nh->subscribe<float64_msg>(
326  hallDt8Topic, 10, boost::bind(&Dashboard::hallDt8Callback, this, _1));
327  vdBatSub = nh->subscribe<battery_msg>(
328  vdBatTopic, 10, boost::bind(&Dashboard::driveBatteryCallback, this, _1));
329  vsBatSub = nh->subscribe<battery_msg>(
330  vsBatTopic, 10, boost::bind(&Dashboard::systemBatteryCallback, this, _1));
331  odomSub = nh->subscribe<odom_msg>(
332  odomTopic, 10, boost::bind(&Dashboard::odomCallback, this, _1));
333 }
334 
336 {
337  if (!ros::service::waitForService(getFirmwareService, 100))
338  ROS_WARN_STREAM("Get car id service not availible!");
339  pses_ucbridge::GetFirmwareVersion::Request firmwareRequest;
340  pses_ucbridge::GetFirmwareVersion::Response firmwareResponse;
341  ros::service::call(getFirmwareService, firmwareRequest, firmwareResponse);
342  if (firmwareResponse.answer_received)
343  {
344  ui->firmware_label->setText(QString(firmwareResponse.version.c_str()));
345  }
346  else
347  {
348  ui->firmware_label->setText(QString("N/A"));
349  }
350 }
351 
353 {
354  if (!ros::service::waitForService(getCarIdService, 100))
355  ROS_WARN_STREAM("Get car id service not availible!");
356  pses_ucbridge::GetControllerID::Request idRequest;
357  pses_ucbridge::GetControllerID::Response idResponse;
358  ros::service::call(getCarIdService, idRequest, idResponse);
359  if (idResponse.answer_received)
360  {
361  ui->id_label->setText(QString(std::to_string(idResponse.ID).c_str()));
362  }
363  else
364  {
365  ui->id_label->setText(QString("N/A"));
366  }
367 }
368 
370 {
371  if (!ros::service::waitForService(getSidService, 100))
372  ROS_WARN_STREAM("Get car sid service not availible!");
373  pses_ucbridge::GetSessionID::Request sidRequest;
374  pses_ucbridge::GetSessionID::Response sidResponse;
375  ros::service::call(getSidService, sidRequest, sidResponse);
376  if (sidResponse.answer_received)
377  {
378  ui->sid_label->setText(QString(std::to_string(sidResponse.SID).c_str()));
379  }
380  else
381  {
382  ui->sid_label->setText(QString("N/A"));
383  }
384 }
385 
387 {
388  QPixmap videoFeed(1280, 720);
389  ui->display_camera->setPixmap(videoFeed);
390  ui->camera_selection->addItem(QString(VIDEO_FEED_MODE_COLOR.c_str()),
391  QVariant());
392  ui->camera_selection->addItem(QString(VIDEO_FEED_MODE_DEPTH.c_str()),
393  QVariant());
394  ui->camera_selection->addItem(QString(DEFAULT_VIDEO_FEED_MODE.c_str()),
395  QVariant());
396 
397  if (videoFeedMode.compare(VIDEO_FEED_MODE_COLOR) == 0)
398  {
399  cameraSub = nh->subscribe<image_msg>(
400  imageColorTopic, 10, boost::bind(&Dashboard::cameraCallback, this, _1));
401  ui->camera_selection->setCurrentIndex(0);
402  }
403  else if (videoFeedMode.compare(VIDEO_FEED_MODE_DEPTH) == 0)
404  {
405  depthSub = nh->subscribe<image_msg>(
406  imageDepthTopic, 10, boost::bind(&Dashboard::depthCallback, this, _1));
407  ui->camera_selection->setCurrentIndex(1);
408  }
409  else if (videoFeedMode.compare(DEFAULT_VIDEO_FEED_MODE) == 0)
410  {
411  ui->camera_selection->setCurrentIndex(2);
412  }
413 }
414 
416 {
417  connect(ui->speedSlider, SIGNAL(valueChanged(int)), this,
418  SLOT(valueChangedSpeed(int)));
419  connect(ui->steeringSlider, SIGNAL(valueChanged(int)), this,
420  SLOT(valueChangedSteering(int)));
421  connect(ui->maxSpeed, SIGNAL(clicked()), this, SLOT(maxSpeedClicked()));
422  connect(ui->minSpeed, SIGNAL(clicked()), this, SLOT(minSpeedClicked()));
423  connect(ui->zeroSpeed, SIGNAL(clicked()), this, SLOT(zeroSpeedClicked()));
424  connect(ui->maxRightSteering, SIGNAL(clicked()), this,
425  SLOT(maxRightSteeringClicked()));
426  connect(ui->maxLeftSteering, SIGNAL(clicked()), this,
427  SLOT(maxLeftSteeringClicked()));
428  connect(ui->centerSteering, SIGNAL(clicked()), this,
429  SLOT(centerSteeringClicked()));
430  connect(ui->kinectToggle, SIGNAL(clicked()), this, SLOT(toggleKinect()));
431  connect(ui->usToggle, SIGNAL(clicked()), this, SLOT(toggleUS()));
432  connect(ui->motorToggle, SIGNAL(clicked()), this, SLOT(toggleMotor()));
433  connect(ui->daqToggle, SIGNAL(clicked()), this, SLOT(toggleDAQ()));
434  connect(ui->camera_selection, SIGNAL(currentIndexChanged(int)), this,
435  SLOT(cameraSelect(int)));
436  connect(ui->modeSelection, SIGNAL(currentIndexChanged(int)), this,
437  SLOT(modeSelect(int)));
438 }
439 
441 {
442  timer = new QTimer(this);
443  connect(timer, SIGNAL(timeout()), this, SLOT(pollNodeHandle()));
444  timer->start(100);
445 }
446 
447 void Dashboard::imuCallback(const imu_msg::ConstPtr& imu)
448 {
449  ui->sensor_ax->display(imu->linear_acceleration.x);
450  ui->sensor_ay->display(imu->linear_acceleration.y);
451  ui->sensor_az->display(imu->linear_acceleration.z);
452  ui->sensor_wx->display(imu->angular_velocity.x);
453  ui->sensor_wy->display(imu->angular_velocity.y);
454  ui->sensor_wz->display(imu->angular_velocity.z);
455 }
456 
457 void Dashboard::magneticCallback(const magnetic_msg::ConstPtr& magnetic)
458 {
459  ui->sensor_mx->display(magnetic->magnetic_field.x * 1000);
460  ui->sensor_my->display(magnetic->magnetic_field.y * 1000);
461  ui->sensor_mz->display(magnetic->magnetic_field.z * 1000);
462 }
463 
464 void Dashboard::usrCallback(const range_msg::ConstPtr& usr)
465 {
466  ui->sensor_usr->display(usr->range);
467 }
468 
469 void Dashboard::uslCallback(const range_msg::ConstPtr& usl)
470 {
471  ui->sensor_usl->display(usl->range);
472 }
473 
474 void Dashboard::usfCallback(const range_msg::ConstPtr& usf)
475 {
476  ui->sensor_usf->display(usf->range);
477 }
478 
479 void Dashboard::hallCntCallback(const uint8_msg::ConstPtr& hallCnt)
480 {
481  ui->sensor_hall_count->display(hallCnt->data);
482 }
483 
484 void Dashboard::hallDtCallback(const float64_msg::ConstPtr& hallDt)
485 {
486  ui->sensor_hall_dt->display(hallDt->data);
487 }
488 
489 void Dashboard::hallDt8Callback(const float64_msg::ConstPtr& hallDt8)
490 {
491  ui->sensor_hall_dtf->display(hallDt8->data);
492 }
493 
494 void Dashboard::driveBatteryCallback(const battery_msg::ConstPtr& vdBat)
495 {
496  ui->sensor_batt_motor->display(vdBat->voltage);
497 }
498 
499 void Dashboard::systemBatteryCallback(const battery_msg::ConstPtr& vsBat)
500 {
501  ui->sensor_batt_sys->display(vsBat->voltage);
502 }
503 
504 void Dashboard::cameraCallback(const image_msg::ConstPtr& img)
505 {
506  QImage image(&img->data[0], (int)img->width, (int)img->height,
507  QImage::Format_RGB888);
508  ui->display_camera->setPixmap(QPixmap::fromImage(image.rgbSwapped()));
509 }
510 
511 void Dashboard::depthCallback(const image_msg::ConstPtr& img)
512 {
513  cv_bridge::CvImagePtr cv_ptr;
514  try
515  {
516  cv_ptr = cv_bridge::toCvCopy(*img, img->encoding);
517  }
518  catch (cv_bridge::Exception& e)
519  {
520  ROS_ERROR("cv_bridge exception: %s", e.what());
521  }
522  cv::Mat im16 = cv_ptr->image;
523  double min, max;
524  cv::minMaxIdx(im16, &min, &max);
525  cv::Mat im8;
526  im16.convertTo(im8, CV_8UC1, 255 / (max - min), -min);
527  QImage image(im8.data, im8.cols, im8.rows, static_cast<int>(im8.step),
528  QImage::Format_Indexed8);
529  ui->display_camera->setPixmap(QPixmap::fromImage(image));
530 }
531 
532 void Dashboard::odomCallback(const odom_msg::ConstPtr& odom)
533 {
534  ui->odom_vx->display(odom->twist.twist.linear.x);
535  ui->odom_vy->display(odom->twist.twist.linear.y);
536  ui->odom_vz->display(odom->twist.twist.linear.z);
537  ui->odom_wx->display(odom->twist.twist.angular.x);
538  ui->odom_wy->display(odom->twist.twist.angular.y);
539  ui->odom_wz->display(odom->twist.twist.angular.z);
540  ui->odom_quat_x->display(odom->pose.pose.orientation.x);
541  ui->odom_quat_y->display(odom->pose.pose.orientation.y);
542  ui->odom_quat_z->display(odom->pose.pose.orientation.z);
543  ui->odom_quat_w->display(odom->pose.pose.orientation.w);
544  ui->odom_x->display(odom->pose.pose.position.x);
545  ui->odom_y->display(odom->pose.pose.position.y);
546  ui->odom_z->display(odom->pose.pose.position.z);
547  double roll, pitch, yaw;
548  tf::Quaternion q;
549  tf::quaternionMsgToTF(odom->pose.pose.orientation, q);
550  tf::Matrix3x3 mat(q);
551  mat.getEulerYPR(yaw, pitch, roll);
552  ui->odom_roll->display(roll);
553  ui->odom_pitch->display(pitch);
554  ui->odom_yaw->display(yaw);
555  ui->odom_speed->display(
556  std::sqrt(odom->twist.twist.linear.x * odom->twist.twist.linear.x +
557  odom->twist.twist.linear.y * odom->twist.twist.linear.y +
558  odom->twist.twist.linear.z * odom->twist.twist.linear.z));
559  double dx = odom->pose.pose.position.x - x;
560  double dy = odom->pose.pose.position.y - y;
561  double dz = odom->pose.pose.position.z - z;
562  distanceTravelled += std::sqrt(dx * dx + dy * dy + dz * dz);
563  x = odom->pose.pose.position.x;
564  y = odom->pose.pose.position.y;
565  z = odom->pose.pose.position.z;
566  ui->odom_distance->display(distanceTravelled);
567 }
568 
569 void Dashboard::keyPressEvent(QKeyEvent* event)
570 {
571  int speed = motorMessage.data; // cmd.motor_level;
572  int steering = steeringMessage.data; // cmd.steering_level;
573  int speedSgn;
574  int steeringSgn;
575 
576  switch (event->key())
577  {
578  case Qt::Key_W:
579  {
580  speed = speed + fwdSgn * speedStep;
581  speedSgn = boost::math::sign(speed);
582  if (std::abs(speed) <= std::abs(maxForwardSpeed) || speedSgn != fwdSgn)
583  {
584  motorMessage.data = speed;
585  motorCommand.publish(motorMessage);
586  }
587  break;
588  }
589 
590  case Qt::Key_S:
591  {
592  speed = speed + bwdSgn * speedStep;
593  speedSgn = boost::math::sign(speed);
594  if (std::abs(speed) <= std::abs(maxReverseSpeed) || speedSgn != bwdSgn)
595  {
596  motorMessage.data = speed;
597  motorCommand.publish(motorMessage);
598  }
599  break;
600  }
601 
602  case Qt::Key_A:
603  {
604  steering = steering + leftSgn * steeringStep;
605  steeringSgn = boost::math::sign(steering);
606  if (std::abs(steering) <= std::abs(maxLeftSteering) ||
607  steeringSgn != leftSgn)
608  {
609  steeringMessage.data = steering;
611  }
612  break;
613  }
614 
615  case Qt::Key_D:
616  {
617  steering = steering + rightSgn * steeringStep;
618  steeringSgn = boost::math::sign(steering);
619  if (std::abs(steering) <= std::abs(maxRightSteering) ||
620  steeringSgn != rightSgn)
621  {
622  steeringMessage.data = steering;
624  }
625  break;
626  }
627 
628  case Qt::Key_Space:
629  {
630  motorMessage.data = 0;
631  motorCommand.publish(motorMessage);
632  break;
633  }
634  }
635  ui->speedSlider->blockSignals(true);
636  ui->steeringSlider->blockSignals(true);
637  ui->speedSlider->setValue(motorMessage.data);
638  ui->steeringSlider->setValue(steeringMessage.data);
639  ui->speedSlider->blockSignals(false);
640  ui->steeringSlider->blockSignals(false);
641  ros::spinOnce();
642 }
643 
645 {
646  ros::spinOnce();
647  timer->start(100);
648 }
649 
651 {
652  pses_ucbridge::ToggleKinect::Request kinectRequest;
653  kinectRequest.kinect_on = ui->kinectToggle->isChecked();
654  pses_ucbridge::ToggleKinect::Response kinectResponse;
655  if (!ros::service::waitForService(toggleKinectService, 100))
656  ROS_WARN_STREAM("Toggle kinect service not availible!");
657  ros::service::call(toggleKinectService, kinectRequest, kinectResponse);
658  if (!kinectResponse.was_set)
659  ui->kinectToggle->setChecked(false);
660 }
661 
663 {
664  pses_ucbridge::ToggleUS::Request usRequest;
665  usRequest.us_on = ui->usToggle->isChecked();
666  pses_ucbridge::ToggleUS::Response usResponse;
667  if (!ros::service::waitForService(toggleUSService, 100))
668  ROS_WARN_STREAM("Toggle us service not availible!");
669  ros::service::call(toggleUSService, usRequest, usResponse);
670  if (!usResponse.was_set)
671  ui->usToggle->setChecked(false);
672 }
673 
675 {
676  pses_ucbridge::ToggleMotor::Request motorRequest;
677  motorRequest.motor_on = ui->motorToggle->isChecked();
678  pses_ucbridge::ToggleMotor::Response motorResponse;
679  if (!ros::service::waitForService(toggleMotorService, 100))
680  ROS_WARN_STREAM("Toggle motor service not availible!");
681  ros::service::call(toggleMotorService, motorRequest, motorResponse);
682  if (!motorResponse.was_set)
683  ui->motorToggle->setChecked(false);
684 }
685 
687 {
688  pses_ucbridge::ToggleDAQ::Request daqRequest;
689  daqRequest.DAQ_on = ui->daqToggle->isChecked();
690  pses_ucbridge::ToggleDAQ::Response daqResponse;
691  if (!ros::service::waitForService(toggleDAQService, 100))
692  ROS_WARN_STREAM("Toggle daq service not availible!");
693  ros::service::call(toggleDAQService, daqRequest, daqResponse);
694  if (!daqResponse.was_set)
695  ui->daqToggle->setChecked(false);
696 }
697 
698 void Dashboard::modeSelect(int index)
699 {
700  mode.data = ui->modeSelection->itemText(index).toStdString();
701  modeControl.publish(mode);
702  ros::spinOnce();
703 }
704 
705 void Dashboard::cameraSelect(int index)
706 {
707  if (index == 0)
708  {
709  depthSub.shutdown();
710  cameraSub = nh->subscribe<image_msg>(
711  imageColorTopic, 10, boost::bind(&Dashboard::cameraCallback, this, _1));
712  }
713  else if (index == 1)
714  {
715  cameraSub.shutdown();
716  depthSub = nh->subscribe<image_msg>(
717  imageDepthTopic, 10, boost::bind(&Dashboard::depthCallback, this, _1));
718  }
719  else
720  {
721  depthSub.shutdown();
722  cameraSub.shutdown();
723  }
724 }
725 
727 {
728  motorMessage.data = value;
729  motorCommand.publish(motorMessage);
730  ros::spinOnce();
731 }
732 
734 {
735  steeringMessage.data = value;
737  ros::spinOnce();
738 }
739 
741 {
743  motorCommand.publish(motorMessage);
744  ui->speedSlider->blockSignals(true);
745  ui->speedSlider->setValue(maxForwardSpeed);
746  ui->speedSlider->blockSignals(false);
747  ros::spinOnce();
748 }
749 
751 {
753  motorCommand.publish(motorMessage);
754  ui->speedSlider->blockSignals(true);
755  ui->speedSlider->setValue(maxReverseSpeed);
756  ui->speedSlider->blockSignals(false);
757  ros::spinOnce();
758 }
759 
761 {
762  motorMessage.data = 0;
763  motorCommand.publish(motorMessage);
764  ui->speedSlider->blockSignals(true);
765  ui->speedSlider->setValue(0);
766  ui->speedSlider->blockSignals(false);
767  ros::spinOnce();
768 }
769 
771 {
774  ui->steeringSlider->blockSignals(true);
775  ui->steeringSlider->setValue(maxLeftSteering);
776  ui->steeringSlider->blockSignals(false);
777  ros::spinOnce();
778 }
779 
781 {
784  ui->steeringSlider->blockSignals(true);
785  ui->steeringSlider->setValue(maxRightSteering);
786  ui->steeringSlider->blockSignals(false);
787  ros::spinOnce();
788 }
789 
791 {
792  steeringMessage.data = 0;
794  ui->steeringSlider->blockSignals(true);
795  ui->steeringSlider->setValue(0);
796  ui->steeringSlider->blockSignals(false);
797  ros::spinOnce();
798 }
int maxReverseSpeed
Definition: dashboard.h:383
static const std::string DEFAULT_HALLDT_TOPIC
Definition: dashboard.h:130
void modeSelect(int index)
This function gets called whenever a mode has been selected.
Definition: dashboard.cpp:698
virtual ~Dashboard()
Dashboard default destructor.
Definition: dashboard.cpp:36
std::string imuTopic
Definition: dashboard.h:377
std::string motorCommandTopic
Definition: dashboard.h:377
std::string hallDt8Topic
Definition: dashboard.h:377
void keyPressEvent(QKeyEvent *event)
Callback function in case of a key event.
Definition: dashboard.cpp:569
nav_msgs::Odometry odom_msg
shortcut for Odometry messages
Definition: dashboard.h:100
static const std::string DEFAULT_GET_SID_SERVICE
Definition: dashboard.h:150
void toggleKinect()
This function gets called whenever the kinect toggle button has been pressed.
Definition: dashboard.cpp:650
std::string getFirmwareService
Definition: dashboard.h:377
std::string uslTopic
Definition: dashboard.h:377
void centerSteeringClicked()
This function gets called whenever the center steering button has been clicked.
Definition: dashboard.cpp:790
static const std::string DEFAULT_GET_FIRMWARE_SERVICE
Definition: dashboard.h:143
void maxLeftSteeringClicked()
This function gets called whenever the max left steering button has been clicked. ...
Definition: dashboard.cpp:770
void valueChangedSteering(int value)
This function gets called whenever the steering slider changed.
Definition: dashboard.cpp:733
static const std::string DEFAULT_GET_CARID_SERVICE
Definition: dashboard.h:147
void usrCallback(const range_msg::ConstPtr &usr)
This function gets called whenever a message has been published to the right ultra sonic range topic...
Definition: dashboard.cpp:464
void configureVideoFeed()
Set up video feed based on launch parameters.
Definition: dashboard.cpp:386
static const std::string DEFAULT_MAGNETIC_TOPIC
Definition: dashboard.h:114
int bwdSgn
Definition: dashboard.h:385
std::string hallDtTopic
Definition: dashboard.h:377
void toggleMotor()
This function gets called whenever the motor toggle button has been pressed.
Definition: dashboard.cpp:674
sensor_msgs::BatteryState battery_msg
shortcut for battery messages
Definition: dashboard.h:70
static const std::string DEFAULT_MOTOR_COMMAND_TOPIC
Definition: dashboard.h:108
ros::Subscriber hallDt8Sub
Definition: dashboard.h:397
static const int DEFAULT_MAX_BWD_SPEED
Definition: dashboard.h:174
sensor_msgs::Range range_msg
shortcut for Range messages
Definition: dashboard.h:80
static const std::string DEFAULT_USF_TOPIC
Definition: dashboard.h:121
void odomCallback(const odom_msg::ConstPtr &odom)
This function gets called whenever a message has been published to the odometry topic.
Definition: dashboard.cpp:532
void toggleUS()
This function gets called whenever the us toggle button has been pressed.
Definition: dashboard.cpp:662
static const std::string DEFAULT_TOGGLE_DAQ_SERVICE
Definition: dashboard.h:168
int maxForwardSpeed
Definition: dashboard.h:383
static const std::string DEFAULT_ODOM_TOPIC
Definition: dashboard.h:141
void minSpeedClicked()
This function gets called whenever the min speed button has been clicked.
Definition: dashboard.cpp:750
void toggleDAQ()
This function gets called whenever the daq toggle button has been pressed.
Definition: dashboard.cpp:686
static const std::string DEFAULT_VSBAT_TOPIC
Definition: dashboard.h:138
This namespace contains the autogenerated ui header.
void hallCntCallback(const uint8_msg::ConstPtr &hallCnt)
This function gets called whenever a message has been published to the hall count topic...
Definition: dashboard.cpp:479
void zeroSpeedClicked()
This function gets called whenever the zero speed button has been clicked.
Definition: dashboard.cpp:760
static const int DEFAULT_MAX_RIGHT_STEER
Definition: dashboard.h:182
static const std::string VIDEO_FEED_MODE_DEPTH
Definition: dashboard.h:189
static const std::string DEFAULT_USR_TOPIC
Definition: dashboard.h:118
void pollNodeHandle()
This function gets called whenever the polling timer runs out.
Definition: dashboard.cpp:644
void callGetCarIdServide()
Get the id from the ucboard.
Definition: dashboard.cpp:352
void usfCallback(const range_msg::ConstPtr &usf)
This function gets called whenever a message has been published to the front ultra sonic range topic...
Definition: dashboard.cpp:474
std::string usrTopic
Definition: dashboard.h:377
std::string usfTopic
Definition: dashboard.h:377
QTimer * timer
Definition: dashboard.h:400
void fetchStartupParameters()
Get all available launch parameters.
Definition: dashboard.cpp:38
std::string getSidService
Definition: dashboard.h:377
int maxRightSteering
Definition: dashboard.h:383
int maxLeftSteering
Definition: dashboard.h:383
ros::Subscriber usfSub
Definition: dashboard.h:397
ros::Publisher motorCommand
Definition: dashboard.h:395
std::string vdBatTopic
Definition: dashboard.h:377
std::string imageColorTopic
Definition: dashboard.h:377
Dashboard(ros::NodeHandle *nh, QWidget *parent=0)
Dashboard constructor.
Definition: dashboard.cpp:9
std::string modeControlTopic
Definition: dashboard.h:377
ros::Subscriber depthSub
Definition: dashboard.h:397
ros::Subscriber vsBatSub
Definition: dashboard.h:397
static const std::string DEFAULT_MODE_CONTROL_TOPIC
Definition: dashboard.h:102
static const std::string DEFAULT_IMAGE_DEPTH_TOPIC
Definition: dashboard.h:156
ros::Subscriber usrSub
Definition: dashboard.h:397
ros::NodeHandle * nh
Definition: dashboard.h:376
std::string steeringCommandTopic
Definition: dashboard.h:377
std::string toggleDAQService
Definition: dashboard.h:377
static const std::string DEFAULT_TOGGLE_MOTOR_SERVICE
Definition: dashboard.h:162
void connectGuiSignals()
Register gui relevant callbacks e.g. buttons, silders etc.
Definition: dashboard.cpp:415
std_msgs::String string_msg
shortcut for standard String messages
Definition: dashboard.h:55
sensor_msgs::Image image_msg
shortcut for Image messages
Definition: dashboard.h:60
void hallDtCallback(const float64_msg::ConstPtr &hallDt)
This function gets called whenever a message has been published to the hall dt topic.
Definition: dashboard.cpp:484
void registerRosTopics()
Register all published/subscribed ros topics.
Definition: dashboard.cpp:306
static const int DEFAULT_SPEED_STEP
Definition: dashboard.h:176
std::string imageDepthTopic
Definition: dashboard.h:377
ros::Subscriber imuSub
Definition: dashboard.h:397
void driveBatteryCallback(const battery_msg::ConstPtr &vdBat)
This function gets called whenever a message has been published to the drive battery topic...
Definition: dashboard.cpp:494
ros::Subscriber vdBatSub
Definition: dashboard.h:397
std::string toggleMotorService
Definition: dashboard.h:377
int16_msg motorMessage
Definition: dashboard.h:388
std::string magneticTopic
Definition: dashboard.h:377
int fwdSgn
Definition: dashboard.h:385
Ui::Dashboard * ui
Definition: dashboard.h:375
std_msgs::Float64 float64_msg
shortcut for double messages
Definition: dashboard.h:90
ros::Publisher modeControl
Definition: dashboard.h:395
void hallDt8Callback(const float64_msg::ConstPtr &hallDt8)
This function gets called whenever a message has been published to the hall dt 8 topic.
Definition: dashboard.cpp:489
ros::Subscriber odomSub
Definition: dashboard.h:397
static const std::string DEFAULT_IMU_TOPIC
Definition: dashboard.h:111
static const std::string DEFAULT_VIDEO_FEED_MODE
Definition: dashboard.h:170
void callGetFirmwareServide()
Get the firmware version from the ucboard.
Definition: dashboard.cpp:335
std_msgs::Int16 int16_msg
shortcut for int16 messages
Definition: dashboard.h:85
std::string vsBatTopic
Definition: dashboard.h:377
void depthCallback(const image_msg::ConstPtr &img)
This function gets called whenever a message has been published to the depth image topic...
Definition: dashboard.cpp:511
void cameraSelect(int index)
This function gets called whenever the camera mode changed.
Definition: dashboard.cpp:705
sensor_msgs::MagneticField magnetic_msg
shortcut for Magnetic Field messages
Definition: dashboard.h:75
static const std::string DEFAULT_HALLCNT_TOPIC
Definition: dashboard.h:127
std::string getCarIdService
Definition: dashboard.h:377
void cameraCallback(const image_msg::ConstPtr &img)
This function gets called whenever a message has been published to the color image topic...
Definition: dashboard.cpp:504
The Dashboard class provides functionality for the autogenerated ui header.
Definition: dashboard.h:218
double y
Definition: dashboard.h:393
static const std::string DEFAULT_HALLDT8_TOPIC
Definition: dashboard.h:133
void systemBatteryCallback(const battery_msg::ConstPtr &vsBat)
This function gets called whenever a message has been published to the system battery topic...
Definition: dashboard.cpp:499
void reconfigureSpeedSlider()
Reconfigure the gui (e.g. speed slider) according to launch paramters.
Definition: dashboard.cpp:286
ros::Subscriber hallDtSub
Definition: dashboard.h:397
int rightSgn
Definition: dashboard.h:385
static const std::string DEFAULT_USL_TOPIC
Definition: dashboard.h:124
void uslCallback(const range_msg::ConstPtr &usl)
This function gets called whenever a message has been published to the left ultra sonic range topic...
Definition: dashboard.cpp:469
ros::Publisher steeringCommand
Definition: dashboard.h:395
std::string odomTopic
Definition: dashboard.h:377
static const std::string VIDEO_FEED_MODE_COLOR
Definition: dashboard.h:187
static const std::string DEFAULT_VDBAT_TOPIC
Definition: dashboard.h:136
ros::Subscriber hallCntSub
Definition: dashboard.h:397
double z
Definition: dashboard.h:393
static const std::string DEFAULT_TOGGLE_US_SERVICE
Definition: dashboard.h:165
ros::Subscriber cameraSub
Definition: dashboard.h:397
static const std::string DEFAULT_TOGGLE_KINECT_SERVICE
Definition: dashboard.h:159
double distanceTravelled
Definition: dashboard.h:391
std::string toggleKinectService
Definition: dashboard.h:377
static const std::string DEFAULT_IMAGE_COLOR_TOPIC
Definition: dashboard.h:153
int speedStep
Definition: dashboard.h:383
static const int DEFAULT_STEER_STEP
Definition: dashboard.h:184
double x
Definition: dashboard.h:393
static const std::string DEFAULT_STEERING_COMMAND_TOPIC
Definition: dashboard.h:105
std_msgs::UInt8 uint8_msg
shortcut for uint8 messages
Definition: dashboard.h:95
void valueChangedSpeed(int value)
This function gets called whenever the speed slider changed.
Definition: dashboard.cpp:726
static const int DEFAULT_MAX_LEFT_STEER
Definition: dashboard.h:180
ros::Subscriber magneticSub
Definition: dashboard.h:397
void magneticCallback(const magnetic_msg::ConstPtr &magnetic)
This function gets called whenever a message has been published to the magnetic field topic...
Definition: dashboard.cpp:457
std::string hallCntTopic
Definition: dashboard.h:377
int leftSgn
Definition: dashboard.h:385
void initTopicPollingTimer()
Ininit ros topic polling timer.
Definition: dashboard.cpp:440
Header file for the Dashboard class.
std::string videoFeedMode
Definition: dashboard.h:387
void callGetSidServide()
Get the session id from the ucboard.
Definition: dashboard.cpp:369
std::string toggleUSService
Definition: dashboard.h:377
void maxRightSteeringClicked()
This function gets called whenever the max right steering button has been clicked.
Definition: dashboard.cpp:780
static const int DEFAULT_MAX_FWD_SPEED
Definition: dashboard.h:172
void maxSpeedClicked()
This function gets called whenever the max speed button has been clicked.
Definition: dashboard.cpp:740
ros::Subscriber uslSub
Definition: dashboard.h:397
sensor_msgs::Imu imu_msg
shortcut for IMU messages
Definition: dashboard.h:65
string_msg mode
Definition: dashboard.h:390
int16_msg steeringMessage
Definition: dashboard.h:389
void imuCallback(const imu_msg::ConstPtr &imu)
This function gets called whenever a message has been published to the imu topic. ...
Definition: dashboard.cpp:447
int steeringStep
Definition: dashboard.h:383


pses_dashboard
Author(s): Sebastian Ehmes
autogenerated on Sat Oct 28 2017 14:12:28