Пример #1
0
def main(args=None):
    global logger
    rclpy.init(args=args)

    node = rclpy.create_node('minimal_action_server')
    logger = node.get_logger()

    # Use a ReentrantCallbackGroup to enable processing multiple goals concurrently
    # Default goal callback accepts all goals
    # Default cancel callback rejects cancel requests
    action_server = ActionServer(
        node,
        Fibonacci,
        'fibonacci',
        execute_callback=execute_callback,
        cancel_callback=cancel_callback,
        callback_group=ReentrantCallbackGroup())

    # Use a MultiThreadedExecutor to enable processing goals concurrently
    executor = MultiThreadedExecutor()

    rclpy.spin(node, executor=executor)

    action_server.destroy()
    node.destroy_node()
    rclpy.shutdown()
Пример #2
0
def main(args=None):
    rclpy.init(args=args)

    node = rclpy.create_node('minimal_publisher')
    publisher = node.create_publisher(String, 'topic', 10)

    msg = String()
    i = 0

    def timer_callback():
        nonlocal i
        msg.data = 'Hello World: %d' % i
        i += 1
        node.get_logger().info('Publishing: "%s"' % msg.data)
        publisher.publish(msg)

    timer_period = 0.5  # seconds
    timer = node.create_timer(timer_period, timer_callback)

    rclpy.spin(node)

    # Destroy the timer attached to the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    node.destroy_timer(timer)
    node.destroy_node()
    rclpy.shutdown()
Пример #3
0
def main(args=None):
    rclpy.init(args=args)

    action_client = MinimalActionClient()

    action_client.send_goal()

    rclpy.spin(action_client)
Пример #4
0
def main(args=None):
    rclpy.init(args=args)

    minimal_service = MinimalService()

    rclpy.spin(minimal_service)

    rclpy.shutdown()
Пример #5
0
def main(args=None):
    rclpy.init(args=args)
    try:
        talker = ThrottledTalker()
        rclpy.spin(talker)
    finally:
        talker.destroy_node()
        rclpy.shutdown()
Пример #6
0
def main(argv=sys.argv):
    rclpy.init(args=argv)

    node = rclpy.create_node(
        'initial_params_node', namespace='/', allow_undeclared_parameters=True)
    rclpy.spin(node)

    rclpy.shutdown()
    return 0
Пример #7
0
def main(args=None):
    rclpy.init(args=args)

    action_server = MinimalActionServer()

    # We use a MultiThreadedExecutor to handle incoming goal requests concurrently
    executor = MultiThreadedExecutor()
    rclpy.spin(action_server, executor=executor)

    action_server.destroy()
    rclpy.shutdown()
Пример #8
0
def main(args=None):
    rclpy.init(args=args)

    minimal_publisher = MinimalPublisher()

    rclpy.spin(minimal_publisher)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    minimal_publisher.destroy_node()
    rclpy.shutdown()
Пример #9
0
def main(args=None):
    if args is None:
        args = sys.argv

    rclpy.init(args)

    node = rclpy.create_node('listener')

    sub = node.create_subscription(String, 'chatter', chatter_callback, qos_profile_default)
    assert sub  # prevent unused warning

    rclpy.spin(node)
Пример #10
0
def main(args=None):
    rclpy.init(args=args)

    minimal_action_server = MinimalActionServer()

    # Use a MultiThreadedExecutor to enable processing goals concurrently
    executor = MultiThreadedExecutor()

    rclpy.spin(minimal_action_server, executor=executor)

    minimal_action_server.destroy()
    rclpy.shutdown()
Пример #11
0
def main(args=None):
    """
    Run a Listener node standalone.

    This function is called directly when using an entrypoint. Entrypoints are configured in
    setup.py. This along with the script installation in setup.cfg allows a listener node to be run
    with the command `ros2 run examples_rclpy_executors listener`.

    :param args: Arguments passed in from the command line.
    """
    rclpy.init(args=args)
    try:
        rclpy.spin(Listener())
    finally:
        rclpy.shutdown()
