expose node namespace in API and pass to rcl (#316)
* expose node namespace in API and pass to rcl * name_space -> namespace_
This commit is contained in:
		
							parent
							
								
									dbe674deb7
								
							
						
					
					
						commit
						e6e1848b97
					
				
					 6 changed files with 38 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -67,22 +67,29 @@ public:
 | 
			
		|||
  /// Create a new node with the specified name.
 | 
			
		||||
  /**
 | 
			
		||||
   * \param[in] node_name Name of the node.
 | 
			
		||||
   * \param[in] namespace_ Namespace of the node.
 | 
			
		||||
   * \param[in] use_intra_process_comms True to use the optimized intra-process communication
 | 
			
		||||
   * pipeline to pass messages between nodes in the same process using shared memory.
 | 
			
		||||
   */
 | 
			
		||||
  RCLCPP_PUBLIC
 | 
			
		||||
  explicit Node(const std::string & node_name, bool use_intra_process_comms = false);
 | 
			
		||||
  explicit Node(
 | 
			
		||||
    const std::string & node_name,
 | 
			
		||||
    const std::string & namespace_ = "",
 | 
			
		||||
    bool use_intra_process_comms = false);
 | 
			
		||||
 | 
			
		||||
  /// Create a node based on the node name and a rclcpp::context::Context.
 | 
			
		||||
  /**
 | 
			
		||||
   * \param[in] node_name Name of the node.
 | 
			
		||||
   * \param[in] namespace_ Namespace of the node.
 | 
			
		||||
   * \param[in] context The context for the node (usually represents the state of a process).
 | 
			
		||||
   * \param[in] use_intra_process_comms True to use the optimized intra-process communication
 | 
			
		||||
   * pipeline to pass messages between nodes in the same process using shared memory.
 | 
			
		||||
   */
 | 
			
		||||
  RCLCPP_PUBLIC
 | 
			
		||||
  Node(
 | 
			
		||||
    const std::string & node_name, rclcpp::context::Context::SharedPtr context,
 | 
			
		||||
    const std::string & node_name,
 | 
			
		||||
    const std::string & namespace_,
 | 
			
		||||
    rclcpp::context::Context::SharedPtr context,
 | 
			
		||||
    bool use_intra_process_comms = false);
 | 
			
		||||
 | 
			
		||||
  RCLCPP_PUBLIC
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,10 @@ public:
 | 
			
		|||
  RCLCPP_SMART_PTR_ALIASES_ONLY(NodeBaseInterface)
 | 
			
		||||
 | 
			
		||||
  RCLCPP_PUBLIC
 | 
			
		||||
  NodeBase(const std::string & node_name, rclcpp::context::Context::SharedPtr context);
 | 
			
		||||
  NodeBase(
 | 
			
		||||
    const std::string & node_name,
 | 
			
		||||
    const std::string & namespace_,
 | 
			
		||||
    rclcpp::context::Context::SharedPtr context);
 | 
			
		||||
 | 
			
		||||
  RCLCPP_PUBLIC
 | 
			
		||||
  virtual
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,18 +33,23 @@
 | 
			
		|||
using rclcpp::node::Node;
 | 
			
		||||
using rclcpp::exceptions::throw_from_rcl_error;
 | 
			
		||||
 | 
			
		||||
Node::Node(const std::string & node_name, bool use_intra_process_comms)
 | 
			
		||||
Node::Node(
 | 
			
		||||
  const std::string & node_name,
 | 
			
		||||
  const std::string & namespace_,
 | 
			
		||||
  bool use_intra_process_comms)
 | 
			
		||||
: Node(
 | 
			
		||||
    node_name,
 | 
			
		||||
    namespace_,
 | 
			
		||||
    rclcpp::contexts::default_context::get_global_default_context(),
 | 
			
		||||
    use_intra_process_comms)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
Node::Node(
 | 
			
		||||
  const std::string & node_name,
 | 
			
		||||
  const std::string & namespace_,
 | 
			
		||||
  rclcpp::context::Context::SharedPtr context,
 | 
			
		||||
  bool use_intra_process_comms)
 | 
			
		||||
: node_base_(new rclcpp::node_interfaces::NodeBase(node_name, context)),
 | 
			
		||||
: node_base_(new rclcpp::node_interfaces::NodeBase(node_name, namespace_, context)),
 | 
			
		||||
  node_graph_(new rclcpp::node_interfaces::NodeGraph(node_base_.get())),
 | 
			
		||||
  node_timers_(new rclcpp::node_interfaces::NodeTimers(node_base_.get())),
 | 
			
		||||
  node_topics_(new rclcpp::node_interfaces::NodeTopics(node_base_.get())),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,7 @@ using rclcpp::node_interfaces::NodeBase;
 | 
			
		|||
 | 
			
		||||
NodeBase::NodeBase(
 | 
			
		||||
  const std::string & node_name,
 | 
			
		||||
  const std::string & namespace_,
 | 
			
		||||
  rclcpp::context::Context::SharedPtr context)
 | 
			
		||||
: context_(context),
 | 
			
		||||
  node_handle_(nullptr),
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +85,7 @@ NodeBase::NodeBase(
 | 
			
		|||
  rcl_node_options_t options = rcl_node_get_default_options();
 | 
			
		||||
  // TODO(wjwwood): pass the Allocator to the options
 | 
			
		||||
  options.domain_id = domain_id;
 | 
			
		||||
  ret = rcl_node_init(rcl_node, node_name.c_str(), &options);
 | 
			
		||||
  ret = rcl_node_init(rcl_node, node_name.c_str(), namespace_.c_str(), &options);
 | 
			
		||||
  if (ret != RCL_RET_OK) {
 | 
			
		||||
    // Finalize the interrupt guard condition.
 | 
			
		||||
    finalize_notify_guard_condition();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue