Beispiel #1
0
    if args.debug:
        openravepy.RaveSetDebugLevel(openravepy.DebugLevel.Debug)

    env = openravepy.Environment()
    env.SetViewer('qtcoin')
    env.GetViewer().SetName('Homework 2 Viewer')

    # First setup the environment and the robot
    visualize = args.visualize
    if args.robot == 'herb':
        robot = HerbRobot(env, args.manip)
        planning_env = HerbEnvironment(robot)
        visualize = False
    elif args.robot == 'simple':
        robot = SimpleRobot(env)
        planning_env = SimpleEnvironment(robot)
    else:
        print 'Unknown robot option: %s' % args.robot
        exit(0)

    # Next setup the planner
    if args.planner == 'rrt':
        planner = RRTPlanner(planning_env, visualize=visualize)
    elif args.planner == 'rrtconnect':
        planner = RRTConnectPlanner(planning_env, visualize=visualize)
    else:
        print 'Unknown planner option: %s' % args.planner
        exit(0)

    main(robot, planning_env, planner)
Beispiel #2
0
    robot.irmodel = openravepy.databases.inversereachability.InverseReachabilityModel(
        robot)
    if not robot.irmodel.load():
        print "irmodel didnt' load. "
        robot.irmodel.autogenerate()

    # add a table and move the robot into place
    table = env.ReadKinBodyXMLFile('models/objects/table.kinbody.xml')
    env.Add(table)

    # Create environments for planning the arm and base
    resolution = [args.hres, args.hres, args.tres]
    herb = HerbRobot(env, robot, args.manip)
    arm_env = HerbEnvironment(herb, table, [0.1] * 7)
    herb_base = SimpleRobot(env, robot)
    base_env = SimpleEnvironment(herb_base, table, resolution)

    base_planner = AStarPlanner(base_env, visualize=False)
    arm_planner = AStarPlanner(arm_env, visualize=False)
    # TODO: Here initialize your arm planner

    table_pose = numpy.array([[0, 0, -1, 0.7], [-1, 0, 0, 0], [0, 1, 0, 0],
                              [0, 0, 0, 1]])
    table.SetTransform(table_pose)

    # set a bottle on the table
    bottle = herb.robot.GetEnv().ReadKinBodyXMLFile(
        'models/objects/fuze_bottle.kinbody.xml')
    herb.robot.GetEnv().Add(bottle)
    table_aabb = table.ComputeAABB()
Beispiel #3
0
    robot.SetActiveDOFValues(left_relaxed)

    robot.controller = openravepy.RaveCreateController(robot.GetEnv(), 'IdealController')
     
    # add a table and move the robot into place
    table = env.ReadKinBodyXMLFile('models/objects/table.kinbody.xml')
    env.Add(table)
    
    table_pose = numpy.array([[ 0, 0, -1, 0.7], 
                              [-1, 0,  0, 0], 
                              [ 0, 1,  0, 0], 
                              [ 0, 0,  0, 1]])
    table.SetTransform(table_pose)

    resolution = [0.1, 0.1, numpy.pi/4.]
    herb_base = SimpleRobot(env, robot)
    base_env = SimpleEnvironment(herb_base, resolution)

    # raw_input('Move robot to start config and press enter')
    sid = base_env.discrete_env.ConfigurationToNodeId(herb_base.GetCurrentConfiguration())
    start_config = base_env.discrete_env.NodeIdToConfiguration(sid)
    herb_base.SetCurrentConfiguration(start_config)

    tstart = robot.GetTransform()
    hstart = openravepy.misc.DrawAxes(env, tstart)
    hstart.SetShow(True)
    

    # raw_input('Move robot to goal config and press enter')
    gid = base_env.discrete_env.ConfigurationToNodeId(herb_base.GetCurrentConfiguration())
    goal_config = numpy.array([-0.1,-0.1,0])
Beispiel #4
0
    robot.SetActiveDOFs(left_manip.GetArmIndices())
    robot.SetActiveDOFValues(left_relaxed)

    robot.controller = openravepy.RaveCreateController(robot.GetEnv(),
                                                       'IdealController')

    # add a table and move the robot into place
    table = env.ReadKinBodyXMLFile('models/objects/table.kinbody.xml')
    env.Add(table)

    table_pose = numpy.array([[0, 0, -1, 0.7], [-1, 0, 0, 0], [0, 1, 0, 0],
                              [0, 0, 0, 1]])
    table.SetTransform(table_pose)

    resolution = [0.1, 0.1, numpy.pi / 16.]
    herb_base = SimpleRobot(env, robot)
    base_env = SimpleEnvironment(herb_base, resolution)

    raw_input('Move robot to start config and press enter')
    sid = base_env.discrete_env.ConfigurationToNodeId(
        herb_base.GetCurrentConfiguration())
    start_config = base_env.discrete_env.NodeIdToConfiguration(sid)
    herb_base.SetCurrentConfiguration(start_config)

    tstart = robot.GetTransform()
    hstart = openravepy.misc.DrawAxes(env, tstart)
    hstart.SetShow(True)

    raw_input('Move robot to goal config and press enter')
    gid = base_env.discrete_env.ConfigurationToNodeId(
        herb_base.GetCurrentConfiguration())
Beispiel #5
0
        i = 0
        while i < ORDER_WAIT_TIME:
            remote_order = self.trader.getRemoteOrder(new_order)
            if remote_order is not None:
                self.trader.saveOrder(remote_order)
                if remote_order.status == Order.PARR_COMPLETED or remote_order.status == Order.COMPLETED:
                    logging.info("Sell Order success")
                    return
            time.sleep(1)
            i += 1


        logging.info("Sell Order timeout")
        self.trader.cancelOrderById(new_order.id)

if __name__ == '__main__':
    from SimpleRobot import SimpleRobot
    from pymongo import MongoClient
    from CNBTC_Trader import Trader
    from SimpleStrategy import SimpleStrategy
    from Market import Market
    client = MongoClient("mongodb://115.28.4.59:27017")
    market = Market(client.trans.cnbtc, client.depths.cnbtc, client.trans_stat.cnbtc_min,
                    client.trans_stat.cnbtc_hr, client.trans_stat.cnbtc_index)
    trader = Trader(client.order.cnbtc, client.balance.cnbtc)
    strategy = SimpleStrategy(market)
    robot = SimpleRobot(market, trader, strategy)
    robot.run()

Beispiel #6
0
        i = 0
        while i < ORDER_WAIT_TIME:
            remote_order = self.trader.getRemoteOrder(new_order)
            if remote_order is not None:
                self.trader.saveOrder(remote_order)
                if remote_order.status == Order.PARR_COMPLETED or remote_order.status == Order.COMPLETED:
                    logging.info("Sell Order success")
                    return
            time.sleep(1)
            i += 1

        logging.info("Sell Order timeout")
        self.trader.cancelOrderById(new_order.id)


if __name__ == '__main__':
    from SimpleRobot import SimpleRobot
    from pymongo import MongoClient
    from CNBTC_Trader import Trader
    from SimpleStrategy import SimpleStrategy
    from Market import Market
    client = MongoClient("mongodb://115.28.4.59:27017")
    market = Market(client.trans.cnbtc, client.depths.cnbtc,
                    client.trans_stat.cnbtc_min, client.trans_stat.cnbtc_hr,
                    client.trans_stat.cnbtc_index)
    trader = Trader(client.order.cnbtc, client.balance.cnbtc)
    strategy = SimpleStrategy(market)
    robot = SimpleRobot(market, trader, strategy)
    robot.run()