def test_unibox(): """Test that uniformized sim produce coherent results""" check = True cfg_ = cfg.copy(deep = True) cfg_.motor = 'commonvelocity' box = boxsim.UniformizeSim(boxsim.BoxSim(cfg_)) try: order = [0.5] * 12 + [0.0] toy_pos = box.execute_order(order) check *= toy_pos[2] == 0.0 for _ in range(20): order = [random.random() for _ in range(13)] pos = box.execute_order(order) if pos[2] == 0.0: check *= toy_pos == pos if pos[:2] == toy_pos[:2]: check *= toy_pos[2] == pos[2] check *= all(0 <= pos_i <= 1 for pos_i in pos) except Exception as e: traceback.print_exc() check = False box.close() return check
import testenv import random from common import cfg import boxsim cfg.visu = False cfg.debug = False cfg.verbose = True box = boxsim.UniformizeSim(boxsim.BoxSim(cfg)) try: for _ in range(100): order = [random.uniform(0.0, 1.0) for _ in range(13)] print box.execute_order(order) except Exception as e: print e box.close()
import testenv import random import boxsim from common import cfg cfg.motors = 'fullmotor' box = boxsim.BoxSim(cfg) #order = [random.uniform(bi_min, bi_max) for (bi_min, bi_max) in box.m_bounds] order = 6 * [0.0] + 6 * [0.2] + [1.0, 0.8, 0.6, 0.4, 0.2, 0.0] print box.execute_order(order) box.close()