Exemplo n.º 1
0
def main():
    with rosenv.RosEnv() as re:
        re.add_package("com_github_robotwebtools_rosbridge_suite/rosapi")
        re.add_package(
            "com_github_robotwebtools_rosbridge_suite/rosbridge_server")
        re.add_package("com_github_robotwebtools_tf2_web_republisher",
                       "tf2_web_republisher")
        re.add_package("com_github_ros_common_msgs/actionlib_msgs")
        re.add_package("com_github_ros_common_msgs/nav_msgs")
        re.add_package("com_github_ros_common_msgs/sensor_msgs")
        re.add_package(
            "com_github_ros_planning_navigation_msgs/move_base_msgs")
        re.add_package("com_github_ros_ros_comm/tools/rosgraph")
        re.add_package("com_github_ros_ros_comm/tools/roslaunch")
        re.add_package("com_github_ros_ros_comm/tools/rosnode")
        re.add_to_path("com_github_ros_catkin")
        re.add_to_path("com_github_ros_infrastructure_rospkg")
        re.add_binary("com_github_robotwebtools_rosbridge_suite/rosapi_node",
                      "rosapi")
        re.add_binary(
            "com_github_robotwebtools_rosbridge_suite/rosbridge_websocket",
            "rosbridge_server")

        launch = os.path.join(
            re.runfiles,
            "cloud_robotics/src/docker/ros_websocket/websocket.launch")

        import roslaunch
        roslaunch.main(["roslaunch", "--wait", launch])
Exemplo n.º 2
0
def main():
    with rosenv.RosEnv() as re:
        re.add_package("com_github_ros_ros_comm/tools/rosgraph")
        re.add_package("com_github_ros_ros_comm/tools/roslaunch")
        re.add_package("com_github_ros_ros_comm/tools/rosout")
        re.add_binary("com_github_ros_ros_comm/rosout", "rosout")
        re.add_to_path("com_github_ros_infrastructure_rospkg")
        re.add_to_path("com_github_ros_ros_comm")

        import roslaunch
        roslaunch.main(["roscore", "--core"] + sys.argv[1:])
Exemplo n.º 3
0
def start(launch_obj, dry_run=False, silent=False):
    """
    Generates a temporary roslaunch XML file from the given roslaunch2 Launch instance and passes it over to roslaunch.
    Returns after roslaunch has terminated and temporary files have been removed.

    :param launch_obj: Instance of class launch.Launch
    :param dry_run: If Only print generated XML (default: False)
    :param silent: Hide roslaunch output
    """
    if silent:
        import sys
        import os
        sys.stdout = open(os.devnull, 'w')

    # Test if launch module correctly defines its main() function:
    if not isinstance(launch_obj, Launch):
        critical(
            "Your launch module's main() function must return an instance of roslaunch2.launch.Launch in order to "
            "be compatible with roslaunch2.  Please fix your launch module code."
        )
        return

    content = launch_obj.generate()
    if not dry_run:
        import tempfile
        import roslaunch  # dry-run even works w/o ROS
        ftmp = tempfile.NamedTemporaryFile(mode='w',
                                           suffix='.launch',
                                           delete=False)
        ftmp.write(content)
        ftmp.close(
        )  # close it so that roslaunch can open it (file still exists)
        # noinspection PyBroadException
        try:
            on_initialize.fire()
            roslaunch.main(_strip_args(ftmp.name))  # actually do the launch!
        except Exception:
            pass
        utils.silent_remove(ftmp.name)
    else:
        print(content)
    on_terminate.fire()
    # Delete created (temporary) env-loader script files:
    Machine.cleanup()