Пример #12
0
def main(args=None):
    rclpy.init(args=args)

    node = rclpy.create_node('minimal_subscriber')

    subscription = node.create_subscription(
        String, 'topic', lambda msg: print('I heard: [%s]' % msg.data))
    subscription  # prevent unused variable warning

    rclpy.spin(node)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    node.destroy_node()
    rclpy.shutdown()
Пример #13
0
def main():
    rclpy.init()
    controller = Controller()
    rclpy.spin(controller)
Пример #14
0
def main(args=None):
    rclpy.init(args=args)
    minimal_publisher = MinimalPublisher()
    rclpy.spin(minimal_publisher)
    rclpy.shutdown()
Пример #15
0
def main(args=None):
    rclpy.init(args=args)
    force_sensor = ForceSensorCorrection()
    rclpy.spin(force_sensor)
    force_sensor.destroy_node()
    rclpy.shutdown()
Пример #16
0
    parser.add_argument('namespace', help='namespace of the ROS node')
    args = parser.parse_args()

    rclpy.init(args=[])
    node = rclpy.create_node('action_server', namespace=args.namespace)

    if 'Fibonacci' == args.action_type:
        action_server = receive_goals(node, Fibonacci, generate_expected_fibonacci_goals())
    elif 'NestedMessage' == args.action_type:
        action_server = receive_goals(
            node,
            NestedMessage,
            generate_expected_nested_message_goals(),
        )
    else:
        print('Unknown action type {!r}'.format(args.action_type), file=sys.stderr)
        node.destroy_node()
        rclpy.shutdown()
        sys.exit(1)

    try:
        rclpy.spin(node)
    except KeyboardInterrupt:
        print('Action server stopped cleanly')
    except BaseException:
        print('Exception in action server:', file=sys.stderr)
        raise
    finally:
        node.destroy_node()
        rclpy.shutdown()
Пример #17
0
def main(args=None):
    rclpy.init(args=args)
    exampleController = ExampleController(args=args)
    rclpy.spin(exampleController)
    rclpy.shutdown()
        response_msg = SomeResponse()

        unix_timestamp = time.time()

        response_msg.timestamp.sec = int(unix_timestamp)
        response_msg.timestamp.nanosec = int((unix_timestamp - int(unix_timestamp)) * 1e+9)

        response_msg.source_id = _SOURCE_ID
        response_msg.destination_id = msg.source_id
        response_msg.conversation_id = msg.conversation_id
        response_msg.data = 'You sent: {}'.format(repr(msg.data))

        self.publisher.publish(response_msg)

        self.logger.info('Sent: {}'.format(response_msg))


if __name__ == '__main__':
    import sys

    rclpy.init(args=sys.argv)

    node = SomeRequestToSomeResponseNode()

    rclpy.spin(node)

    node.destroy_node()

    rclpy.shutdown()
Пример #19
0
def main (args=None):
    rclpy.init(args=args)
    node=my_node()
    rclpy.spin(node)

    rclpy.shutdown()
Пример #20
0
def main(args=None):
	rclpy.init(args=args)
	node = LEDPanel()
	rclpy.spin(node)
	rclpy.shutdown()
Пример #21
0
def main(usbserial):
    rclpy.init(args=None)

    cnc_action_server = CNCActionServer(usbserial)

    rclpy.spin(cnc_action_server)
Пример #22
0
def main(args=None):
    rclpy.init(args=args)
    minimal_subscriber = MinimalSubscriber()
    rclpy.spin(minimal_subscriber.node)
    minimal_subscriber.destroy_node()
    rclpy.shutdown()
Пример #23
0
def main():
    rclpy.init()
    node = ImageSystem()
    rclpy.spin(node)
def main(args=None):
    rclpy.init(args=args)

    fibonacci_action_server = FibonacciActionServer()

    rclpy.spin(fibonacci_action_server)
Пример #25
0
def main(args=None):
    rclpy.init(args=args)
    detector = DetectorNode()
    rclpy.spin(detector)
    detector.destroy_node()
    rclpy.shutdown()
Пример #26
0
def main(args=None):
    rclpy.init(args=args)
    node = nodeMaker()
    rclpy.spin(node)
    rclpy.shutdown()
