Beispiel #1
0
    def __init__(self):
        super().__init__('minimal_action_server')

        self._action_server = ActionServer(
            self,
            Fibonacci,
            'fibonacci',
            execute_callback=self.execute_callback,
            callback_group=ReentrantCallbackGroup(),
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback)
 def __init__(self):
     super().__init__('complex_node')
     self.publisher = self.create_publisher(Arrays, 'arrays', qos_profile_system_default)
     self.subscription = self.create_subscription(
         Strings, 'strings', lambda msg: None, qos_profile_system_default
     )
     self.server = self.create_service(BasicTypes, 'basic', lambda req, res: res)
     self.action_server = ActionServer(
         self, Fibonacci, 'fibonacci', self.action_callback
     )
     self.timer = self.create_timer(1.0, self.pub_callback)
 def __init__(self, namespace: str = None):
     super().__init__('each_leg_gait', namespace=namespace)
     self._gait_action_server = ActionServer(
         self,
         Gait,
         'gait',
         execute_callback=self.execute_callback,
         callback_group=ReentrantCallbackGroup(),
         goal_callback=self.goal_callback,
         cancel_callback=self.cancel_callback)
     self._move_leg_action_client = ActionClient(self, MoveLeg, 'move_leg')
    def __init__(self, node, exit_future):
        threading.Thread.__init__(self)
        self._node = node
        self._exit_future = exit_future

        self._action_server = ActionServer(
            node,
            Fibonacci,
            'fibonacci',
            execute_callback=self.execute_callback,
            callback_group=ReentrantCallbackGroup(),
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback)
Beispiel #5
0
    def setUpClass(cls):
        cls.context = rclpy.context.Context()
        rclpy.init(context=cls.context)
        cls.node0 = rclpy.create_node(TEST_NODE0,
                                      namespace=TEST_NAMESPACE0,
                                      context=cls.context)
        cls.node1 = rclpy.create_node(TEST_NODE1,
                                      namespace=TEST_NAMESPACE1,
                                      context=cls.context)
        cls.node2 = rclpy.create_node(TEST_NODE2,
                                      namespace=TEST_NAMESPACE2,
                                      context=cls.context)

        cls.action_client10 = ActionClient(cls.node1, Fibonacci, TEST_ACTION0)
        cls.action_server10 = ActionServer(cls.node1, Fibonacci, TEST_ACTION0,
                                           lambda: None)
        cls.action_client20 = ActionClient(cls.node2, Fibonacci, TEST_ACTION0)
        cls.action_client21 = ActionClient(cls.node2, Fibonacci, TEST_ACTION1)
        cls.action_server20 = ActionServer(cls.node2, Fibonacci, TEST_ACTION0,
                                           lambda: None)
        cls.action_server21 = ActionServer(cls.node2, Fibonacci, TEST_ACTION1,
                                           lambda: None)
Beispiel #6
0
    def __init__(self):
        super().__init__(self.node_name())
        self._dict = self.init_argument()
        self.cb_group = ReentrantCallbackGroup()

        self._action_server = ActionServer(
            self,
            TsDoSubtask,
            "subtask_node_" + str(self.id()),
            execute_callback=self.execute_callback,
            callback_group=self.cb_group,
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback)
    def __init__(self):
        super().__init__('minimal_action_server')

        self._sequence = []

        self._action_server = ActionServer(
            self,
            Fibonacci,
            'fibonacci',
            execute_callback=lambda x, self_=self: self_.execute_callback(x),
            callback_group=ReentrantCallbackGroup(),
            goal_callback=lambda x, self_=self: self_.goal_callback(x),
            cancel_callback=lambda x, self_=self: self_.cancel_callback(x))
    def __init__(self):
        super().__init__('fibonacci_action_server')
        self.action_server = ActionServer(
            self,
            Fibonacci,
            'fibonacci',
            callback_group=ReentrantCallbackGroup(),
            execute_callback=self.execute_callback,
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback,
        )

        self.get_logger().info('=== Fibonacci Action Server Started ====')
    def __init__(self):
        super().__init__('minimal_action_server_8')

        self._action_server = ActionServer(
            self,
            Fibonacci,
            'fibonacci_8',
            execute_callback=self.execute_callback,
            callback_group=ReentrantCallbackGroup(),
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback)

        self.get_logger().info('SERVER 8 : ONLINE')
