当前位置: 首页>>代码示例>>Python>>正文


Python History.clear方法代码示例

本文整理汇总了Python中history.History.clear方法的典型用法代码示例。如果您正苦于以下问题:Python History.clear方法的具体用法?Python History.clear怎么用?Python History.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在history.History的用法示例。


在下文中一共展示了History.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Simulation

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import clear [as 别名]
class Simulation(object):
    def __init__(self):
        self.show_impulse = False
        # self.name = 'GP_--N_handfree_naive_clean'
        # self.name = 'Atlas_##_--N_naive_clean'
        self.name = 'Atlas_##--N'
        # self.name = 'BioloidGP_--N'
        # self.name = 'BioloidGP_--N_from_one_foot'

        # Init api
        pydart.init()
        self.world = pydart.create_world(1.0 / 2000.0)
        self.world.add_skeleton(config.DATA_PATH + "sdf/ground.urdf",
                                control=False)
        if 'GP' in self.name:
            self.world.add_skeleton(config.DATA_PATH +
                                    "urdf/BioloidGP/BioloidGP.URDF")
            self.world.skel.set_joint_damping(0.15)
        # self.world.add_skeleton(config.DATA_PATH +
        #                         "urdf/atlas/atlas_v3_no_head.urdf")
        else:
            self.world.add_skeleton(config.DATA_PATH +
                                    "urdf/atlas/atlas_v3_no_head.urdf")
            self.world.skel.set_joint_damping(0.15)

        self.skel = self.world.skel  # shortcut for the control skeleton

        for i, dof in enumerate(self.skel.dofs):
            print i, dof, 'efforts:', self.skel.tau_lo[i], self.skel.tau_hi[i]

        # Configure the scene
        self.cfg = scene.configure.Configure(self)
        self.name = self.name.replace('--', '%.1f' % self.cfg.f_mag)
        if '##' in self.name and self.cfg.tag is not None:
            self.name = self.name.replace('##', self.cfg.tag)

        self.prob = problem.Problem(self, self.cfg.name)
        self.history = History(self)
        self.impulse_live_renderer = ImpulseLiveRenderer(self)

        # # ### Now, configure the controllers
        self.tip_controller = model.controller.Controller(self.skel, self.prob)
        self.tip_controller.pd.set_pd_params(self.name)
        self.event_handler = events.Handler()

        # Reset to the initial state
        self.reset()

        print 'skel.m = ', self.skel.m
        print 'skel.approx_inertia_x = ', self.skel.approx_inertia_x()
        print 'skel.q = ', self.skel.q

        self.rc = scene.range_checker.RangeChecker(self)
        self.rc.check_all()

        # Abstract model
        self.abstract_tip = abstract.dynamic.DynamicTIP(self.prob, self.rc)

        # For handle callbacks properly..
        self.history.clear()
        self.history.push()

    def is_bioloid(self):
        return ("BioloidGP" in self.skel.filename)

    @property
    def tip(self):
        return self.tip_controller.tip()

    def do_plan(self):
        # return self.do_ik()  # Just testing IK

        # Plan with Dynamic TIP
        self.abstract_tip.set_x0(self.tip_controller.tips)
        self.abstract_tip.plan_initial()
        # cProfile.runctx('self.abstract_tip.plan_initial()',
        #                 globals(), locals())
        x0 = self.abstract_tip.x0
        path = self.abstract_tip.path

        print 'self.x0 = ', str(x0)
        print 'self.path = ', str(path)
        # print 'sleep 5 seconds'
        # time.sleep(5)
        self.plan = abstract.plan.Plan(x0, path)
        self.plan.names = self.prob.contact_names()
        print 'new plan is generated'
        self.tip_controller = model.controller.Controller(self.skel,
                                                          self.prob,
                                                          self.plan)
        self.tip_controller.pd.set_pd_params(self.name)
        print 'new tip controller is generated'
        self.do_ik()
        self.name = self.name.replace('_naive', '')

    def do_ik(self):
        # self.plan.plot()

        # self.ik = IKMulti(self, self.plan)
        self.ik = ik.IKJac(self, self.plan)
#.........这里部分代码省略.........
开发者ID:sehoonha,项目名称:pydart_private,代码行数:103,代码来源:simulation.py


注:本文中的history.History.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。