Пример #27
0
def main(args=None):
    rclpy.init(args=args)
    command_node = CVCommandsNode()
    rclpy.spin(command_node)
    rclpy.shutdown()
Пример #28
0
    cam_info = msg
    global tf_buffer
    global pubLineContainer

    add_corners()
    add_tcrossings()
    add_crosses()
    publish_goals()

    pubGoals.publish(message_container)
    message_container = LineInformationRelative()


if __name__ == '__main__':
    cam_info_sub = rospy.Subscriber("/camera_info", CameraInfo, cam_info_cb)

    pubLineContainer = self.create_publisher(LineInformationRelative, '/lines',
                                             10)

    pubGoals = self.create_publisher(GoalRelative, '/goals_simulated', 10)

    while rclpy.ok():
        try:
            rclpy.spin(self)
        except rospy.exceptions.ROSTimeMovedBackwardsException:
            self.get_logger().warn(
                "We moved backwards in time. I hope you just resetted the simulation. If not there is something wrong"
            )
        except rospy.exceptions.ROSInterruptException:
            exit()
def main(args=None):
    rclpy.init(args=args)
    node = getCameraDataNode()
    rclpy.spin(node)
    rclpy.shutdown()
Пример #30
0
def main(args=None):
    rclpy.init(args=args)
    epuck_controller = EPuckDriveCalibrator('epuck_drive_calibrator')
    rclpy.spin(epuck_controller)
    epuck_controller.destroy_node()
    rclpy.shutdown()
Пример #31
0
def main(args=None):
	# Iterate over the joystick devices.
	print('Available devices:')
	i = 0
	for fn in os.listdir('/dev/input'):
		if fn.startswith('js'):
			print('  /dev/input/%s' % (fn))
			i += 1
	if i == 0:
		print("No joysticks found. Terminating")
		sys.exit(-1)

	# We'll store the states here.
	axis_states = {}
	button_states = {}

	# These constants were borrowed from linux/input.h
	axis_names = {
		0x00 : 'x',
		0x01 : 'y',
		0x02 : 'z',
		0x03 : 'rx',
		0x04 : 'ry',
		0x05 : 'rz',
		0x06 : 'trottle',
		0x07 : 'rudder',
		0x08 : 'wheel',
		0x09 : 'gas',
		0x0a : 'brake',
		0x10 : 'hat0x',
		0x11 : 'hat0y',
		0x12 : 'hat1x',
		0x13 : 'hat1y',
		0x14 : 'hat2x',
		0x15 : 'hat2y',
		0x16 : 'hat3x',
		0x17 : 'hat3y',
		0x18 : 'pressure',
		0x19 : 'distance',
		0x1a : 'tilt_x',
		0x1b : 'tilt_y',
		0x1c : 'tool_width',
		0x20 : 'volume',
		0x28 : 'misc',
	}

	button_names = {
		0x120 : 'trigger',
		0x121 : 'thumb',
		0x122 : 'thumb2',
		0x123 : 'top',
		0x124 : 'top2',
		0x125 : 'pinkie',
		0x126 : 'base',
		0x127 : 'base2',
		0x128 : 'base3',
		0x129 : 'base4',
		0x12a : 'base5',
		0x12b : 'base6',
		0x12f : 'dead',
		0x130 : 'a',
		0x131 : 'b',
		0x132 : 'c',
		0x133 : 'x',
		0x134 : 'y',
		0x135 : 'z',
		0x136 : 'tl',
		0x137 : 'tr',
		0x138 : 'tl2',
		0x139 : 'tr2',
		0x13a : 'select',
		0x13b : 'start',
		0x13c : 'mode',
		0x13d : 'thumbl',
		0x13e : 'thumbr',

		0x220 : 'dpad_up',
		0x221 : 'dpad_down',
		0x222 : 'dpad_left',
		0x223 : 'dpad_right',

		# XBox 360 controller uses these codes.
		0x2c0 : 'dpad_left',
		0x2c1 : 'dpad_right',
		0x2c2 : 'dpad_up',
		0x2c3 : 'dpad_down',
	}

	axis_map = []
	button_map = []

	print("\nFinding correct joystick")
	for fn in os.listdir('/dev/input'):
		if fn.startswith('js'):
			jsdev = open("/dev/input/" + fn, 'rb')
			buf = array.array('B', [0] * 64)
			ioctl(jsdev, 0x80006a13 + (0x10000 * len(buf)), buf) # JSIOCGNAME(len)
			js_name = buf.tobytes().rstrip(b'\x00').decode('utf-8')
		if js_name == "Microsoft X-Box One S pad":
			break
		jsdev.close()
	if js_name != "Microsoft X-Box One S pad":
		print("Joystick not found terminating")
		jsdev.close()
		sys.exit(-1)
	print("Correct joystick found\n")

	# Get number of axes and buttons.
	buf = array.array('B', [0])
	ioctl(jsdev, 0x80016a11, buf) # JSIOCGAXES
	num_axes = buf[0]

	buf = array.array('B', [0])
	ioctl(jsdev, 0x80016a12, buf) # JSIOCGBUTTONS
	num_buttons = buf[0]

	# Get the axis map.
	buf = array.array('B', [0] * 0x40)
	ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP

	for axis in buf[:num_axes]:
		axis_name = axis_names.get(axis, 'unknown(0x%02x)' % axis)
		axis_map.append(axis_name)
		axis_states[axis_name] = 0.0

	# Get the button map.
	buf = array.array('H', [0] * 200)
	ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP

	for btn in buf[:num_buttons]:
		btn_name = button_names.get(btn, 'unknown(0x%03x)' % btn)
		button_map.append(btn_name)
		button_states[btn_name] = 0

	print('%d axes found: %s' % (num_axes, ', '.join(axis_map)))
	print('%d buttons found: %s' % (num_buttons, ', '.join(button_map)))

	rclpy.init(args=args)

	controller = MainDriveTeleop(jsdev, axis_map, axis_states, button_map, button_states, num_axes, num_buttons)
	rclpy.spin(controller)

	# Destroy the node explicitly
	# (optional - otherwise it will be done automatically
	# when the garbage collector destroys the node object)
	controller.destroy_node()
	rclpy.shutdown()
