Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a980c7f
added right click service
May 11, 2018
9827340
gps generic services
May 28, 2018
288da7f
Merge branch 'd4l' into kinetic-devel
May 28, 2018
1b66854
multi_res image of simulation map
Jun 4, 2018
50d5b45
efffeu setup
Jun 4, 2018
e208f2d
changed loc of tiles
Jun 8, 2018
c4759ab
tile move
Jun 8, 2018
15f144b
Merge branch 'tmp' into efffeu
Jun 8, 2018
937ce84
latest local d4l
Jul 27, 2018
b6f31e2
finished cleaning-merge request
Jul 27, 2018
fbe884a
Merge remote-tracking branch 'upstream/kinetic-devel' into efffeu
Jul 27, 2018
01655b1
l
Jul 27, 2018
44445c8
l2
Jul 27, 2018
94cd04b
removed dependency from d4l
Aug 1, 2018
66cc20c
Merge branch 'kinetic-devel' of https://github.com/swri-robotics/mapv…
Aug 24, 2018
aeb56b2
removed extraneous files
Aug 24, 2018
1411dd9
minor rempoved dependency
Aug 24, 2018
e0dce22
minor fixes
Aug 24, 2018
438f014
Merge branch 'd4l' into efffeu
Aug 24, 2018
3b5510e
Merge remote-tracking branch 'origin/master' into efffeu
pjreed Nov 13, 2018
3e10717
merge request fixes 14.11
Nov 14, 2018
14e3784
Merge branch 'tmp1411' into HEAD
Nov 19, 2018
6e4414b
19.11 changes workign
Nov 19, 2018
a2912c2
merged CMakeList
Nov 19, 2018
c3ef060
duplicate std_msgs
Nov 19, 2018
5b456f7
removed changes from test.geo
Nov 19, 2018
2e20f7c
rm changes from test.geo
Nov 19, 2018
d5e7bdd
added Readme description to include right click services
Nov 19, 2018
8560299
merged kinetic devel recent into efffeu
Nov 21, 2018
55e88c4
changed text fields to empty right click services
Dec 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mapviz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
)
add_dependencies(${PROJECT_NAME}
${PROJECT_NAME}_gencpp
${catkin_EXPORTED_TARGETS}
)

### Install mapviz ###
Expand Down
5 changes: 5 additions & 0 deletions mapviz/include/mapviz/map_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ namespace mapviz
explicit MapCanvas(QWidget *parent = 0);
~MapCanvas();

std::string showCustomContextMenu(const QPoint &pos,std::vector<std::string> result);


void InitializeTf(boost::shared_ptr<tf::TransformListener> tf);

void AddPlugin(MapvizPluginPtr plugin, int order);
Expand Down Expand Up @@ -181,12 +184,14 @@ namespace mapviz
void mouseMoveEvent(QMouseEvent* e);
void keyPressEvent(QKeyEvent* e);


void Recenter();
void TransformTarget(QPainter* painter);
void Zoom(float factor);

void InitializePixelBuffers();

std::string service_name;
bool canvas_able_to_move_ = true;
bool has_pixel_buffers_;
int32_t pixel_buffer_size_;
Expand Down
58 changes: 49 additions & 9 deletions mapviz/src/map_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include is duplicated.

#include <mapviz/map_canvas.h>
#include <QMenu>
#include <QAction>
#include "ros/ros.h"
#include <vector>
#include <string>
#include <sstream>
#include <iostream>

// C++ standard libraries
#include <cmath>
Expand Down Expand Up @@ -90,6 +97,7 @@ MapCanvas::MapCanvas(QWidget* parent) :
setFrameRate(50.0);
frame_rate_timer_.start();
setFocusPolicy(Qt::StrongFocus);
this->setContextMenuPolicy(Qt::CustomContextMenu);
}

MapCanvas::~MapCanvas()
Expand Down Expand Up @@ -319,13 +327,15 @@ void MapCanvas::Zoom(float factor)

void MapCanvas::mousePressEvent(QMouseEvent* e)
{
mouse_x_ = e->x();
mouse_y_ = e->y();
mouse_previous_y_ = mouse_y_;
drag_x_ = 0;
drag_y_ = 0;
mouse_pressed_ = true;
mouse_button_ = e->button();

mouse_x_ = e->x();
mouse_y_ = e->y();
mouse_previous_y_ = mouse_y_;
drag_x_ = 0;
drag_y_ = 0;
mouse_pressed_ = true;
mouse_button_ = e->button();

}

