Skip to content

Commit

Permalink
ROS 2 Dashing Support (#31)
Browse files Browse the repository at this point in the history
Update swri_console to work on ROS 2 Dashing

Distro A, OPSEC #2893

Signed-off-by: P. J. Reed <[email protected]>
Co-authored-by: Jacob Hassold <[email protected]>
  • Loading branch information
jhdcs and Jacob Hassold authored Mar 31, 2020
1 parent 13c211a commit 99fe455
Show file tree
Hide file tree
Showing 27 changed files with 422 additions and 362 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ crashlytics-build.properties
*.dSYM/

# Created by .ignore support plugin (hsz.mobi)
cmake-build-debug/
cmake-build-*/
10 changes: 10 additions & 0 deletions .ros2_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

apt-get update
rosdep update
apt-get install -y build-essential python3-colcon-ros

cd /ws

rosdep install src --from-paths -i -y
colcon build
29 changes: 14 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
sudo: required
dist: trusty
notifications:
email:
on_success: always
on_failure: always
env:
matrix:
- ROS_DISTRO="indigo" USE_DEB="true"
- ROS_DISTRO="kinetic" USE_DEB="true"
- ROS_DISTRO="lunar" USE_DEB="true"
install:
- git clone https://github.com/ros-industrial/industrial_ci.git .ci_config
script:
- source .ci_config/travis.sh
language: generic


services:
- docker

jobs:
include:
- stage: compile
script:
- exec docker run -a STDOUT -a STDERR --rm -v $(pwd):/ws/src/mapviz ros:dashing /ws/src/mapviz/.ros2_build.sh
- stage: compile
script:
- exec docker run -a STDOUT -a STDERR --rm -v $(pwd):/ws/src/mapviz ros:eloquent /ws/src/mapviz/.ros2_build.sh
84 changes: 38 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.10)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

project(swri_console)

find_package(catkin REQUIRED COMPONENTS rosbag_storage roscpp rosgraph_msgs)
### ROS PACKAGES ###
find_package(ament_cmake REQUIRED)
# find_package(rosbag_storage REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcl_interfaces REQUIRED)

### QT PACKAGES ###
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Boost COMPONENTS chrono REQUIRED)

catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS rosbag_storage roscpp rosgraph_msgs
)
find_package(Boost COMPONENTS chrono thread REQUIRED)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(include
${catkin_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
add_definitions(
${Qt5Core_DEFINITIONS}
${Qt5Gui_DEFINITIONS}
${Qt5Widgets_DEFINITIONS}
)

set(QT_USE_QTCORE TRUE)
set(QT_USE_QTGUI TRUE)
include_directories(include)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

# Build mapviz node
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(src)
file (GLOB UI_FILES
set(UI_FILES
ui/console_window.ui)
file (GLOB HEADER_FILES
set(HEADER_FILES
include/swri_console/bag_reader.h
include/swri_console/console_master.h
include/swri_console/console_window.h
Expand All @@ -48,16 +40,16 @@ file (GLOB HEADER_FILES
include/swri_console/rosout_log_loader.h
include/swri_console/ros_thread.h
)
file (GLOB SRC_FILES
set(SRC_FILES
src/bag_reader.cpp
src/console_master.cpp
src/console_window.cpp
src/log_database.cpp
src/log_database_proxy_model.cpp
src/node_click_handler.cpp
src/node_list_model.cpp
src/log_database_proxy_model.cpp
src/ros_thread.cpp
src/rosout_log_loader.cpp
src/ros_thread.cpp
src/settings_keys.cpp
)
qt5_add_resources(RCC_SRCS resources/images.qrc)
Expand All @@ -66,24 +58,24 @@ qt5_wrap_cpp(SRC_FILES ${HEADER_FILES})

add_executable(swri_console ${HEADER_FILES} ${SRC_FILES} ${RCC_SRCS} src/main.cpp)
target_link_libraries(swri_console
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
Qt5::Core
Qt5::Gui
Qt5::Widgets
Boost::chrono
Boost::thread
)

catkin_install_python(PROGRAMS scripts/rosout_agg_recorder
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
ament_target_dependencies(${PROJECT_NAME}
ament_cmake
rclcpp
rcl_interfaces
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

ament_export_dependencies(${RUNTIME_DEPS})
ament_package()
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@

swri_console is an alternative to rqt_console for viewing the ROS console output. swri_console was written to scale well to large systems with heavy console output. It stays responsive under fire and allows users to quickly find information to track down problems.

[![Build Status](https://travis-ci.org/swri-robotics/swri_console.svg?branch=master)](https://travis-ci.org/swri-robotics/swri_console)
### Features

- High performance; swri_console handles receiving thousands of logs per second and storing millions in memory while staying responsive
- Ctrl or shift-click to quickly select which nodes you want to monitor
- Hide or show log messages based on substring matches, or, if you need more power, regular expressions
- Hide, show, and colorize log messages based on severity
- Save and load log messages to text files
- Save and load log messages directly from the `/rosout` topic in a bag file
- *Not supported in ROS 2 yet*
- Right-click on nodes to dynamically set their logger levels
- *Not supported in ROS 2 yet*


[![Build Status](https://travis-ci.org/swri-robotics/swri_console.svg?branch=dashing-devel)](https://travis-ci.org/swri-robotics/swri_console)
Binary file modified doc/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions include/swri_console/bag_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#include <QString>
#include <QMetaType>

#include <rosgraph_msgs/Log.h>
#include <rclcpp/rclcpp.hpp>
#include <rcl_interfaces/msg/log.hpp>

namespace swri_console
{
Expand Down Expand Up @@ -63,7 +64,7 @@ namespace swri_console
* Emitted every time a log message is received. This will likely be emitted several times
* per bag file; finishedReading will be emitted when we're done.
*/
void logReceived(const rosgraph_msgs::LogConstPtr& msg);
void logReceived(const rcl_interfaces::msg::Log::ConstSharedPtr);

/**
* Emitted after we're completely done reading the bag file.
Expand Down
12 changes: 7 additions & 5 deletions include/swri_console/console_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@
#include <QObject>
#include <QList>
#include <QFont>
#include <rosgraph_msgs/Log.h>

#include <rclcpp/rclcpp.hpp>
#include <rcl_interfaces/msg/log.hpp>

#include <swri_console/log_database.h>
#include <swri_console/bag_reader.h>
#include <swri_console/rosout_log_loader.h>

#include "ros_thread.h"
#include <swri_console/ros_thread.h>

namespace swri_console
{
typedef std::vector<rosgraph_msgs::LogConstPtr> MessageList;
typedef std::vector<rcl_interfaces::msg::Log::SharedPtr> MessageList;

class ConsoleWindow;
class ConsoleMaster : public QObject
Expand All @@ -53,7 +55,7 @@ class ConsoleMaster : public QObject

public:
ConsoleMaster(int argc, char** argv);
virtual ~ConsoleMaster();
~ConsoleMaster() override;

public Q_SLOTS:
void createNewWindow();
Expand Down
2 changes: 1 addition & 1 deletion include/swri_console/console_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <QSettings>
#include "ui_console_window.h"

#include "node_click_handler.h"
#include <swri_console/node_click_handler.h>

namespace swri_console
{
Expand Down
16 changes: 9 additions & 7 deletions include/swri_console/log_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
#include <QObject>
#include <QAbstractListModel>
#include <QStringList>
#include <rosgraph_msgs/Log.h>

#include <rclcpp/rclcpp.hpp>
#include <rcl_interfaces/msg/log.hpp>
#include <deque>
#include <ros/time.h>
#include <rclcpp/time.hpp>

namespace swri_console
{
struct LogEntry
{
ros::Time stamp;
rclcpp::Time stamp;
uint8_t level;
std::string node;
std::string file;
Expand All @@ -58,11 +60,11 @@ class LogDatabase : public QObject

public:
LogDatabase();
~LogDatabase();
~LogDatabase() override = default;

void clear();
const std::deque<LogEntry>& log() { return log_; }
const ros::Time& minTime() const { return min_time_; }
const rclcpp::Time& minTime() const { return min_time_; }

const std::map<std::string, size_t>& messageCounts() const { return msg_counts_; }

Expand All @@ -72,15 +74,15 @@ class LogDatabase : public QObject
void minTimeUpdated();

public Q_SLOTS:
void queueMessage(const rosgraph_msgs::LogConstPtr msg);
void queueMessage(const rcl_interfaces::msg::Log::ConstSharedPtr msg);
void processQueue();

private:
std::map<std::string, size_t> msg_counts_;
std::deque<LogEntry> log_;
std::deque<LogEntry> new_msgs_;

ros::Time min_time_;
rclcpp::Time min_time_;
}; // class LogDatabase
} // namespace swri_console
#endif // SWRI_CONSOLE_LOG_DATABASE_H_
13 changes: 7 additions & 6 deletions include/swri_console/log_database_proxy_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <QStringList>
#include <QRegExp>

#include <stdint.h>
#include <cstdint>
#include <set>
#include <string>
#include <deque>
Expand All @@ -46,6 +46,7 @@ namespace swri_console

class LogDatabase;
struct LogEntry;

class LogDatabaseProxyModel : public QAbstractListModel
{
Q_OBJECT
Expand All @@ -55,8 +56,8 @@ class LogDatabaseProxyModel : public QAbstractListModel
ExtendedLogRole = Qt::UserRole + 0
};

LogDatabaseProxyModel(LogDatabase *db);
~LogDatabaseProxyModel();
explicit LogDatabaseProxyModel(LogDatabase *db);
~LogDatabaseProxyModel() override = default;

void setNodeFilter(const std::set<std::string> &names);
void setSeverityFilter(uint8_t severity_mask);
Expand All @@ -71,11 +72,11 @@ class LogDatabaseProxyModel : public QAbstractListModel
void setFatalColor(const QColor& fatal_color);
bool isIncludeValid() const;
bool isExcludeValid() const;
int getItemIndex(const QString searchText, int index, int increment);
int getItemIndex(const QString& searchText, int index, int increment);
void clearSearchFailure();

virtual int rowCount(const QModelIndex &parent) const;
virtual QVariant data(const QModelIndex &index, int role) const;
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;

void reset();

Expand Down
Loading

0 comments on commit 99fe455

Please sign in to comment.