Beispiel #10
0
 def __init__(self):
     super().__init__('minimal_action_server')
     self._goal_handle = None
     self._goal_lock = threading.Lock()
     self._action_server = ActionServer(
         self,
         Fibonacci,
         'fibonacci',
         execute_callback=self.execute_callback,
         goal_callback=self.goal_callback,
         handle_accepted_callback=self.handle_accepted_callback,
         cancel_callback=self.cancel_callback,
         callback_group=ReentrantCallbackGroup())
    def __init__(self):
        super().__init__('minimal_action_server_6')

        self._action_server = ActionServer(
            self,
            Simple,
            'simple_6',
            execute_callback=self.execute_callback,
            callback_group=ReentrantCallbackGroup(),
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback)

        self.get_logger().info('SERVER 6 : ONLINE')
 def __init__(self):
     super().__init__('move_distance_action')
     self._goal_lock = threading.Lock()
     self._goal_handle = None
     self._action_server = ActionServer(
         self,
         MoveDistance,
         'move_distance',
         execute_callback=self.execute_callback,
         handle_accepted_callback=self.handle_accepted_callback,
         callback_group=ReentrantCallbackGroup(),
         goal_callback=self.goal_callback,
         cancel_callback=self.cancel_callback)
 def __init__(self):
     """
     Class Constructor. Starts the action server node
     """
     super().__init__('hydrophone_streamer_aserver')
     self.action_server = ActionServer(
         self,
         Hydrophoneraw,
         'hydrophoneraw',
         self.execute_callback
     )
     self.publisher = self.create_publisher(String, 'hydrophonerawdata', 10)
     self.are_hydrophones_in = False
Beispiel #14
0
 def __init__(self, goal_tolerance: float=0.05, pos_handler: str=None, pos_topic: str=None):
     super().__init__(pos_handler, pos_topic)
     self._goalreached_event = Event()
     self._abort_event = Event()
     self._lock = Lock()
     self.goal_point = None
     self._tolerance = goal_tolerance
     self._action_server = ActionServer(
         self,
         PositionAction,
         'positionaction',
         self.execute_callback)
     self.tocontrol_publisher = self.create_publisher(Point, 'goal', 10)
Beispiel #15
0
 def test_get_num_entities(self):
     action_server = ActionServer(
         self.node,
         Fibonacci,
         'fibonacci',
         execute_callback=self.execute_goal_callback,
     )
     num_entities = action_server.get_num_entities()
     self.assertEqual(num_entities.num_subscriptions, 0)
     self.assertEqual(num_entities.num_guard_conditions, 0)
     self.assertEqual(num_entities.num_timers, 1)
     self.assertEqual(num_entities.num_clients, 0)
     self.assertEqual(num_entities.num_services, 3)
     action_server.destroy()
Beispiel #16
0
 def __init__(self):
     super(TFRepublisher, self).__init__('tf2_web_republisher')
     self.tf_transform_server = ActionServer(
         node=self,
         action_type=TFSubscription,
         action_name='tf2_web_republisher',
         execute_callback=self.goal_cb,
         cancel_callback=self.cancel_cb)
     self.republish_service = self.create_service(RepublishTFs,
                                                  'republish_tfs',
                                                  self.request_cb)
     self.tf_buffer = Buffer()
     self.tf_listener = TransformListener(self.tf_buffer, node=self)
     self.active_clients = {}
Beispiel #17
0
    def __init__(self):
        """コンストラクタ
        """
        self.cb_group = ReentrantCallbackGroup()

        super().__init__("task_scheduler_manager")
        self.get_logger().info('task_scheduler_manager')
        self.action_server = ActionServer(self,
                                          TsReq,
                                          "tms_ts_master",
                                          self.execute_callback,
                                          goal_callback=self.goal_callback,
                                          cancel_callback=self.cancel_callback,
                                          callback_group=self.cb_group)