Пример #32
0
 def run(self):
     rclpy.spin(self._node)
Пример #33
0
def main(args=None):
    rclpy.init(args=args)
    try:
        rclpy.spin(ThrottledTalker())
    finally:
        rclpy.shutdown()
Пример #34
0
import rclpy
from rclpy.node import Node

from sensor import MinimalSubscriber

rclpy.init(args=args)

Drone1Sensor = MinimalSubscriber(1)

rclpy.spin(Drone1Sensor)

# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_subscriber.destroy_node()
rclpy.shutdown()

Пример #35
0
def main(args=None):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--cfg',
        type=str,
        default='/module/src/rectifier/rectifier/cfg/yolov3.cfg',
        help='*.cfg path')
    parser.add_argument('--names',
                        type=str,
                        default='data/coco.names',
                        help='*.names path')
    parser.add_argument(
        '--weights',
        type=str,
        default=
        '/home/mayank_s/playing_ros/c++/ros2_play_old/src/rectifier/rectifier/weights/color_model.pt',
        help='weights path')
    parser.add_argument('--source',
                        type=str,
                        default='data/samples',
                        help='source')
    parser.add_argument('--output',
                        type=str,
                        default='output',
                        help='output folder')  # output folder
    parser.add_argument('--img-size',
                        type=int,
                        default=416,
                        help='inference size (pixels)')
    parser.add_argument('--conf-thres',
                        type=float,
                        default=0.3,
                        help='object confidence threshold')
    parser.add_argument('--iou-thres',
                        type=float,
                        default=0.6,
                        help='IOU threshold for NMS')
    parser.add_argument('--fourcc',
                        type=str,
                        default='mp4v',
                        help='output video codec (verify ffmpeg support)')
    parser.add_argument('--half',
                        action='store_true',
                        help='half precision FP16 inference')
    parser.add_argument('--device',
                        default='0',
                        help='device id (i.e. 0 or 0,1) or cpu')
    parser.add_argument('--view-img',
                        action='store_true',
                        help='display results')
    parser.add_argument('--save-txt',
                        action='store_true',
                        help='save results to *.txt')
    parser.add_argument('--classes',
                        nargs='+',
                        type=int,
                        help='filter by class')
    parser.add_argument('--agnostic-nms',
                        action='store_true',
                        help='class-agnostic NMS')
    opt = parser.parse_args()
    # print(opt)
    rclpy.init(args=args)
    # with torch.no_grad():
    node = Recogniser(opt)
    rclpy.spin(node)
    node.destroy_node()
    rclpy.shutdown()