Exemplo n.º 4
0
    def ros_core_process(self):
        logger_inner = get_logger('ros_manager_inner')
        logger_inner.info('begin ros core')
        try:
            while True:
                while True:
                    time.sleep(3)
                    status, result = getipaddr()
                    logger_inner.info('get ip :' + str(result))
                    if status:
                        logger_inner.info('host ip is init!')
                        break
                    else:
                        print('wait for ip init!!')
                        logger_inner.warning('wait for ip init!!')

                if not get_ros_core():
                    logger_inner.info('start ros core')
                    try:
                        roslaunch.main(['roscore', '--core'])
                        while True:
                            time.sleep(1)
                    except Exception as e:
                        print('I am except ' + str(e))
                        logger_inner.fatal(str(e))
                        continue

                    finally:
                        logger_inner.fatal('I am finally')
                        time.sleep(1)

                else:
                    logger_inner.warning('ros core is exist , skip!')
                    print('ros core is exist , skip!')
                    break
        except Exception as e:
            print('something error ' + str(e))
            logger_inner.fatal('something error ' + str(e))
Exemplo n.º 5
0
            print "Error reading motor controller board version from i2c"

    extrinsics_file = '~/.ros/camera_info/extrinsics_%s.yaml' % conf[
        'raspicam']['position']
    extrinsics_file = os.path.expanduser(extrinsics_file)
    if not os.path.isfile(extrinsics_file):
        extrinsics_file = '-'

    controller = conf['motor_controller']  # make it easier to access elements
    # Ugly, but works
    # just passing argv doesn't work with launch arguments, so we assign sys.argv
    sys.argv = [
        "roslaunch", "magni_bringup", "core.launch",
        "raspicam_mount:=%s" % conf['raspicam']['position'],
        "sonars_installed:=%s" % conf['sonars'],
        "controller_board_version:=%d" % boardRev,
        "camera_extrinsics_file:=%s" % extrinsics_file,
        "controller_serial_port:=%s" % controller['serial_port'],
        "controller_serial_baud:=%s" % controller['serial_baud'],
        "controller_pid_proportional:=%s" % controller['pid_proportional'],
        "controller_pid_integral:=%s" % controller['pid_integral'],
        "controller_pid_derivative:=%s" % controller['pid_derivative'],
        "controller_pid_denominator:=%s" % controller['pid_denominator'],
        "controller_pid_moving_buffer_size:=%s" %
        controller['pid_moving_buffer_size'],
        "controller_pid_velocity:=%s" % controller['pid_velocity'],
        "oled_display:=%s" % oled_display_installed
    ]

    roslaunch.main(sys.argv)