Beispiel #18
0
    def __init__(self):
        super().__init__('pipeline_manager')

        self.nodes_in_pipeline = []
        self.pipeline_success = False
        self.pipeline_abort = False
        self.pipeline_feedback_msg = ""

        self.pipeline_types = [
            PipelineType.TYPE_CIRCLE_APPROACH, PipelineType.TYPE_BAR
        ]

        self.declare_parameters(namespace='pipeline',
                                parameters=[('components', ['']),
                                            ('remap_rules', ['']),
                                            ('pkg_name', ''),
                                            ('namespace', '')])

        self.feedback_sub = self.create_subscription(PipelineFeedback,
                                                     '/tr/pipeline_feedback',
                                                     self.feedback_callback,
                                                     10)

        self.pipeline_loading_client = self.create_client(
            LoadNode, '/tr/pipeline/_container/load_node')
        while not self.pipeline_loading_client.wait_for_service(
                timeout_sec=1.0):
            self.get_logger().warn(
                'Pipeline loading service not available, waiting again...')

        self.pipeline_unloading_client = self.create_client(
            UnloadNode, '/tr/pipeline/_container/unload_node')
        while not self.pipeline_unloading_client.wait_for_service(
                timeout_sec=1.0):
            self.get_logger().warn(
                'Pipeline unloading service not available, waiting again...')

        self.pipeline_listing_client = self.create_client(
            ListNodes, '/tr/pipeline/_container/list_nodes')
        while not self.pipeline_listing_client.wait_for_service(
                timeout_sec=1.0):
            self.get_logger().warn(
                'Pipeline listing service not available, waiting again...')

        self.pipeline_running_server = ActionServer(self, RunPipeline,
                                                    'run_pipeline',
                                                    self.run_pipeline)

        self.pipeline_configuring_server = self.create_service(
            ConfigurePipeline, 'configure_pipeline', self.configure_pipeline)
def receive_goals(node, action_type, expected_goals):
    from rclpy.action import ActionServer

    def execute_callback(goal_handle):
        for expected_goal in expected_goals:
            if expected_goal.is_goal_expected(goal_handle.request):
                return expected_goal.execute_goal(goal_handle)
        # Not an expected goal (this should not happen)
        print('Unexpected goal received by action server', file=sys.stderr)
        goal_handle.set_aborted()
        return action_type.Result()

    action_name = 'test/action/' + action_type.__name__
    return ActionServer(node, action_type, action_name, execute_callback)
 def __init__(self, exit_future):
     multiprocessing.Process.__init__(self)
     self._node = rclpy.create_node('minimal_action_server')
     self._executor = MultiThreadedExecutor()
     self._exit_future = exit_future
     
     self._action_server = ActionServer(
         self._node,
         Fibonacci,
         'fibonacci',
         execute_callback=self.execute_callback,
         callback_group=ReentrantCallbackGroup(),
         goal_callback=self.goal_callback,
         cancel_callback=self.cancel_callback)
