Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/split rviz packages #1195

Merged
merged 11 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions mock/cpp_mock_scenarios/launch/mock_test.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def generate_launch_description():
arguments=[("__log_level:=warn")],
),
Node(
package="openscenario_visualization",
executable="openscenario_visualization_node",
name="openscenario_visualization_node",
package="traffic_simulator",
executable="visualization_node",
name="visualizer",
output="screen",
),
Node(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ include_directories(include
SYSTEM
${OGRE_INCLUDE_DIRS})

ament_auto_add_library(openscenario_visualization_component SHARED
src/openscenario_visualization_component.cpp
)

ament_auto_add_executable(openscenario_visualization_node
src/openscenario_visualization_node.cpp
)
target_link_libraries(openscenario_visualization_node openscenario_visualization_component)

add_definitions(-DQT_NO_KEYWORDS)

qt5_wrap_ui(UIC_FILES src/ui/context_panel_plugin.ui)
Expand All @@ -63,10 +54,6 @@ target_include_directories(openscenario_visualization_rviz_plugin PRIVATE "${OGR
install(DIRECTORY icons DESTINATION share/openscenario_visualization)
install(DIRECTORY include/ DESTINATION include)

ament_export_libraries(openscenario_visualization_component)

rclcpp_components_register_nodes(openscenario_visualization_component "openscenario_visualization::OpenscenarioVisualizationComponent")

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
Expand Down
13 changes: 13 additions & 0 deletions simulation/traffic_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ ament_auto_add_library(traffic_simulator SHARED
src/traffic_lights/traffic_light_publisher.cpp
)

ament_auto_add_library(visualization_component SHARED
src/visualization/visualization_component.cpp
)

ament_auto_add_executable(visualization_node
src/visualization/visualization_node.cpp
)
target_link_libraries(visualization_node visualization_component)

ament_export_libraries(visualization_component)

rclcpp_components_register_nodes(visualization_component "traffic_simulator::VisualizationComponent")

target_link_libraries(traffic_simulator
tinyxml2
pugixml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class API
const lane_change::TrajectoryShape trajectory_shape,
const lane_change::Constraint & constraint);

// clang-format off
// clang-format off
#define FORWARD_TO_ENTITY_MANAGER(NAME) \
/*! \
@brief Forward to arguments to the EntityManager::NAME function. \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class EntityBase

virtual void cancelRequest();

// clang-format off
// clang-format off
#define DEFINE_GETTER(NAME, TYPE, RETURN_VARIABLE) \
/** \
@brief Get NAME of the entity. \
Expand All @@ -84,7 +84,7 @@ class EntityBase
// clang-format on
#undef DEFINE_GETTER

// clang-format off
// clang-format off
#define DEFINE_CHECK_FUNCTION(FUNCTION_NAME, BOOL_VARIABLE) \
/** \
@note This function was defined by DEFINE_CHECK_FUNCTION function. \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class EntityManager
}
}

// clang-format off
// clang-format off
#define FORWARD_TO_HDMAP_UTILS(NAME) \
/*! \
@brief Forward to arguments to the HDMapUtils::NAME function. \
Expand All @@ -264,7 +264,7 @@ class EntityManager

#undef FORWARD_TO_HDMAP_UTILS

// clang-format off
// clang-format off
#define FORWARD_TO_ENTITY(IDENTIFIER, ...) \
/*! \
@brief Forward to arguments to the EntityBase::IDENTIFIER function. \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* @brief definition of visualizer component
*/

#ifndef OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_
#define OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_
#ifndef TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_
#define TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_

#if __cplusplus
extern "C" {
Expand All @@ -27,38 +27,33 @@ extern "C" {
// demos/composition/include/composition/visibility_control.h at https://github.com/ros2/demos
#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT \
__attribute__((dllexport))
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT \
__attribute__((dllimport))
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __attribute__((dllexport))
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT __attribute__((dllimport))
#else
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT __declspec(dllexport)
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT __declspec(dllimport)
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __declspec(dllexport)
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT __declspec(dllimport)
#endif
#ifdef OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_BUILDING_DLL
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \
OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT
#ifdef TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_BUILDING_DLL
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC \
TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT
#else
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \
OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC \
TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT
#endif
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC_TYPE \
OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC_TYPE \
TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL
#else
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT \
__attribute__((visibility("default")))
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __attribute__((visibility("default")))
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT
#if __GNUC__ >= 4
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \
__attribute__((visibility("default")))
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL \
__attribute__((visibility("hidden")))
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC __attribute__((visibility("default")))
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL __attribute__((visibility("hidden")))
#else
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL
#endif
#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC_TYPE
#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC_TYPE
#endif

#if __cplusplus
Expand All @@ -72,16 +67,16 @@ extern "C" {
#include <unordered_map>
#include <visualization_msgs/msg/marker_array.hpp>

namespace openscenario_visualization
namespace traffic_simulator
{
/**
* @brief ROS 2 component for visualizing simulation result.
*/
class OpenscenarioVisualizationComponent : public rclcpp::Node
class VisualizationComponent : public rclcpp::Node
{
public:
OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC
explicit OpenscenarioVisualizationComponent(const rclcpp::NodeOptions &);
TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC
explicit VisualizationComponent(const rclcpp::NodeOptions &);

private:
/**
Expand Down Expand Up @@ -128,6 +123,6 @@ class OpenscenarioVisualizationComponent : public rclcpp::Node
*/
std::unordered_map<std::string, visualization_msgs::msg::MarkerArray> markers_;
};
} // namespace openscenario_visualization
} // namespace traffic_simulator

#endif // OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_
#endif // TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,25 @@
#include <cmath>
#include <color_names/color_names.hpp>
#include <geometry/spline/catmull_rom_spline.hpp>
#include <openscenario_visualization/openscenario_visualization_component.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_components/register_node_macro.hpp>
#include <string>
#include <traffic_simulator/visualization/visualization_component.hpp>
#include <vector>

namespace openscenario_visualization
namespace traffic_simulator
{
OpenscenarioVisualizationComponent::OpenscenarioVisualizationComponent(
const rclcpp::NodeOptions & options)
: Node("openscenario_visualization", options)
VisualizationComponent::VisualizationComponent(const rclcpp::NodeOptions & options)
: Node("visualization", options)
{
marker_pub_ = create_publisher<visualization_msgs::msg::MarkerArray>("entity/marker", 1);
entity_status_sub_ =
this->create_subscription<traffic_simulator_msgs::msg::EntityStatusWithTrajectoryArray>(
"entity/status", 1,
std::bind(
&OpenscenarioVisualizationComponent::entityStatusCallback, this, std::placeholders::_1));
std::bind(&VisualizationComponent::entityStatusCallback, this, std::placeholders::_1));
}

void OpenscenarioVisualizationComponent::entityStatusCallback(
void VisualizationComponent::entityStatusCallback(
const traffic_simulator_msgs::msg::EntityStatusWithTrajectoryArray::ConstSharedPtr msg)
{
visualization_msgs::msg::MarkerArray current_marker;
Expand Down Expand Up @@ -100,7 +99,7 @@ void OpenscenarioVisualizationComponent::entityStatusCallback(
marker_pub_->publish(current_marker);
}

const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::generateDeleteMarker(
const visualization_msgs::msg::MarkerArray VisualizationComponent::generateDeleteMarker(
std::string ns)
{
auto ret = visualization_msgs::msg::MarkerArray();
Expand All @@ -117,7 +116,7 @@ const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::g
return ret;
}

const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::generateMarker(
const visualization_msgs::msg::MarkerArray VisualizationComponent::generateMarker(
const traffic_simulator_msgs::msg::EntityStatus & status,
const std::vector<geometry_msgs::msg::Pose> & goal_pose,
const traffic_simulator_msgs::msg::WaypointsArray & waypoints,
Expand Down Expand Up @@ -449,15 +448,14 @@ const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::g
return ret;
}

const visualization_msgs::msg::MarkerArray
OpenscenarioVisualizationComponent::generateDeleteMarker() const
const visualization_msgs::msg::MarkerArray VisualizationComponent::generateDeleteMarker() const
{
visualization_msgs::msg::MarkerArray ret;
visualization_msgs::msg::Marker marker;
marker.action = marker.DELETEALL;
ret.markers.emplace_back(marker);
return ret;
}
} // namespace openscenario_visualization
} // namespace traffic_simulator

RCLCPP_COMPONENTS_REGISTER_NODE(openscenario_visualization::OpenscenarioVisualizationComponent)
RCLCPP_COMPONENTS_REGISTER_NODE(traffic_simulator::VisualizationComponent)
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
*/

#include <memory>
#include <openscenario_visualization/openscenario_visualization_component.hpp>
#include <rclcpp/rclcpp.hpp>
#include <traffic_simulator/visualization/visualization_component.hpp>

int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
rclcpp::NodeOptions options;
auto component =
std::make_shared<openscenario_visualization::OpenscenarioVisualizationComponent>(options);
auto component = std::make_shared<traffic_simulator::VisualizationComponent>(options);
rclcpp::spin(component->get_node_base_interface());
rclcpp::shutdown();
return 0;
Expand Down
6 changes: 3 additions & 3 deletions test_runner/random_test_runner/launch/random_test.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ def launch_setup(self, context, *args, **kwargs):
scenario_node,
RegisterEventHandler(event_handler=shutdown_handler),
Node(
package="openscenario_visualization",
executable="openscenario_visualization_node",
package="traffic_simulator",
executable="visualization_node",
namespace="simulation",
name="openscenario_visualizer",
name="visualizer",
output="screen",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ def description():
on_exit=ShutdownOnce(),
),
Node(
package="openscenario_visualization",
executable="openscenario_visualization_node",
package="traffic_simulator",
executable="visualization_node",
namespace="simulation",
name="openscenario_visualizer",
name="visualizer",
output="screen",
),
Node(
Expand Down
Loading