-
Notifications
You must be signed in to change notification settings - Fork 219
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
Use Rviz as a component #1140
base: rolling
Are you sure you want to change the base?
Use Rviz as a component #1140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||
/* | ||||||
* Copyright (c) 2024, Open Source Robotics Foundation. | ||||||
* All rights reserved. | ||||||
* | ||||||
* Redistribution and use in source and binary forms, with or without | ||||||
* modification, are permitted provided that the following conditions are met: | ||||||
* | ||||||
* * Redistributions of source code must retain the above copyright | ||||||
* notice, this list of conditions and the following disclaimer. | ||||||
* * Redistributions in binary form must reproduce the above copyright | ||||||
* notice, this list of conditions and the following disclaimer in the | ||||||
* documentation and/or other materials provided with the distribution. | ||||||
* * Neither the name of the Willow Garage, Inc. nor the names of its | ||||||
* contributors may be used to endorse or promote products derived from | ||||||
* this software without specific prior written permission. | ||||||
* | ||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||||
* POSSIBILITY OF SUCH DAMAGE. | ||||||
*/ | ||||||
|
||||||
#ifndef RVIZ_COMMON__ROS_INTEGRATION__ROS_COMPONENT_MANAGER_HPP_ | ||||||
#define RVIZ_COMMON__ROS_INTEGRATION__ROS_COMPONENT_MANAGER_HPP_ | ||||||
|
||||||
#include "rclcpp_components/component_manager.hpp" | ||||||
#include "rclcpp_components/node_instance_wrapper.hpp" | ||||||
#include "rviz_common/visibility_control.hpp" | ||||||
|
||||||
namespace rviz_common | ||||||
{ | ||||||
namespace ros_integration | ||||||
{ | ||||||
class RVIZ_COMMON_PUBLIC ComponentManager : public rclcpp_components::ComponentManager{ | ||||||
public: | ||||||
using rclcpp_components::ComponentManager::ComponentManager; | ||||||
|
||||||
void | ||||||
add_node_to_executor( | ||||||
rclcpp_components::NodeInstanceWrapper & node) | ||||||
{ | ||||||
auto node_id = unique_id_++; | ||||||
node_wrappers_[node_id] = node; | ||||||
if (auto exec = this->executor_.lock()) { | ||||||
exec->add_node(node.get_node_base_interface(), true); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop
Suggested change
|
||||||
} | ||||||
} | ||||||
}; | ||||||
} // namespace ros_integration | ||||||
} // namespace rviz_common | ||||||
|
||||||
#endif // RVIZ_COMMON__ROS_INTEGRATION__ROS_COMPONENT_MANAGER_HPP_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
#include "rviz_common/display_context.hpp" | ||
#include "rviz_common/frame_manager_iface.hpp" | ||
#include "rviz_common/ros_integration/ros_node_abstraction_iface.hpp" | ||
#include "rviz_common/ros_integration/ros_component_manager.hpp" | ||
#include "rviz_common/transformation/transformation_manager.hpp" | ||
|
||
class QTimer; | ||
|
@@ -399,6 +400,7 @@ private Q_SLOTS: | |
rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_; | ||
ros_integration::RosNodeAbstractionIface::WeakPtr rviz_ros_node_; | ||
rviz_common::transformation::TransformationManager * transformation_manager_; | ||
std::shared_ptr<ros_integration::ComponentManager> mgr_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly initialize to |
||
}; | ||
|
||
} // namespace rviz_common | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ namespace ros_integration | |
{ | ||
|
||
RosNodeAbstraction::RosNodeAbstraction(const std::string & node_name) | ||
: raw_node_(rclcpp::Node::make_shared(node_name)) | ||
: raw_node_(rclcpp::Node::make_shared(node_name, rclcpp::NodeOptions().use_intra_process_comms(true))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make |
||
{} | ||
|
||
std::string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
|
||
#include "rclcpp/clock.hpp" | ||
#include "rclcpp/time.hpp" | ||
#include <rclcpp_components/node_instance_wrapper.hpp> | ||
#include "rviz_rendering/material_manager.hpp" | ||
#include "rviz_rendering/render_window.hpp" | ||
|
||
|
@@ -225,7 +226,15 @@ VisualizationManager::VisualizationManager( | |
|
||
connect(this, SIGNAL(timeJumped()), this, SLOT(resetTime())); | ||
|
||
executor_->add_node(rviz_ros_node_.lock()->get_raw_node()); | ||
if (!mgr_) { | ||
mgr_ = std::make_shared<ros_integration::ComponentManager>(executor_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we allow users to configure the name of the component manager and pass it along as an argument here? |
||
executor_->add_node(mgr_); | ||
|
||
auto inst = rclcpp_components::NodeInstanceWrapper( | ||
rviz_ros_node_.lock()->get_raw_node(), | ||
std::bind(&rclcpp::Node::get_node_base_interface, rviz_ros_node_.lock()->get_raw_node())); | ||
mgr_->add_node_to_executor(inst); | ||
} | ||
|
||
display_factory_ = new DisplayFactory(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move impl to a .cpp file?