void MapCanvas::keyPressEvent(QKeyEvent* event)
Expand Down Expand Up @@ -614,4 +624,34 @@ double MapCanvas::frameRate() const
{
return 1000.0 / frame_rate_timer_.interval();
}
} // namespace mapviz

std::string MapCanvas::showCustomContextMenu(const QPoint &pos,std::vector<std::string> result){
QMenu contextMenu(this);
std::vector<QAction *> actions;

for(auto service : result){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general comment that applies to the rest of the code here, but please indent with two spaces per level and put braces on their own lines.

QAction * act= new QAction(service.c_str(),this);
actions.push_back(act);
}
for(auto action: actions){
contextMenu.addAction(action);
}

QAction* selectedItem=contextMenu.exec(pos);
for(auto action: actions){
action->deleteLater();
}

if (selectedItem){
ROS_INFO("make call to %s",selectedItem->text().toStdString().c_str());
return selectedItem->text().toStdString().c_str();
}else{
ROS_ERROR("Service:'' doesn't exist");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message looks like it should be printing out a string; is it missing something?

return "";
}

}


}

20 changes: 19 additions & 1 deletion mapviz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ set(DEPENDENCIES
visualization_msgs
)

find_package(catkin REQUIRED COMPONENTS ${DEPENDENCIES})
find_package(catkin REQUIRED COMPONENTS ${DEPENDENCIES}
std_msgs
geometry_msgs
message_generation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build-time dependencies should be added into the definition of the DEPENDENCIES variable above; also, note that std_msgs is already included.

)

add_message_files(DIRECTORY msg
FILES
Location.msg
)

add_service_files(FILES
AvailableServices.srv
GPSCommand.srv
)
generate_messages(DEPENDENCIES std_msgs geometry_msgs)

