10 : QMainWindow(parent), ui(new
Ui::
Dashboard), nh(nh)
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());
40 if (
nh->hasParam(
"dashboard/mode_control_topic"))
48 if (
nh->hasParam(
"dashboard/steering_command_topic"))
56 if (
nh->hasParam(
"dashboard/motor_command_topic"))
64 if (
nh->hasParam(
"dashboard/imu_topic"))
72 if (
nh->hasParam(
"dashboard/magnetic_topic"))
80 if (
nh->hasParam(
"dashboard/usr_topic"))
88 if (
nh->hasParam(
"dashboard/usl_topic"))
96 if (
nh->hasParam(
"dashboard/usf_topic"))
104 if (
nh->hasParam(
"dashboard/hallcnt_topic"))
112 if (
nh->hasParam(
"dashboard/halldt_topic"))
120 if (
nh->hasParam(
"dashboard/halldt8_topic"))
128 if (
nh->hasParam(
"dashboard/sys_bat_topic"))
136 if (
nh->hasParam(
"dashboard/drv_bat_topic"))
144 if (
nh->hasParam(
"dashboard/get_car_id_service"))
152 if (
nh->hasParam(
"dashboard/get_firmware_service"))
160 if (
nh->hasParam(
"dashboard/get_sid_service"))
168 if (
nh->hasParam(
"dashboard/image_color_topic"))
176 if (
nh->hasParam(
"dashboard/image_depth_topic"))
184 if (
nh->hasParam(
"dashboard/toggle_kinect_service"))
192 if (
nh->hasParam(
"dashboard/toggle_motor_service"))
200 if (
nh->hasParam(
"dashboard/toggle_us_service"))
208 if (
nh->hasParam(
"dashboard/toggle_daq_service"))
216 if (
nh->hasParam(
"dashboard/video_feed"))
224 if (
nh->hasParam(
"dashboard/max_fwd_speed"))
232 if (
nh->hasParam(
"dashboard/max_bwd_speed"))
240 if (
nh->hasParam(
"dashboard/max_left_steer"))
248 if (
nh->hasParam(
"dashboard/max_right_steer"))
256 if (
nh->hasParam(
"dashboard/steering_step"))
264 if (
nh->hasParam(
"dashboard/speed_step"))
272 if (
nh->hasParam(
"dashboard/odom_topic"))
291 ui->speedSlider->setSliderPosition(0);
292 ui->speedSlider->setValue(0);
298 ui->steeringSlider->setSliderPosition(0);
299 ui->steeringSlider->setValue(0);
300 ui->maxRightSteering->setText(
302 ui->maxLeftSteering->setText(
338 ROS_WARN_STREAM(
"Get car id service not availible!");
339 pses_ucbridge::GetFirmwareVersion::Request firmwareRequest;
340 pses_ucbridge::GetFirmwareVersion::Response firmwareResponse;
342 if (firmwareResponse.answer_received)
344 ui->firmware_label->setText(QString(firmwareResponse.version.c_str()));
348 ui->firmware_label->setText(QString(
"N/A"));
355 ROS_WARN_STREAM(
"Get car id service not availible!");
356 pses_ucbridge::GetControllerID::Request idRequest;
357 pses_ucbridge::GetControllerID::Response idResponse;
359 if (idResponse.answer_received)
361 ui->id_label->setText(QString(std::to_string(idResponse.ID).c_str()));
365 ui->id_label->setText(QString(
"N/A"));
372 ROS_WARN_STREAM(
"Get car sid service not availible!");
373 pses_ucbridge::GetSessionID::Request sidRequest;
374 pses_ucbridge::GetSessionID::Response sidResponse;
376 if (sidResponse.answer_received)
378 ui->sid_label->setText(QString(std::to_string(sidResponse.SID).c_str()));
382 ui->sid_label->setText(QString(
"N/A"));
388 QPixmap videoFeed(1280, 720);
389 ui->display_camera->setPixmap(videoFeed);
401 ui->camera_selection->setCurrentIndex(0);
407 ui->camera_selection->setCurrentIndex(1);
411 ui->camera_selection->setCurrentIndex(2);
417 connect(
ui->speedSlider, SIGNAL(valueChanged(
int)),
this,
419 connect(
ui->steeringSlider, SIGNAL(valueChanged(
int)),
this,
424 connect(
ui->maxRightSteering, SIGNAL(clicked()),
this,
426 connect(
ui->maxLeftSteering, SIGNAL(clicked()),
this,
428 connect(
ui->centerSteering, SIGNAL(clicked()),
this,
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,
436 connect(
ui->modeSelection, SIGNAL(currentIndexChanged(
int)),
this,
442 timer =
new QTimer(
this);
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);
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);
466 ui->sensor_usr->display(usr->range);
471 ui->sensor_usl->display(usl->range);
476 ui->sensor_usf->display(usf->range);
481 ui->sensor_hall_count->display(hallCnt->data);
486 ui->sensor_hall_dt->display(hallDt->data);
491 ui->sensor_hall_dtf->display(hallDt8->data);
496 ui->sensor_batt_motor->display(vdBat->voltage);
501 ui->sensor_batt_sys->display(vsBat->voltage);
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()));
513 cv_bridge::CvImagePtr cv_ptr;
516 cv_ptr = cv_bridge::toCvCopy(*img, img->encoding);
518 catch (cv_bridge::Exception& e)
520 ROS_ERROR(
"cv_bridge exception: %s", e.what());
522 cv::Mat im16 = cv_ptr->image;
524 cv::minMaxIdx(im16, &min, &max);
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));
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;
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;
563 x = odom->pose.pose.position.x;
564 y = odom->pose.pose.position.y;
565 z = odom->pose.pose.position.z;
576 switch (event->key())
581 speedSgn = boost::math::sign(speed);
593 speedSgn = boost::math::sign(speed);
605 steeringSgn = boost::math::sign(steering);
618 steeringSgn = boost::math::sign(steering);
635 ui->speedSlider->blockSignals(
true);
636 ui->steeringSlider->blockSignals(
true);
639 ui->speedSlider->blockSignals(
false);
640 ui->steeringSlider->blockSignals(
false);
652 pses_ucbridge::ToggleKinect::Request kinectRequest;
653 kinectRequest.kinect_on =
ui->kinectToggle->isChecked();
654 pses_ucbridge::ToggleKinect::Response kinectResponse;
656 ROS_WARN_STREAM(
"Toggle kinect service not availible!");
658 if (!kinectResponse.was_set)
659 ui->kinectToggle->setChecked(
false);
664 pses_ucbridge::ToggleUS::Request usRequest;
665 usRequest.us_on =
ui->usToggle->isChecked();
666 pses_ucbridge::ToggleUS::Response usResponse;
668 ROS_WARN_STREAM(
"Toggle us service not availible!");
670 if (!usResponse.was_set)
671 ui->usToggle->setChecked(
false);
676 pses_ucbridge::ToggleMotor::Request motorRequest;
677 motorRequest.motor_on =
ui->motorToggle->isChecked();
678 pses_ucbridge::ToggleMotor::Response motorResponse;
680 ROS_WARN_STREAM(
"Toggle motor service not availible!");
682 if (!motorResponse.was_set)
683 ui->motorToggle->setChecked(
false);
688 pses_ucbridge::ToggleDAQ::Request daqRequest;
689 daqRequest.DAQ_on =
ui->daqToggle->isChecked();
690 pses_ucbridge::ToggleDAQ::Response daqResponse;
692 ROS_WARN_STREAM(
"Toggle daq service not availible!");
694 if (!daqResponse.was_set)
695 ui->daqToggle->setChecked(
false);
700 mode.data =
ui->modeSelection->itemText(index).toStdString();
744 ui->speedSlider->blockSignals(
true);
746 ui->speedSlider->blockSignals(
false);
754 ui->speedSlider->blockSignals(
true);
756 ui->speedSlider->blockSignals(
false);
764 ui->speedSlider->blockSignals(
true);
765 ui->speedSlider->setValue(0);
766 ui->speedSlider->blockSignals(
false);
774 ui->steeringSlider->blockSignals(
true);
776 ui->steeringSlider->blockSignals(
false);
784 ui->steeringSlider->blockSignals(
true);
786 ui->steeringSlider->blockSignals(
false);
794 ui->steeringSlider->blockSignals(
true);
795 ui->steeringSlider->setValue(0);
796 ui->steeringSlider->blockSignals(
false);
static const std::string DEFAULT_HALLDT_TOPIC
void modeSelect(int index)
This function gets called whenever a mode has been selected.
virtual ~Dashboard()
Dashboard default destructor.
std::string motorCommandTopic
void keyPressEvent(QKeyEvent *event)
Callback function in case of a key event.
nav_msgs::Odometry odom_msg
shortcut for Odometry messages
static const std::string DEFAULT_GET_SID_SERVICE
void toggleKinect()
This function gets called whenever the kinect toggle button has been pressed.
std::string getFirmwareService
void centerSteeringClicked()
This function gets called whenever the center steering button has been clicked.
static const std::string DEFAULT_GET_FIRMWARE_SERVICE
void maxLeftSteeringClicked()
This function gets called whenever the max left steering button has been clicked. ...
void valueChangedSteering(int value)
This function gets called whenever the steering slider changed.
static const std::string DEFAULT_GET_CARID_SERVICE
void usrCallback(const range_msg::ConstPtr &usr)
This function gets called whenever a message has been published to the right ultra sonic range topic...
void configureVideoFeed()
Set up video feed based on launch parameters.
static const std::string DEFAULT_MAGNETIC_TOPIC
void toggleMotor()
This function gets called whenever the motor toggle button has been pressed.
sensor_msgs::BatteryState battery_msg
shortcut for battery messages
static const std::string DEFAULT_MOTOR_COMMAND_TOPIC
ros::Subscriber hallDt8Sub
static const int DEFAULT_MAX_BWD_SPEED
sensor_msgs::Range range_msg
shortcut for Range messages
static const std::string DEFAULT_USF_TOPIC
void odomCallback(const odom_msg::ConstPtr &odom)
This function gets called whenever a message has been published to the odometry topic.
void toggleUS()
This function gets called whenever the us toggle button has been pressed.
static const std::string DEFAULT_TOGGLE_DAQ_SERVICE
static const std::string DEFAULT_ODOM_TOPIC
void minSpeedClicked()
This function gets called whenever the min speed button has been clicked.
void toggleDAQ()
This function gets called whenever the daq toggle button has been pressed.
static const std::string DEFAULT_VSBAT_TOPIC
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...
void zeroSpeedClicked()
This function gets called whenever the zero speed button has been clicked.
static const int DEFAULT_MAX_RIGHT_STEER
static const std::string VIDEO_FEED_MODE_DEPTH
static const std::string DEFAULT_USR_TOPIC
void pollNodeHandle()
This function gets called whenever the polling timer runs out.
void callGetCarIdServide()
Get the id from the ucboard.
void usfCallback(const range_msg::ConstPtr &usf)
This function gets called whenever a message has been published to the front ultra sonic range topic...
void fetchStartupParameters()
Get all available launch parameters.
std::string getSidService
ros::Publisher motorCommand
std::string imageColorTopic
Dashboard(ros::NodeHandle *nh, QWidget *parent=0)
Dashboard constructor.
std::string modeControlTopic
static const std::string DEFAULT_MODE_CONTROL_TOPIC
static const std::string DEFAULT_IMAGE_DEPTH_TOPIC
std::string steeringCommandTopic
std::string toggleDAQService
static const std::string DEFAULT_TOGGLE_MOTOR_SERVICE
void connectGuiSignals()
Register gui relevant callbacks e.g. buttons, silders etc.
std_msgs::String string_msg
shortcut for standard String messages
sensor_msgs::Image image_msg
shortcut for Image messages
void hallDtCallback(const float64_msg::ConstPtr &hallDt)
This function gets called whenever a message has been published to the hall dt topic.
void registerRosTopics()
Register all published/subscribed ros topics.
static const int DEFAULT_SPEED_STEP
std::string imageDepthTopic
void driveBatteryCallback(const battery_msg::ConstPtr &vdBat)
This function gets called whenever a message has been published to the drive battery topic...
std::string toggleMotorService
std::string magneticTopic
std_msgs::Float64 float64_msg
shortcut for double messages
ros::Publisher modeControl
void hallDt8Callback(const float64_msg::ConstPtr &hallDt8)
This function gets called whenever a message has been published to the hall dt 8 topic.
static const std::string DEFAULT_IMU_TOPIC
static const std::string DEFAULT_VIDEO_FEED_MODE
void callGetFirmwareServide()
Get the firmware version from the ucboard.
std_msgs::Int16 int16_msg
shortcut for int16 messages
void depthCallback(const image_msg::ConstPtr &img)
This function gets called whenever a message has been published to the depth image topic...
void cameraSelect(int index)
This function gets called whenever the camera mode changed.
sensor_msgs::MagneticField magnetic_msg
shortcut for Magnetic Field messages
static const std::string DEFAULT_HALLCNT_TOPIC
std::string getCarIdService
void cameraCallback(const image_msg::ConstPtr &img)
This function gets called whenever a message has been published to the color image topic...
The Dashboard class provides functionality for the autogenerated ui header.
static const std::string DEFAULT_HALLDT8_TOPIC
void systemBatteryCallback(const battery_msg::ConstPtr &vsBat)
This function gets called whenever a message has been published to the system battery topic...
void reconfigureSpeedSlider()
Reconfigure the gui (e.g. speed slider) according to launch paramters.
ros::Subscriber hallDtSub
static const std::string DEFAULT_USL_TOPIC
void uslCallback(const range_msg::ConstPtr &usl)
This function gets called whenever a message has been published to the left ultra sonic range topic...
ros::Publisher steeringCommand
static const std::string VIDEO_FEED_MODE_COLOR
static const std::string DEFAULT_VDBAT_TOPIC
ros::Subscriber hallCntSub
static const std::string DEFAULT_TOGGLE_US_SERVICE
ros::Subscriber cameraSub
static const std::string DEFAULT_TOGGLE_KINECT_SERVICE
std::string toggleKinectService
static const std::string DEFAULT_IMAGE_COLOR_TOPIC
static const int DEFAULT_STEER_STEP
static const std::string DEFAULT_STEERING_COMMAND_TOPIC
std_msgs::UInt8 uint8_msg
shortcut for uint8 messages
void valueChangedSpeed(int value)
This function gets called whenever the speed slider changed.
static const int DEFAULT_MAX_LEFT_STEER
ros::Subscriber magneticSub
void magneticCallback(const magnetic_msg::ConstPtr &magnetic)
This function gets called whenever a message has been published to the magnetic field topic...
void initTopicPollingTimer()
Ininit ros topic polling timer.
Header file for the Dashboard class.
std::string videoFeedMode
void callGetSidServide()
Get the session id from the ucboard.
std::string toggleUSService
void maxRightSteeringClicked()
This function gets called whenever the max right steering button has been clicked.
static const int DEFAULT_MAX_FWD_SPEED
void maxSpeedClicked()
This function gets called whenever the max speed button has been clicked.
sensor_msgs::Imu imu_msg
shortcut for IMU messages
int16_msg steeringMessage
void imuCallback(const imu_msg::ConstPtr &imu)
This function gets called whenever a message has been published to the imu topic. ...