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


Python Scenario_Generator.find_man_traj方法代码示例

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


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

示例1: find_qualitative_path_extended

# 需要导入模块: from scenario_generator import Scenario_Generator [as 别名]
# 或者: from scenario_generator.Scenario_Generator import find_man_traj [as 别名]
    def find_qualitative_path_extended(self, velocity, zones, man_obj_id):

        scenario = Scenario_Generator(self.width, self.height, self.immobile_objs, self.mobile_objs, self.manipulatable_obj, self.target_obj, showRender=False)
        scenario.current_man_id = man_obj_id
        scenario.apply_velocity_and_run(*velocity)
        traj = scenario.find_man_traj()
        b2contacts = scenario.find_contacts_with_mobile_objs()

        initial_zone = -1
        pre_zone = initial_zone
        path = [initial_zone]
        for traj_pt in traj:
            occupied_zone = -1

            man_position = Point(traj_pt)
            for i in xrange(len(zones)):
                if zones[i].contains(man_position):
                    occupied_zone = i
                    break

            # if out of scope, still wait to see if it will come back, quite slow
            if occupied_zone == -1 or occupied_zone == pre_zone:
                continue

            path.append(occupied_zone)
            pre_zone = occupied_zone
        return path, b2contacts
开发者ID:fantastdd,项目名称:physical-reasoning-2d,代码行数:29,代码来源:increment_solver.py

示例2: find_qualitative_path_ptlike

# 需要导入模块: from scenario_generator import Scenario_Generator [as 别名]
# 或者: from scenario_generator.Scenario_Generator import find_man_traj [as 别名]
    def find_qualitative_path_ptlike(self, action, zones, initial_zone):
        scenario = Scenario_Generator(self.width, self.height, self.immobile_objs, self.mobile_objs, self.manipulatable_obj, self.target_obj, showRender=False)
        scenario.apply_impulse_and_run(action)
        traj = scenario.find_man_traj()
        b2contacts = scenario.find_contacts_with_mobile_objs()
        #print contacts
        pre_zone = initial_zone        
        path = [initial_zone]

        for traj_pt in traj:
            occupied_zone = -1
            man_position = Point(traj_pt)
            for i in xrange(len(zones)):
                if zones[i].contains(man_position):
                    occupied_zone = i
                    break
            # if out of scope, still wait to see if it will come back, quite slow
            if occupied_zone == -1 or occupied_zone == pre_zone:
                continue

            '''

            if occupied_zone == -1:
                # reach end zone
                path.append(-1)
                break

            elif occupied_zone == pre_zone:
                continue
            '''
            path.append(occupied_zone)
            pre_zone = occupied_zone

        return path, b2contacts
开发者ID:fantastdd,项目名称:physical-reasoning-2d,代码行数:36,代码来源:increment_solver.py

示例3: find_qualitative_path_rich

# 需要导入模块: from scenario_generator import Scenario_Generator [as 别名]
# 或者: from scenario_generator.Scenario_Generator import find_man_traj [as 别名]
    def find_qualitative_path_rich(self, action, zones, initial_zone):
        scenario = Scenario_Generator(self.width, self.height, self.immobile_objs, self.mobile_objs, self.manipulatable_obj, self.target_obj, showRender=False)
        scenario.apply_impulse_and_run(action)
        traj = scenario.find_man_traj()
        num_zones = len(zones)
        initial_time, x,y, touching = traj[0]
        # ball must touch the surface
        last_touching_time = initial_time # beginning of the last touching
        last_state_time = initial_time
        last_touching_state = True # False: not touched, True, touched
        pre_zone = initial_zone
        last_motion_type = 0
        quali_path = ''
        for traj_pt in traj:
            time, x, y, touching = traj_pt
            man_position = Point(x,y)

            for i in xrange(num_zones):
                if zones[i].contains(man_position):
                    occupied_zone = i
                    break

            if occupied_zone == pre_zone:
                if last_touching_state == touching:
                    continue
                else:
                    # previously touch, currently not
                    if last_touching_state: 
                        time_duration = time - last_touching_time
                        if time_duration > 30: #SLIDING
                            motion_type = 4
                           
                        else:
                            motion_type = 8 # BOUCING                           
                        
                    else:
                        motion_type = 2 # FLYING                    
                        last_touching_time = time

                    last_motion_type = last_motion_type | motion_type                    
                    last_motion_type = motion_type
                    last_touching_state = touching

            else:
                if time - last_state_time < 10:
                    continue
                if last_motion_type == 0:
                    if last_touching_state:
                        time_duration = time - last_touching_time
                        if time_duration > 30:
                            last_motion_type = 4
                        else:
                            last_motion_type = 8
                    else:
                        last_motion_type = 2


                quali_path = quali_path + str(pre_zone) + "*" +str(last_motion_type) + ","
                last_touching_state = touching
                pre_zone = occupied_zone
                last_state_time = time
                last_motion_type = 0
                if touching:
                    last_touching_time = time   


        return quali_path
开发者ID:fantastdd,项目名称:physical-reasoning-2d,代码行数:69,代码来源:increment_solver_qsim_rich.py


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