Beispiel #21
0
    def __init__(self):
        super().__init__('R_KR10')
        self.publisher_ = self.create_publisher(AdjacencyList, 'graph_node_network', 10)
        timer_period = 1  # seconds
        self.timer = self.create_timer(timer_period, self.timer_callback)

        #Action server declaration
        self._action_server = ActionServer(self,Transport,'transport_request',self.transport_callback,goal_callback=self.goal_parse_msg)
        self.action_storage_client_2 = ActionClient(self, Storage, 'storage_request_2')
        self.action_storage_client_5 = ActionClient(self, Storage, 'storage_request_5')
        self.action_storage_client_6 = ActionClient(self, Storage, 'storage_request_6')
        self.servcie_machine_client_4 = self.create_client(MachineRequest5, 'machine_request_5')


        self.graph = AdjacencyList()
        self.graph.node = 3
        self.graph.adjacent = [2,4,5,6]

        self.storage_2_ready = 0

        print("init.....")
        #--------GPIO pin setup start-------------
        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)
        self.pin_start_23 = 33
        self.pin_start_32 = 35
        self.pin_start_34 = 36  
        self.pin_start_43 = 37
        self.pin_start_35 = 38
        self.pin_start_36 = 40
        self.pin_progress = 16
        self.pin_finished = 18
        GPIO.setup(self.pin_start_23, GPIO.OUT) #Input 2 Kuka
        GPIO.setup(self.pin_start_32, GPIO.OUT) #Input 3 Kuka
        GPIO.setup(self.pin_start_34, GPIO.OUT) #Input 4 Kuka
        GPIO.setup(self.pin_start_43, GPIO.OUT) #Input 5 Kuka
        GPIO.setup(self.pin_start_35, GPIO.OUT) #Input 6 Kuka
        GPIO.setup(self.pin_start_36, GPIO.OUT) #Input 7 Kuka
        GPIO.setup(self.pin_progress, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(self.pin_finished, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.output(self.pin_start_23, GPIO.LOW)    
        GPIO.output(self.pin_start_32, GPIO.LOW)
        GPIO.output(self.pin_start_34, GPIO.LOW) 
        GPIO.output(self.pin_start_43, GPIO.LOW) 
        GPIO.output(self.pin_start_35, GPIO.LOW) 
        GPIO.output(self.pin_start_36, GPIO.LOW)  
        #--------GPIO pin setup end-------------
        print("ready")
Beispiel #22
0
 def __init__(self):
     """
     Class Constructor. Starts the action server node
     """
     super().__init__('hydrophone_localiser_aserver')
     self.action_server = ActionServer(self, Hydrophonelocalise,
                                       'hydrophonelocaliser',
                                       self.execute_callback)
     self.samp_rate = 192000
     self.heading_publisher = self.create_publisher(String,
                                                    'target_heading', 10)
     self.distance_publisher = self.create_publisher(
         Float32, 'target_distance', 10)
     self.channel_one_data = ""
     self.channel_two_data = ""
     self.channel_three_data = ""
Beispiel #23
0
    def __init__(self):
        self.task_node_list = []
        self.cb_group = ReentrantCallbackGroup()
        self.name = 'task_scheduler_manager'
        self.goal_handles = []
        super().__init__('task_scheduler_manager')

        self.action_server = ActionServer(
            self,
            TsReq,
            "tms_ts_master",
            self.execute_callback,
            callback_group=self.cb_group,
            goal_callback=self.goal_callback,
            cancel_callback=self.cancel_callback
        )
Beispiel #24
0
    def __init__(self, executor):
        """Initialize."""
        super().__init__('test_runner')
        self.node_executor = executor
        self.invariant_evaluations = []

        self.invariant_evaluation_subscription = self.create_subscription(
            ConditionEvaluationPairStamped, INVARIANT_EVALUATIONS_TOPIC,
            self.add_invariant_evaluation, 10)
        # prevent unused variable warning
        self.invariant_evaluation_subscription
        self.spinning = False
        self._action_server = ActionServer(self, ExecuteXMLTestSuite,
                                           'execute_xml_test_suite',
                                           self.execute_xml_test_suite)
        self.active_goal_handle = None
Beispiel #25
0
    def __init__(self, task_tree):
        """コンストラクタ
        """
        self.cb_group = ReentrantCallbackGroup()
        self.name = f'tasknode_{TaskNode._count}'
        self.task_tree = task_tree
        self.subtask_goalhandles = {}
        super().__init__(self.name)
        TaskNode._count += 1

        self.action_server = ActionServer(self,
                                          TsDoTask,
                                          self.name,
                                          self.execute_callback,
                                          cancel_callback=self.cancel_callback,
                                          callback_group=self.cb_group)
    def __init__(self):
        super().__init__('action_server_node')

        self._goal_handle = None
        self._goal_lock = threading.Lock()
        self._execute_lock = threading.Lock()

        self._as = ActionServer(
            self,
            Move,
            'move',
            execute_callback=self.execute_callback, 
            # goal_callback=self.goal_callback,
            # handle_accepted_callback=self.handle_accepted_callback,
            # cancel_callback=self.cancel_callback,
            # callback_group=ReentrantCallbackGroup()
        )
Beispiel #27
0
    def test_cancel_goal_accept(self):
        def execute_callback(goal_handle):
            # Wait, to give the opportunity to cancel
            time.sleep(3.0)
            self.assertTrue(goal_handle.is_cancel_requested)
            goal_handle.canceled()
            return Fibonacci.Result()

        def cancel_callback(request):
            return CancelResponse.ACCEPT

        executor = MultiThreadedExecutor(context=self.context)
        action_server = ActionServer(
            self.node,
            Fibonacci,
            'fibonacci',
            callback_group=ReentrantCallbackGroup(),
            execute_callback=execute_callback,
            handle_accepted_callback=lambda gh: None,
            cancel_callback=cancel_callback,
        )

        goal_uuid = UUID(uuid=list(uuid.uuid4().bytes))
        goal_order = 10
        goal_msg = Fibonacci.Impl.SendGoalService.Request()
        goal_msg.goal_id = goal_uuid
        goal_msg.goal.order = goal_order
        goal_future = self.mock_action_client.send_goal(goal_msg)
        rclpy.spin_until_future_complete(self.node, goal_future, executor)
        goal_handle = goal_future.result()
        self.assertTrue(goal_handle.accepted)

        cancel_srv = CancelGoal.Request()
        cancel_srv.goal_info.goal_id = goal_uuid
        cancel_srv.goal_info.stamp.sec = 0
        cancel_srv.goal_info.stamp.nanosec = 0
        cancel_future = self.mock_action_client.cancel_goal(cancel_srv)
        rclpy.spin_until_future_complete(self.node, cancel_future, executor)
        cancel_result = cancel_future.result()
        self.assertEqual(len(cancel_result.goals_canceling), 1)
        assert all(
            cancel_result.goals_canceling[0].goal_id.uuid == goal_uuid.uuid)

        action_server.destroy()
        executor.shutdown()
Beispiel #28
0
 def test_constructor_no_defaults(self):
     action_server = ActionServer(
         self.node,
         Fibonacci,
         'fibonacci',
         execute_callback=self.execute_goal_callback,
         callback_group=ReentrantCallbackGroup(),
         goal_callback=lambda req: GoalResponse.REJECT,
         handle_accepted_callback=lambda gh: None,
         cancel_callback=lambda req: CancelResponse.REJECT,
         goal_service_qos_profile=rclpy.qos.qos_profile_default,
         result_service_qos_profile=rclpy.qos.qos_profile_default,
         cancel_service_qos_profile=rclpy.qos.qos_profile_default,
         feedback_pub_qos_profile=rclpy.qos.qos_profile_default,
         status_pub_qos_profile=rclpy.qos.qos_profile_default,
         result_timeout=300,
     )
     action_server.destroy()
Beispiel #29
0
    def __init__(self):
        """Starts a simple action server and waits for requests."""
        super().__init__("animation")
        # currently, we set log level to info since the action server is spamming too much
        if not self.get_parameter("use_sim_time"):
            pass  # todo how does this work in rclpy
            # rospy.on_shutdown(self.on_shutdown_hook)
        self.get_logger().debug("Starting Animation Server")

        self.current_joint_states = None
        self.hcm_state = 0
        self.current_animation = None
        self.animation_cache = {}
        all_animations = find_all_animations_by_name(self)
        for animation_name, animation_file in all_animations.items():
            try:
                with open(animation_file) as fp:
                    self.animation_cache[animation_name] = parse(json.load(fp))
            except IOError:
                self.get_logger().error("Animation '%s' could not be loaded" %
                                        animation_name)
            except ValueError:
                self.get_logger().error(
                    "Animation '%s' had a ValueError. Probably there is a syntax error in the animation file. "
                    "See traceback" % animation_name)
                traceback.print_exc()

        # predefined messages for performance
        self.anim_msg = AnimationMsg()
        # AnimationMsg takes a JointTrajectory message to also be able to process trajectories. To keep this
        # functionality, we use this message type, even though we only need a single joint goal in this case.
        self.traj_msg = JointTrajectory()
        self.traj_point = JointTrajectoryPoint()

        self.create_subscription(JointState, "joint_states",
                                 self.update_current_pose, 1)
        self.create_subscription(RobotControlState, "robot_state",
                                 self.update_hcm_state, 1)
        self.hcm_publisher = self.create_publisher(AnimationMsg, "animation",
                                                   1)

        self._as = ActionServer(self, PlayAnimation, "animation",
                                self.execute_cb)
Beispiel #30
0
    def __init__(self):
        super().__init__('minimal_publisher')
        self.publisher_ = self.create_publisher(AdjacencyList,
                                                'graph_node_network', 10)
        timer_period = 1  # seconds
        self.timer = self.create_timer(timer_period, self.timer_callback)

        self._action_server = ActionServer(self, Storage, 'storage_request_2',
                                           self.spin_execute_callback)

        self.graph = AdjacencyList()
        self.graph.node = 2
        self.graph.adjacent = [1, 3]
        self.trays = [0, 0, 0]
        self.spinning = 0
        self.conveyor_GPIO_pin = 15
        self.conveyor_IR_pins = [38, 40]
        self.pneumatic_stop_pins = [8, 7]
        self.pneumatic_pin = 0

        self.new_ir_readings = [0, 0]
        self.old_ir_readings = [0, 0]
        self.kuka_tray_counter = [-1, -1]
        self.debounce_counter = [0, 0]
        self.tray_requested = 0
        self.found = 0
        self.correct_edge_found = 0

        print("init.....")
        #--------GPIO pin setup start-------------
        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)
        GPIO.setup(self.conveyor_GPIO_pin, GPIO.OUT)
        GPIO.setup(self.conveyor_IR_pins[0],
                   GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(self.conveyor_IR_pins[1],
                   GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(self.pneumatic_stop_pins[0], GPIO.OUT)
        GPIO.setup(self.pneumatic_stop_pins[1], GPIO.OUT)
        #--------GPIO pin setup end-------------
        print("ready")