### QT ###
if("$ENV{ROS_DISTRO}" STRLESS "kinetic")
Expand Down Expand Up @@ -101,6 +116,7 @@ set(UI_FILES
ui/path_config.ui
ui/plan_route_config.ui
ui/point_click_publisher_config.ui
ui/right_click_services_config.ui
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the order of files in these lists alphabetized.

ui/pointcloud2_config.ui
ui/robot_image_config.ui
ui/route_config.ui
Expand All @@ -127,6 +143,7 @@ set(SRC_FILES
src/placeable_window_proxy.cpp
src/plan_route_plugin.cpp
src/point_click_publisher_plugin.cpp
src/right_click_services_plugin.cpp
src/pointcloud2_plugin.cpp
src/point_drawing_plugin.cpp
src/robot_image_plugin.cpp
Expand Down Expand Up @@ -155,6 +172,7 @@ set(HEADER_FILES
include/${PROJECT_NAME}/placeable_window_proxy.h
include/${PROJECT_NAME}/plan_route_plugin.h
include/${PROJECT_NAME}/point_click_publisher_plugin.h
include/${PROJECT_NAME}/right_click_services_plugin.h
include/${PROJECT_NAME}/pointcloud2_plugin.h
include/${PROJECT_NAME}/point_drawing_plugin.h
include/${PROJECT_NAME}/robot_image_plugin.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace mapviz_plugins
void setMaxClickMovement(qreal max_distance);

Q_SIGNALS:
void pointClicked(const QPointF&);
void pointClicked(const QPointF&, const Qt::MouseButton&);

protected:
bool eventFilter(QObject *object, QEvent* event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace mapviz_plugins
QWidget* GetConfigWidget(QWidget* parent);

protected Q_SLOTS:
void pointClicked(const QPointF& point);
void pointClicked(const QPointF& point, const Qt::MouseButton& button);
void topicChanged(const QString& topic);
void updateFrames();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// *****************************************************************************
// handling right click event, calls service which will display a
// number of services that are available on that specific location
//
// *****************************************************************************


#ifndef MAPVIZ_PLUGINS_right_click_services_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preprocessor definitions should be in all capitals.

#define MAPVIZ_PLUGINS_right_click_services_H

// Include mapviz_plugin.h first to ensure GL deps are included in the right order
#include <mapviz/mapviz_plugin.h>

#include <QGLWidget>
#include <QTimer>
#include <mapviz/map_canvas.h>
#include <QMouseEvent>
#include <mapviz_plugins/canvas_click_filter.h>

#include <ros/ros.h>

// QT autogenerated files
#include "ui_right_click_services_config.h"
#include "ui_topic_select.h"

/**
* This is a pretty straightforward plugin. It watches for user clicks on the
* canvas, then converts the coordinates into a specified frame and publishes
* them as PointStamped messages on a specified topic.
*/
namespace mapviz_plugins
{
class RightClickServicesPlugin : public mapviz::MapvizPlugin
{
Q_OBJECT;
public:

RightClickServicesPlugin();
virtual ~RightClickServicesPlugin();

bool Initialize(QGLWidget* canvas);
void Shutdown() {}

virtual void SetNode(const ros::NodeHandle& node);
virtual void PrintError(const std::string& message);
virtual void PrintInfo(const std::string& message);
virtual void PrintWarning(const std::string& message);

void Draw(double x, double y, double scale);

void Transform() {}

void LoadConfig(const YAML::Node& node, const std::string& path);
void SaveConfig(YAML::Emitter& emitter, const std::string& path);

QWidget* GetConfigWidget(QWidget* parent);


void serviceCall(std::string service);


protected Q_SLOTS:

void pointClicked(const QPointF& point, const Qt::MouseButton& button);
void topicChanged(const QString& topic);
void updateFrames();


private:
void showContextMenu(const QPoint& pos, boost::shared_ptr<geometry_msgs::PointStamped> stamped);
Ui::right_click_services_config ui_;
QWidget* config_widget_;

CanvasClickFilter click_filter_;
mapviz::MapCanvas* canvas_;

QTimer frame_timer_;
ros::Publisher point_publisher_;
};
}

#endif //MAPVIZ_PLUGINS_right_click_services_H
3 changes: 3 additions & 0 deletions mapviz_plugins/mapviz_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<class name="mapviz_plugins/point_click_publisher" type="mapviz_plugins::PointClickPublisherPlugin" base_class_type="mapviz::MapvizPlugin">
<description>Publishes a StampedPoint when a point on the map canvas is clicked.</description>
</class>
<class name="mapviz_plugins/right_click_services" type="mapviz_plugins::RightClickServicesPlugin" base_class_type="mapviz::MapvizPlugin">
<description>displays list of Services availableat that GPS location</description>
</class>
<class name="mapviz_plugins/string" type="mapviz_plugins::StringPlugin" base_class_type="mapviz::MapvizPlugin">
<description>Displays a std_msgs/String at a fixed point on the canvas.</description>
</class>
Expand Down
8 changes: 8 additions & 0 deletions mapviz_plugins/msg/Location.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need to create a new message for this rather than using sensor_msgs/NavSatFix? Re-using an existing message would remove the need to add message generation to this package and also make it easier for this to interact with other packages.

# Latitude (degrees). Positive is north of equator; negative is south.
float64 latitude
# Longitude [degrees]. Positive is east of prime meridian; negative is west.
float64 longitude
# Altitude [m]. Positive is above the WGS 84 ellipsoid
# (quiet NaN if no altitude is available).
float64 altitude
12 changes: 8 additions & 4 deletions mapviz_plugins/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
<license>BSD</license>
<url>https://github.com/swri-robotics/mapviz</url>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>qt_qmake</buildtool_depend>

<build_depend>libqt_dev</build_depend>
<build_depend>libqt_opengl_dev</build_depend>
<build_depend>message_generation</build_depend>

<build_export_depend>message_runtime</build_export_depend>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>qt_qmake</buildtool_depend>

<depend>actionlib</depend>
<depend>cv_bridge</depend>
Expand All @@ -39,9 +42,10 @@
<depend>swri_yaml_util</depend>
<depend>tf</depend>
<depend>visualization_msgs</depend>

<exec_depend>libqt_core</exec_depend>
<exec_depend>libqt_opengl</exec_depend>
<exec_depend>message_runtime</exec_depend>

<export>
<mapviz plugin="${prefix}/mapviz_plugins.xml" />
Expand Down
4 changes: 2 additions & 2 deletions mapviz_plugins/src/canvas_click_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ namespace mapviz_plugins
if (msecsDiff < max_ms_ && distance <= max_distance_)
{
#if QT_VERSION >= 0x050000
Q_EMIT pointClicked(me->localPos());
Q_EMIT pointClicked(me->localPos(), me->button());
#else
Q_EMIT pointClicked(me->posF());
Q_EMIT pointClicked(me->posF(), me->button());
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion mapviz_plugins/src/point_click_publisher_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace mapviz_plugins
}


void PointClickPublisherPlugin::pointClicked(const QPointF& point)
void PointClickPublisherPlugin::pointClicked(const QPointF& point, const Qt::MouseButton& button)
{
QPointF transformed = canvas_->MapGlCoordToFixedFrame(point);

Expand Down
Loading