diff --git a/crosbot_ui/CMakeLists.txt b/crosbot_ui/CMakeLists.txt index 897d424eb746670678da93ccc41be79597986a4c..b2731609afb5b894592b3866caedfe9718d2dcfe 100644 --- a/crosbot_ui/CMakeLists.txt +++ b/crosbot_ui/CMakeLists.txt @@ -4,7 +4,7 @@ project(crosbot_ui) ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages -find_package(catkin REQUIRED COMPONENTS roscpp crosbot crosbot_map crosbot_fastslam) +find_package(catkin REQUIRED COMPONENTS roscpp crosbot crosbot_map crosbot_fastslam image_transport) ## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) diff --git a/crosbot_ui/Makefile b/crosbot_ui/Makefile index 500462201e45707c3ad6ccccdaa35878fe40ae6f..b0f7a862b9ec258db73036a6ee61ed8c9d716237 100644 --- a/crosbot_ui/Makefile +++ b/crosbot_ui/Makefile @@ -1,5 +1,7 @@ +PACKAGE=$(shell basename `pwd` ) + default: all all: - make -C ../.. + make -C ../.. $(PACKAGE) diff --git a/crosbot_ui/include/crosbot_ui/renders/robot/image.hpp b/crosbot_ui/include/crosbot_ui/renders/robot/image.hpp index 30fb2f86fd4c14158508c74bae450f67dff67119..fe8aeadc2fdaeab8e6453568d73b6f4d1dbd176c 100644 --- a/crosbot_ui/include/crosbot_ui/renders/robot/image.hpp +++ b/crosbot_ui/include/crosbot_ui/renders/robot/image.hpp @@ -8,10 +8,11 @@ #ifndef CROSBOT_RENDER_IMAGE_HPP_ #define CROSBOT_RENDER_IMAGE_HPP_ +#include #include #include -#include +#include namespace crosbot { @@ -27,9 +28,9 @@ public: virtual void render(); virtual bool isHidden(); - virtual bool keyPressEvent(QKeyEvent *ke); + virtual bool keyPressEvent(QKeyEvent *e); - void callback(sensor_msgs::ImageConstPtr); + void callback(const sensor_msgs::ImageConstPtr&); protected: ImagePtr image, textureImage; bool hidden; @@ -37,8 +38,9 @@ protected: Colour4f colour; GLuint textureId; - std::string topic; - ros::Subscriber subscriber; + std::string topic, transport; + image_transport::Subscriber subscriber; + }; } // namespace gui diff --git a/crosbot_ui/include/crosbot_ui/renders/robot/simple.hpp b/crosbot_ui/include/crosbot_ui/renders/robot/simple.hpp index c91b6c3529fdc317ad28b8f27201f330339d0989..aa3f78f267bb29dcac0d8a6b6d2cd240810a1fc4 100644 --- a/crosbot_ui/include/crosbot_ui/renders/robot/simple.hpp +++ b/crosbot_ui/include/crosbot_ui/renders/robot/simple.hpp @@ -60,7 +60,6 @@ protected: std::string topic; ros::Subscriber subscriber; - Colour4f lineColour, fillColour; }; diff --git a/crosbot_ui/package.xml b/crosbot_ui/package.xml index 66a27f8b048515d009f9b65b69bfd30d72717d7f..16d164293a0b1f3bf540fd974be7380794709417 100644 --- a/crosbot_ui/package.xml +++ b/crosbot_ui/package.xml @@ -44,11 +44,13 @@ crosbot_map crosbot_fastslam roscpp + image_transport qt4 crosbot crosbot_map crosbot_fastslam roscpp + image_transport qt4 diff --git a/crosbot_ui/src/renders/robot/image.cpp b/crosbot_ui/src/renders/robot/image.cpp index a2a6dd3f9e17db92b328f49e2407183fc103025c..e50bb579170266d0301e0a88cd8682b15b0c1f34 100644 --- a/crosbot_ui/src/renders/robot/image.cpp +++ b/crosbot_ui/src/renders/robot/image.cpp @@ -31,14 +31,16 @@ ImageRender::ImageRender(RobotPanel& panel, ConfigElementPtr config) : topic = config->getParam(PARAM_TOPIC); topic = config->getParam(RENDER_IMAGE, topic); topic = config->getParam(PARAM_NAME, topic); + transport = config->getParam("transport", "raw"); } void ImageRender::start() { if (topic != "") { ros::NodeHandle nh("~"); - subscriber = nh.subscribe(topic, 1, &ImageRender::callback, this); + image_transport::ImageTransport it(nh); + image_transport::TransportHints hint(transport); + subscriber = it.subscribe(topic, 1, &ImageRender::callback, this, hint); } - } void ImageRender::stop() { @@ -59,8 +61,11 @@ bool ImageRender::keyPressEvent(QKeyEvent *ke) { return false; } -void ImageRender::callback(sensor_msgs::ImageConstPtr rosImage) { +void ImageRender::callback(const sensor_msgs::ImageConstPtr& rosImage) { ImagePtr image = new Image(rosImage); + if (image->encoding == Image::Unknown) { + ERROR("crosbot::Image: Unknown encoding %s\n", rosImage->encoding.c_str()); + } this->image = image; } diff --git a/crosbot_ui/src/renders/robot/simple.cpp b/crosbot_ui/src/renders/robot/simple.cpp index f3c232d208a6851875aa70f2d8ec5ae7080989e5..ed7d6b32f7d9696a98b4c4ba5ef519dff7b7f9b7 100644 --- a/crosbot_ui/src/renders/robot/simple.cpp +++ b/crosbot_ui/src/renders/robot/simple.cpp @@ -96,7 +96,7 @@ void SpeedRender::render() { #define MOUSE_DELTA 120 bool SpeedRender::wheelEvent(QWheelEvent *we) { float currentSpeed, currentTurnRate; - panel.getCurrentSpeeds(currentSpeed, currentTurnRate); + panel.getThrottle(currentSpeed, currentTurnRate); if(we->modifiers() != 0) { float newTurnRate = currentTurnRate; @@ -120,7 +120,7 @@ bool SpeedRender::wheelEvent(QWheelEvent *we) { } currentSpeed = newSpeed; } - panel.setCurrentSpeeds(currentSpeed, currentTurnRate); + panel.setThrottle(currentSpeed, currentTurnRate); return true; }