本文整理汇总了Python中simulator.Simulator.set_stop_when_colliding方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.set_stop_when_colliding方法的具体用法?Python Simulator.set_stop_when_colliding怎么用?Python Simulator.set_stop_when_colliding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.set_stop_when_colliding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import set_stop_when_colliding [as 别名]
#.........这里部分代码省略.........
""" The observation error covariance matrix """
N = self.calc_covariance_value(self.robot,
self.min_observation_covariance,
N_base,
covariance_type='observation')
elif self.inc_covariance == "observation":
M = self.calc_covariance_value(self.robot,
self.min_process_covariance,
M_base)
N = self.calc_covariance_value(self.robot,
m_covs[j],
N_base,
covariance_type='observation')
P_t = np.array([[0.0 for k in xrange(2 * self.robot_dof)] for l in xrange(2 * self.robot_dof)])
path_planner.setup_path_evaluator(A, B, C, D, H, M, N, V, W,
self.robot,
self.sample_size,
self.obstacles,
self.goal_position,
self.goal_radius,
self.robot_file,
self.environment_file)
sim.setup_problem(A, B, C, D, H, V, W, M, N,
self.robot,
self.enforce_control_constraints,
self.obstacles,
self.goal_position,
self.goal_radius,
self.max_velocity,
self.show_viewer_simulation,
self.robot_file,
self.environment_file)
sim.set_stop_when_colliding(self.replan_when_colliding)
if self.dynamic_problem:
path_evaluator.setup_dynamic_problem()
sim.setup_dynamic_problem(self.simulation_step_size)
path_planner.setup_reward_function(self.step_penalty, self.exit_reward, self.illegal_move_penalty, self.discount_factor)
mean_number_planning_steps = 0.0
number_of_steps = 0.0
mean_planning_time = 0.0
num_generated_paths_run = 0.0
successful_runs = 0
num_collisions = 0.0
final_states= []
rewards_cov = []
for k in xrange(self.num_simulation_runs):
print "MPC: Run " + str(k + 1)
self.serializer.write_line("log.log", tmp_dir, "RUN #" + str(k + 1) + " \n")
current_step = 0
x_true = self.start_state
x_estimate = self.start_state
x_tilde_linear = np.array([0.0 for i in xrange(2 * self.robot_dof)])
P_t = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
deviation_covariance = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
estimated_deviation_covariance = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
total_reward = 0.0
terminal = False
while current_step < self.max_num_steps and not terminal:
path_planner.set_start_and_goal(x_estimate, goal_states, self.goal_position, self.goal_radius)
t0 = time.time()
(xs,
us,
zs,
control_durations,
num_generated_paths,
示例2: __init__
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import set_stop_when_colliding [as 别名]
#.........这里部分代码省略.........
self.enforce_control_constraints,
self.obstacles,
self.goal_position,
self.goal_radius,
self.max_velocity,
self.show_viewer_simulation,
self.robot_file,
self.environment_file,
self.knows_collision)
path_evaluator.setup(A, B, C, D, H, M, N, V, W,
self.robot,
self.sample_size,
self.obstacles,
self.goal_position,
self.goal_radius,
self.show_viewer_evaluation,
self.robot_file,
self.environment_file,
self.num_cores)
path_evaluator.setup_reward_function(self.step_penalty, self.illegal_move_penalty, self.exit_reward, self.discount_factor)
plan_adjuster.setup(self.robot,
M,
H,
W,
N,
C,
D,
self.dynamic_problem,
self.enforce_control_constraints)
plan_adjuster.set_simulation_step_size(self.simulation_step_size)
plan_adjuster.set_model_matrices(A, B, V)
if not self.dynamic_problem:
plan_adjuster.set_max_joint_velocities_linear_problem(np.array([self.max_velocity for i in xrange(self.robot_dof)]))
sim.set_stop_when_colliding(self.replan_when_colliding)
if self.dynamic_problem:
path_evaluator.setup_dynamic_problem()
sim.setup_dynamic_problem(self.simulation_step_size)
path_planner.setup_reward_function(self.step_penalty, self.exit_reward, self.illegal_move_penalty, self.discount_factor)
mean_number_planning_steps = 0.0
number_of_steps = 0.0
mean_planning_time = 0.0
num_generated_paths_run = 0.0
successful_runs = 0
num_collisions = 0.0
linearization_error = 0.0
final_states= []
rewards_cov = []
for k in xrange(self.num_simulation_runs):
print "HRF: Run " + str(k + 1)
self.serializer.write_line("log.log", tmp_dir, "RUN #" + str(k + 1) + " \n")
current_step = 0
x_true = np.array([self.start_state[m] for m in xrange(len(self.start_state))])
x_estimated = np.array([self.start_state[m] for m in xrange(len(self.start_state))])
#x_estimated[0] += 0.2
#x_estimated[0] = 0.4
#x_predicted = self.start_state
P_t = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
P_ext_t = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
deviation_covariance = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
estimated_deviation_covariance = np.array([[0.0 for i in xrange(2 * self.robot_dof)] for i in xrange(2 * self.robot_dof)])
total_reward = 0.0
terminal = False
last_x_true = None
"""
Obtain a nominal path