Пример #36
0
def main(args=None):
    rclpy.init(args=args)
    node = MyCustomNode()  # MODIFY NAME
    rclpy.spin(node)
    rclpy.shutdown()
Пример #37
0
def main(args=None):
    rclpy.init(args=args)
    server = Server()
    rclpy.spin(server)
    server.destroy_node()  # destory node explicitly
    rclpy.shutdown()
def main(args=None):
    rclpy.init(args=args)
    drive = Drive()
    rclpy.spin(drive)
Пример #39
0
def main(args=None):
    rclpy.init(args=args)
    node = CommandInput()
    rclpy.spin(node)
    rclpy.shutdown()
Пример #40
0
def main(args=None):
    rclpy.init(args=args)
    follower_node = Follower()
    rclpy.spin(follower_node)
    follower_node.destroy_node()
    rclpy.shutdown()
Пример #41
0
import time
from rclpy.node import Node
from std_msgs.msg import Int16


class ReaderNode(Node):
    def __init__(self):
        super().__init__("Reader")
        self.create_subscription(Int16, "countup", self.cb, 10)

    def cb(self, msg):
        if msg.data == 0:
            self.get_logger().info("One day,someone bet on Hemingway.")
        elif msg.data == 1:
            self.get_logger().info(
                "'If you can make a short story with 6 words,'")
        elif msg.data == 2:
            self.get_logger().info("'And make people cry,It's your victory.'")
        elif msg.data == 3:
            self.get_logger().info("And Hemingway won the bet.")
        elif msg.data == 4:
            self.get_logger().info("This is it...")
        elif msg.data == 5:
            self.get_logger().info("For sale : baby shoes, never worn")
        else:
            sys.exit("done")


rclpy.init()
rclpy.spin(ReaderNode())
Пример #42
0
def main(args=None):
    rclpy.init(args=args)
    profiler = ProfilerNode()
    rclpy.spin(profiler)
Пример #43
0
def main (args=None):
    rclpy.init(args=args)
    node1=my_server()
    rclpy.spin(node1)
    rclpy.shutdown()
Пример #44
0
            print(f'    {len(level.images)} images')
            print(f'    {len(level.places)} places')
            print(f'    {len(level.doors)} doors')
            for door in level.doors:
                self.print_door(door)
            print(f'    {len(level.nav_graphs)} navigation graphs')
            for nav_graph in level.nav_graphs:
                print(f'    graph {nav_graph.name}:')
                print(f'      {len(nav_graph.vertices)} vertices')
                for vertex in nav_graph.vertices:
                    print(f'        ({round(vertex.x, 2)}, ' +
                          f'{round(vertex.y, 2)}, "{vertex.name}")')

                print(f'      {len(nav_graph.edges)} edges')
                for edge in nav_graph.edges:
                    if edge.edge_type == GraphEdge.EDGE_TYPE_BIDIRECTIONAL:
                        arrow = '<=>'
                    else:
                        arrow = '=>'
                    print(f'        {edge.v1_idx} {arrow} {edge.v2_idx}')
        print('\npress Ctrl+C to exit...')


if __name__ == '__main__':
    rclpy.init()
    n = BuildingMapClient()
    try:
        rclpy.spin(n)
    except KeyboardInterrupt:
        pass
Пример #45
0
def main(args=None):
    rclpy.init(args=args)
    node = NumberCounter()

    rclpy.spin(node)
    rclpy.shutdown()