Exemplo n.º 6
0
                      metavar="PORT")
    parser.add_option("-v",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose printing")
    parser.add_option("-w",
                      "--numworkers",
                      dest="num_workers",
                      default=NUM_WORKERS,
                      type=int,
                      help="override number of worker threads",
                      metavar="NUM_WORKERS")
    parser.add_option(
        "-t",
        "--timeout",
        dest="timeout",
        help="override the socket connection timeout (in seconds).",
        metavar="TIMEOUT")
    return parser


parser = _get_optparse()
(options, args) = parser.parse_args(sys.argv[1:])

if len(args) > 0:
    parser.error("roscore does not take arguments")

import roslaunch
roslaunch.main(['roscore', '--core'] + sys.argv[1:])
Exemplo n.º 7
0
 def ros_core_launch():
     roslaunch.main(['roscore',
                     '--core'])  # same as rostest_main implementation
Exemplo n.º 8
0
                    if filename.endswith('.bag') and not filename.endswith('.orig.bag'):
                        bag_file = os.path.abspath(os.path.join(bag_dir, filename))
                        for det, desc in d_list:
                            printstr = "Detector+Descriptor {}+{}".format(det, desc)
                            print ''
                            print '-' * len(printstr)
                            print printstr
                            print '-' * len(printstr)
                            print ''
                            if desc.endswith('+LR'):
                                desc = desc.split('+')[0]
                                sys.argv = ['roslaunch', 'omni_slam_eval', 'matching_eval.launch', 'bag_file:={}'.format(bag_file), 'camera_file:={}'.format(fov_file), 'detector_type:={}'.format(det), 'descriptor_type:={}'.format(desc), 'detector_params:={}'.format(det_param_map[det]), 'rate:={}'.format(args.rate), 'local_unwarping:=true']
                            else:
                                sys.argv = ['roslaunch', 'omni_slam_eval', 'matching_eval.launch', 'bag_file:={}'.format(bag_file), 'camera_file:={}'.format(fov_file), 'detector_type:={}'.format(det), 'descriptor_type:={}'.format(desc), 'detector_params:={}'.format(det_param_map[det]), 'rate:={}'.format(args.rate)]
                            reload(roslaunch)
                            roslaunch.main()
else:
    print ''
    print '=================================================='
    print 'Single run detector+descriptor matching evaluation'
    print '=================================================='
    bag_dir = os.path.abspath(args.working_dir)
    for det, desc in d_list:
        printstr = "Detector+Descriptor {}+{}".format(det, desc)
        print ''
        print '-' * len(printstr)
        print printstr
        print '-' * len(printstr)
        print ''
        sys.argv = ['roslaunch', 'omni_slam_eval', 'matching_eval.launch', 'bag_file:={}'.format(bag_dir), 'detector_type:={}'.format(det), 'descriptor_type:={}'.format(desc), 'detector_params:={}'.format(det_param_map[det]), 'rate:={}'.format(args.rate)]
        if args.camera_file is not None:
Exemplo n.º 9
0
import roslaunch
roslaunch.main(['roslaunch','--core'])
Exemplo n.º 10
0
def go():

    roslaunch.main(['roslaunch','--core'])
Exemplo n.º 11
0
AttributeError: 'module' object has no attribute 'setsid'
The Python REPL process has exited

No handlers could be found for logger "roslaunch"
Roslaunch got a 'The system cannot find the file specified' error while attempting to run:

rosmaster --core -p 11311 __log:=c:\ROS\log\e5670e0f-7cd6-11e5-8c31-003ee1c5c62d\master.log

Please make sure that all the executables in this command exist and have
executable permission. This is often caused by a bad launch-prefix.
The traceback for the exception was written to the log file
The Python REPL process has exited

#go time:
import roslaunch
roslaunch.main(['roslaunch','--core'])


#testing failure
import rospkg
import os
import roslib
rospack = rospkg.RosPack(rospkg.get_ros_paths(env=os.environ))
matches = roslib.packages.find_node('rosout','rosout', rospack)



#('process[%s]: start w/ args [%s]', 'master', ['rosmaster', '--core', '-p', '11311', '__log:=c:\\ros\\home\\log\\9c890ec0-7cde-11e5-93d1-003ee1c5c62d\\master.log'])
#('process[%s]: cwd will be [%s]', 'master', 'c:\\ros\\home')
#def rosmaster_main(argv=sys.argv, stdout=sys.stdout, env=os.environ):
#rosmaster --core -p 11311 __log:=c:\ROS\log\e5670e0f-7cd6-11e5-8c31-003ee1c5c62d\master.log
Exemplo n.º 12
0
#!/usr/bin/python

###
# Eventually this should do something smarter, like launch sonars
# 3DTOF, etc, if they are installed.
###

import roslaunch
roslaunch.main(argv=["roslaunch", "magni_bringup", "core.launch"])
Exemplo n.º 13
0
#!/usr/bin/env python3

import roslaunch
import rospy

from cym_gazebo import gen_launch_element_tree

import os
import sys
import tempfile
import yaml


argv = rospy.myargv(argv=sys.argv)
cfg_yml = argv[1]

with open(cfg_yml, 'r') as f:
    cfg = yaml.safe_load(f)
    launch_xml_tree = gen_launch_element_tree(cfg)

# Create a temporary launch file and launch using roslaunch
_, path = tempfile.mkstemp()
try:
    launch_xml_tree.write(path)

    roslaunch.main(argv=[argv[0], path])
finally:
    os.remove(path)