def destroy_node(self): ret = True if self.handle is None: return ret for sub in self.subscriptions: ret &= _rclpy.rclpy_destroy_node_entity( 'subscription', sub.subscription_handle, self.handle) self.subscriptions.remove(sub) for pub in self.publishers: ret &= _rclpy.rclpy_destroy_node_entity( 'publisher', pub.publisher_handle, self.handle) self.publishers.remove(pub) for cli in self.clients: ret &= _rclpy.rclpy_destroy_node_entity( 'client', cli.client_handle, self.handle) self.clients.remove(cli) for srv in self.services: ret &= _rclpy.rclpy_destroy_node_entity( 'service', srv.service_handle, self.handle) self.services.remove(srv) for tmr in self.timers: ret &= _rclpy.rclpy_destroy_entity('timer', tmr.timer_handle) self.timers.remove(tmr) ret &= _rclpy.rclpy_destroy_entity('node', self.handle) self._handle = None return ret
def destroy_subscription(self, subscription): for sub in self.subscriptions: if sub.subscription_handle == subscription.subscription_handle: _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) self.subscriptions.remove(sub) return True return False
def destroy_service(self, service): for srv in self.services: if srv.service_handle == service.service_handle: _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) self.services.remove(srv) return True return False
def destroy_publisher(self, publisher): for pub in self.publishers: if pub.publisher_handle == publisher.publisher_handle: _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) self.publishers.remove(pub) return True return False
def destroy_subscription(self, subscription): for sub in self.subscriptions: if sub.subscription_handle == subscription.subscription_handle: _rclpy.rclpy_destroy_node_entity( 'subscription', sub.subscription_handle, self.handle) self.subscriptions.remove(sub) return True return False
def destroy_client(self, client): for cli in self.clients: if cli.client_handle == client.client_handle: _rclpy.rclpy_destroy_node_entity( 'client', cli.client_handle, self.handle) self.clients.remove(cli) return True return False
def destroy_service(self, service): for srv in self.services: if srv.service_handle == service.service_handle: _rclpy.rclpy_destroy_node_entity( 'service', srv.service_handle, self.handle) self.services.remove(srv) return True return False
def destroy_client(self, client): for cli in self.clients: if cli.client_handle == client.client_handle: _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) self.clients.remove(cli) return True return False
def destroy_publisher(self, publisher): for pub in self.publishers: if pub.publisher_handle == publisher.publisher_handle: _rclpy.rclpy_destroy_node_entity( 'publisher', pub.publisher_handle, self.handle) self.publishers.remove(pub) return True return False
def destroy_client(self, client: Client) -> bool: """ Destroy a service client created by the node. :return: ``True`` if successful, ``False`` otherwise. """ for cli in self.clients: if cli.client_handle == client.client_handle: _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) self.clients.remove(cli) return True return False
def destroy_subscription(self, subscription: Subscription) -> bool: """ Destroy a subscription created by the node. :return: ``True`` if succesful, ``False`` otherwise. """ for sub in self.subscriptions: if sub.subscription_handle == subscription.subscription_handle: _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) self.subscriptions.remove(sub) return True return False
def destroy_publisher(self, publisher: Publisher) -> bool: """ Destroy a publisher created by the node. :return: ``True`` if successful, ``False`` otherwise. """ for pub in self.publishers: if pub.publisher_handle == publisher.publisher_handle: _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) self.publishers.remove(pub) return True return False
def destroy_service(self, service: Service) -> bool: """ Destroy a service server created by the node. :return: ``True`` if successful, ``False`` otherwise. """ for srv in self.services: if srv.service_handle == service.service_handle: _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) self.services.remove(srv) return True return False
def destroy_node(self): ret = True if self.handle is None: return ret while self.publishers: pub = self.publishers.pop() _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) while self.subscriptions: sub = self.subscriptions.pop() _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) while self.clients: cli = self.clients.pop() _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) while self.services: srv = self.services.pop() _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) while self.timers: tmr = self.timers.pop() _rclpy.rclpy_destroy_entity(tmr.timer_handle) while self.guards: gc = self.guards.pop() _rclpy.rclpy_destroy_entity(gc.guard_handle) _rclpy.rclpy_destroy_entity(self.handle) self._handle = None return ret
def destroy_node(self): ret = True if self.handle is None: return ret # Drop extra reference to parameter event publisher. # It will be destroyed with other publishers below. self._parameter_event_publisher = None while self.publishers: pub = self.publishers.pop() _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) while self.subscriptions: sub = self.subscriptions.pop() _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) while self.clients: cli = self.clients.pop() _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) while self.services: srv = self.services.pop() _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) while self.timers: tmr = self.timers.pop() _rclpy.rclpy_destroy_entity(tmr.timer_handle) # TODO(sloretz) Store clocks on node and destroy them separately _rclpy.rclpy_destroy_entity(tmr.clock._clock_handle) while self.guards: gc = self.guards.pop() _rclpy.rclpy_destroy_entity(gc.guard_handle) _rclpy.rclpy_destroy_entity(self.handle) self._handle = None return ret
def destroy_node(self): ret = True if self.handle is None: return ret while self.publishers: pub = self.publishers.pop() _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) while self.subscriptions: sub = self.subscriptions.pop() _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) while self.clients: cli = self.clients.pop() _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) while self.services: srv = self.services.pop() _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) while self.timers: tmr = self.timers.pop() _rclpy.rclpy_destroy_entity(tmr.timer_handle) # TODO(sloretz) Store clocks on node and destroy them separately _rclpy.rclpy_destroy_entity(tmr.clock._clock_handle) while self.guards: gc = self.guards.pop() _rclpy.rclpy_destroy_entity(gc.guard_handle) _rclpy.rclpy_destroy_entity(self.handle) self._handle = None return ret
def destroy_node(self) -> bool: """ Destroy the node. Frees resources used by the node, including any entities created by the following methods: * :func:`create_publisher` * :func:`create_subscription` * :func:`create_client` * :func:`create_service` * :func:`create_timer` * :func:`create_guard_condition` :return: ``True`` if successful, ``False`` otherwise. """ ret = True if self.handle is None: return ret # Drop extra reference to parameter event publisher. # It will be destroyed with other publishers below. self._parameter_event_publisher = None while self.publishers: pub = self.publishers.pop() _rclpy.rclpy_destroy_node_entity(pub.publisher_handle, self.handle) while self.subscriptions: sub = self.subscriptions.pop() _rclpy.rclpy_destroy_node_entity(sub.subscription_handle, self.handle) while self.clients: cli = self.clients.pop() _rclpy.rclpy_destroy_node_entity(cli.client_handle, self.handle) while self.services: srv = self.services.pop() _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle) while self.timers: tmr = self.timers.pop() _rclpy.rclpy_destroy_entity(tmr.timer_handle) # TODO(sloretz) Store clocks on node and destroy them separately _rclpy.rclpy_destroy_entity(tmr.clock._clock_handle) while self.guards: gc = self.guards.pop() _rclpy.rclpy_destroy_entity(gc.guard_handle) _rclpy.rclpy_destroy_entity(self.handle) self._handle = None return ret