code
stringlengths
17
6.64M
def get_time(): '\n Returns the value of the GLFW timer.\n\n Wrapper for:\n double glfwGetTime(void);\n ' return _glfw.glfwGetTime()
def set_time(time): '\n Sets the GLFW timer.\n\n Wrapper for:\n void glfwSetTime(double time);\n ' _glfw.glfwSetTime(time)
def make_context_current(window): '\n Makes the context of the specified window current for the calling\n thread.\n\n Wrapper for:\n void glfwMakeContextCurrent(GLFWwindow* window);\n ' _glfw.glfwMakeContextCurrent(window)
def get_current_context(): '\n Returns the window whose context is current on the calling thread.\n\n Wrapper for:\n GLFWwindow* glfwGetCurrentContext(void);\n ' return _glfw.glfwGetCurrentContext()
def swap_buffers(window): '\n Swaps the front and back buffers of the specified window.\n\n Wrapper for:\n void glfwSwapBuffers(GLFWwindow* window);\n ' _glfw.glfwSwapBuffers(window)
def swap_interval(interval): '\n Sets the swap interval for the current context.\n\n Wrapper for:\n void glfwSwapInterval(int interval);\n ' _glfw.glfwSwapInterval(interval)
def extension_supported(extension): '\n Returns whether the specified extension is available.\n\n Wrapper for:\n int glfwExtensionSupported(const char* extension);\n ' return _glfw.glfwExtensionSupported(_to_char_p(extension))
def get_proc_address(procname): '\n Returns the address of the specified function for the current\n context.\n\n Wrapper for:\n GLFWglproc glfwGetProcAddress(const char* procname);\n ' return _glfw.glfwGetProcAddress(_to_char_p(procname))
def append_objects(cur, extra): for i in range(cur.ngeom, (cur.ngeom + extra.ngeom)): cur.geoms[i] = extra.geoms[(i - cur.ngeom)] cur.ngeom = (cur.ngeom + extra.ngeom) if (cur.ngeom > cur.maxgeom): raise ValueError('buffer limit exceeded!')
class MJCONTACT(Structure): _fields_ = [('dist', c_double), ('pos', (c_double * 3)), ('frame', (c_double * 9)), ('includemargin', c_double), ('friction', (c_double * 5)), ('solref', (c_double * 2)), ('solimp', (c_double * 3)), ('mu', c_double), ('coef', (c_double * 5)), ('zone', c_int), ('dim', c_int), ('geom1', c_int), ('geom2', c_int), ('exclude', c_int), ('efc_address', c_int)]
class MJRRECT(Structure): _fields_ = [('left', c_int), ('bottom', c_int), ('width', c_int), ('height', c_int)]
class MJVCAMERAPOSE(Structure): _fields_ = [('head_pos', (c_double * 3)), ('head_right', (c_double * 3)), ('window_pos', (c_double * 3)), ('window_right', (c_double * 3)), ('window_up', (c_double * 3)), ('window_normal', (c_double * 3)), ('window_size', (c_double * 2)), ('scale', c_double), ('ipd', c_double)]
class MJROPTION(Structure): _fields_ = [('stereo', c_ubyte), ('flags', (c_ubyte * 6))]
class MJRCONTEXT(Structure): _fields_ = [('linewidth', c_float), ('znear', c_float), ('zfar', c_float), ('shadowclip', c_float), ('shadowscale', c_float), ('shadowsize', c_int), ('offwidth', c_uint), ('offheight', c_uint), ('offFBO', c_uint), ('offColor', c_uint), ('offDepthStencil', c_uint), ('shadowFBO', c_uint), ('shadowTex', c_uint), ('ntexture', c_uint), ('texture', (c_int * 100)), ('textureType', (c_int * 100)), ('basePlane', c_uint), ('baseMesh', c_uint), ('baseHField', c_uint), ('baseBuiltin', c_uint), ('baseFontNormal', c_uint), ('baseFontBack', c_uint), ('baseFontBig', c_uint), ('rangePlane', c_int), ('rangeMesh', c_int), ('rangeHField', c_int), ('rangeBuiltin', c_int), ('rangeFont', c_int), ('charWidth', (c_int * 127)), ('charWidthBig', (c_int * 127)), ('charHeight', c_int), ('charHeightBig', c_int), ('glewInitialized', c_int)]
class MJVCAMERA(Structure): _fields_ = [('fovy', c_double), ('camid', c_int), ('trackbodyid', c_int), ('lookat', (c_double * 3)), ('azimuth', c_double), ('elevation', c_double), ('distance', c_double), ('pose', MJVCAMERAPOSE), ('VR', c_ubyte)]
class MJVOPTION(Structure): _fields_ = [('label', c_int), ('frame', c_int), ('geomgroup', (c_ubyte * 5)), ('sitegroup', (c_ubyte * 5)), ('flags', (c_ubyte * 18))]
class MJVGEOM(Structure): _fields_ = [('type', c_int), ('dataid', c_int), ('objtype', c_int), ('objid', c_int), ('category', c_int), ('texid', c_int), ('texuniform', c_int), ('texrepeat', (c_float * 2)), ('size', (c_float * 3)), ('pos', (c_float * 3)), ('mat', (c_float * 9)), ('rgba', (c_float * 4)), ('emission', c_float), ('specular', c_float), ('shininess', c_float), ('reflectance', c_float), ('label', (c_char * 100)), ('camdist', c_float), ('rbound', c_float), ('transparent', c_ubyte)]
class MJVLIGHT(Structure): _fields_ = [('pos', (c_float * 3)), ('dir', (c_float * 3)), ('attenuation', (c_float * 3)), ('cutoff', c_float), ('exponent', c_float), ('ambient', (c_float * 3)), ('diffuse', (c_float * 3)), ('specular', (c_float * 3)), ('headlight', c_ubyte), ('directional', c_ubyte), ('castshadow', c_ubyte)]
class MJVOBJECTS(Structure): _fields_ = [('nlight', c_int), ('ngeom', c_int), ('maxgeom', c_int), ('lights', (MJVLIGHT * 8)), ('geoms', POINTER(MJVGEOM)), ('geomorder', POINTER(c_int))]
class MJOPTION(Structure): _fields_ = [('timestep', c_double), ('apirate', c_double), ('tolerance', c_double), ('impratio', c_double), ('gravity', (c_double * 3)), ('wind', (c_double * 3)), ('magnetic', (c_double * 3)), ('density', c_double), ('viscosity', c_double), ('o_margin', c_double), ('o_solref', (c_double * 2)), ('o_solimp', (c_double * 3)), ('mpr_tolerance', c_double), ('mpr_iterations', c_int), ('integrator', c_int), ('collision', c_int), ('impedance', c_int), ('reference', c_int), ('solver', c_int), ('iterations', c_int), ('disableflags', c_int), ('enableflags', c_int)]
class MJVISUAL(Structure): class ANON_GLOBAL(Structure): _fields_ = [('fovy', c_float), ('ipd', c_float), ('linewidth', c_float), ('glow', c_float), ('offwidth', c_int), ('offheight', c_int)] class ANON_QUALITY(Structure): _fields_ = [('shadowsize', c_int), ('numSlices', c_int), ('numStacks', c_int), ('numArrows', c_int), ('numQuads', c_int)] class ANON_HEADLIGHT(Structure): _fields_ = [('ambient', (c_float * 3)), ('diffuse', (c_float * 3)), ('specular', (c_float * 3)), ('active', c_int)] class ANON_MAP(Structure): _fields_ = [('stiffness', c_float), ('force', c_float), ('torque', c_float), ('alpha', c_float), ('fogstart', c_float), ('fogend', c_float), ('znear', c_float), ('zfar', c_float), ('shadowclip', c_float), ('shadowscale', c_float)] class ANON_SCALE(Structure): _fields_ = [('forcewidth', c_float), ('contactwidth', c_float), ('contactheight', c_float), ('connect', c_float), ('com', c_float), ('camera', c_float), ('light', c_float), ('selectpoint', c_float), ('jointlength', c_float), ('jointwidth', c_float), ('actuatorlength', c_float), ('actuatorwidth', c_float), ('framelength', c_float), ('framewidth', c_float), ('constraint', c_float), ('slidercrank', c_float)] class ANON_RGBA(Structure): _fields_ = [('fog', (c_float * 4)), ('force', (c_float * 4)), ('inertia', (c_float * 4)), ('joint', (c_float * 4)), ('actuator', (c_float * 4)), ('com', (c_float * 4)), ('camera', (c_float * 4)), ('light', (c_float * 4)), ('selectpoint', (c_float * 4)), ('connect', (c_float * 4)), ('contactpoint', (c_float * 4)), ('contactforce', (c_float * 4)), ('contactfriction', (c_float * 4)), ('contacttorque', (c_float * 4)), ('constraint', (c_float * 4)), ('slidercrank', (c_float * 4)), ('crankbroken', (c_float * 4))] _fields_ = [('global_', ANON_GLOBAL), ('quality', ANON_QUALITY), ('headlight', ANON_HEADLIGHT), ('map_', ANON_MAP), ('scale', ANON_SCALE), ('rgba', ANON_RGBA)]
class MJSTATISTIC(Structure): _fields_ = [('meanmass', c_double), ('meansize', c_double), ('extent', c_double), ('center', (c_double * 3))]
class MJDATA(Structure): _fields_ = [('nstack', c_int), ('nbuffer', c_int), ('pstack', c_int), ('maxstackuse', c_int), ('ne', c_int), ('nf', c_int), ('nefc', c_int), ('ncon', c_int), ('nwarning', (c_int * 8)), ('warning_info', (c_int * 8)), ('timer_duration', (c_double * 14)), ('timer_ncall', (c_double * 14)), ('mocaptime', (c_double * 3)), ('time', c_double), ('energy', (c_double * 2)), ('solverstat', (c_double * 4)), ('solvertrace', (c_double * 200)), ('buffer', POINTER(c_ubyte)), ('stack', POINTER(c_double)), ('qpos', POINTER(c_double)), ('qvel', POINTER(c_double)), ('act', POINTER(c_double)), ('ctrl', POINTER(c_double)), ('qfrc_applied', POINTER(c_double)), ('xfrc_applied', POINTER(c_double)), ('qacc', POINTER(c_double)), ('act_dot', POINTER(c_double)), ('mocap_pos', POINTER(c_double)), ('mocap_quat', POINTER(c_double)), ('userdata', POINTER(c_double)), ('sensordata', POINTER(c_double)), ('xpos', POINTER(c_double)), ('xquat', POINTER(c_double)), ('xmat', POINTER(c_double)), ('xipos', POINTER(c_double)), ('ximat', POINTER(c_double)), ('xanchor', POINTER(c_double)), ('xaxis', POINTER(c_double)), ('geom_xpos', POINTER(c_double)), ('geom_xmat', POINTER(c_double)), ('site_xpos', POINTER(c_double)), ('site_xmat', POINTER(c_double)), ('cam_xpos', POINTER(c_double)), ('cam_xmat', POINTER(c_double)), ('light_xpos', POINTER(c_double)), ('light_xdir', POINTER(c_double)), ('com_subtree', POINTER(c_double)), ('cdof', POINTER(c_double)), ('cinert', POINTER(c_double)), ('ten_wrapadr', POINTER(c_int)), ('ten_wrapnum', POINTER(c_int)), ('ten_length', POINTER(c_double)), ('ten_moment', POINTER(c_double)), ('wrap_obj', POINTER(c_int)), ('wrap_xpos', POINTER(c_double)), ('actuator_length', POINTER(c_double)), ('actuator_moment', POINTER(c_double)), ('crb', POINTER(c_double)), ('qM', POINTER(c_double)), ('qLD', POINTER(c_double)), ('qLDiagInv', POINTER(c_double)), ('qLDiagSqrtInv', POINTER(c_double)), ('contact', POINTER(MJCONTACT)), ('efc_type', POINTER(c_int)), ('efc_id', POINTER(c_int)), ('efc_rownnz', POINTER(c_int)), ('efc_rowadr', POINTER(c_int)), ('efc_colind', POINTER(c_int)), ('efc_rownnz_T', POINTER(c_int)), ('efc_rowadr_T', POINTER(c_int)), ('efc_colind_T', POINTER(c_int)), ('efc_solref', POINTER(c_double)), ('efc_solimp', POINTER(c_double)), ('efc_margin', POINTER(c_double)), ('efc_frictionloss', POINTER(c_double)), ('efc_pos', POINTER(c_double)), ('efc_J', POINTER(c_double)), ('efc_J_T', POINTER(c_double)), ('efc_diagApprox', POINTER(c_double)), ('efc_D', POINTER(c_double)), ('efc_R', POINTER(c_double)), ('efc_AR', POINTER(c_double)), ('e_ARchol', POINTER(c_double)), ('fc_e_rect', POINTER(c_double)), ('fc_AR', POINTER(c_double)), ('ten_velocity', POINTER(c_double)), ('actuator_velocity', POINTER(c_double)), ('cvel', POINTER(c_double)), ('cdof_dot', POINTER(c_double)), ('qfrc_bias', POINTER(c_double)), ('qfrc_passive', POINTER(c_double)), ('efc_vel', POINTER(c_double)), ('efc_aref', POINTER(c_double)), ('actuator_force', POINTER(c_double)), ('qfrc_actuator', POINTER(c_double)), ('qfrc_unc', POINTER(c_double)), ('qacc_unc', POINTER(c_double)), ('efc_b', POINTER(c_double)), ('fc_b', POINTER(c_double)), ('efc_force', POINTER(c_double)), ('qfrc_constraint', POINTER(c_double)), ('qfrc_inverse', POINTER(c_double)), ('cacc', POINTER(c_double)), ('cfrc_int', POINTER(c_double)), ('cfrc_ext', POINTER(c_double))]
class MJMODEL(Structure): _fields_ = [('nq', c_int), ('nv', c_int), ('nu', c_int), ('na', c_int), ('nbody', c_int), ('njnt', c_int), ('ngeom', c_int), ('nsite', c_int), ('ncam', c_int), ('nlight', c_int), ('nmesh', c_int), ('nmeshvert', c_int), ('nmeshface', c_int), ('nmeshgraph', c_int), ('nhfield', c_int), ('nhfielddata', c_int), ('ntex', c_int), ('ntexdata', c_int), ('nmat', c_int), ('npair', c_int), ('nexclude', c_int), ('neq', c_int), ('ntendon', c_int), ('nwrap', c_int), ('nsensor', c_int), ('nnumeric', c_int), ('nnumericdata', c_int), ('ntext', c_int), ('ntextdata', c_int), ('nkey', c_int), ('nuser_body', c_int), ('nuser_jnt', c_int), ('nuser_geom', c_int), ('nuser_site', c_int), ('nuser_tendon', c_int), ('nuser_actuator', c_int), ('nuser_sensor', c_int), ('nnames', c_int), ('nM', c_int), ('nemax', c_int), ('njmax', c_int), ('nconmax', c_int), ('nstack', c_int), ('nuserdata', c_int), ('nmocap', c_int), ('nsensordata', c_int), ('nbuffer', c_int), ('opt', MJOPTION), ('vis', MJVISUAL), ('stat', MJSTATISTIC), ('buffer', POINTER(c_ubyte)), ('qpos0', POINTER(c_double)), ('qpos_spring', POINTER(c_double)), ('body_parentid', POINTER(c_int)), ('body_rootid', POINTER(c_int)), ('body_weldid', POINTER(c_int)), ('body_mocapid', POINTER(c_int)), ('body_jntnum', POINTER(c_int)), ('body_jntadr', POINTER(c_int)), ('body_dofnum', POINTER(c_int)), ('body_dofadr', POINTER(c_int)), ('body_geomnum', POINTER(c_int)), ('body_geomadr', POINTER(c_int)), ('body_pos', POINTER(c_double)), ('body_quat', POINTER(c_double)), ('body_ipos', POINTER(c_double)), ('body_iquat', POINTER(c_double)), ('body_mass', POINTER(c_double)), ('body_inertia', POINTER(c_double)), ('body_invweight0', POINTER(c_double)), ('body_user', POINTER(c_double)), ('jnt_type', POINTER(c_int)), ('jnt_qposadr', POINTER(c_int)), ('jnt_dofadr', POINTER(c_int)), ('jnt_bodyid', POINTER(c_int)), ('jnt_limited', POINTER(c_ubyte)), ('jnt_solref', POINTER(c_double)), ('jnt_solimp', POINTER(c_double)), ('jnt_pos', POINTER(c_double)), ('jnt_axis', POINTER(c_double)), ('jnt_stiffness', POINTER(c_double)), ('jnt_range', POINTER(c_double)), ('jnt_margin', POINTER(c_double)), ('jnt_user', POINTER(c_double)), ('dof_bodyid', POINTER(c_int)), ('dof_jntid', POINTER(c_int)), ('dof_parentid', POINTER(c_int)), ('dof_Madr', POINTER(c_int)), ('dof_frictional', POINTER(c_ubyte)), ('dof_solref', POINTER(c_double)), ('dof_solimp', POINTER(c_double)), ('dof_frictionloss', POINTER(c_double)), ('dof_armature', POINTER(c_double)), ('dof_damping', POINTER(c_double)), ('dof_invweight0', POINTER(c_double)), ('geom_type', POINTER(c_int)), ('geom_contype', POINTER(c_int)), ('geom_conaffinity', POINTER(c_int)), ('geom_condim', POINTER(c_int)), ('geom_bodyid', POINTER(c_int)), ('geom_dataid', POINTER(c_int)), ('geom_matid', POINTER(c_int)), ('geom_group', POINTER(c_int)), ('geom_solmix', POINTER(c_double)), ('geom_solref', POINTER(c_double)), ('geom_solimp', POINTER(c_double)), ('geom_size', POINTER(c_double)), ('geom_rbound', POINTER(c_double)), ('geom_pos', POINTER(c_double)), ('geom_quat', POINTER(c_double)), ('geom_friction', POINTER(c_double)), ('geom_margin', POINTER(c_double)), ('geom_gap', POINTER(c_double)), ('geom_user', POINTER(c_double)), ('geom_rgba', POINTER(c_float)), ('site_type', POINTER(c_int)), ('site_bodyid', POINTER(c_int)), ('site_matid', POINTER(c_int)), ('site_group', POINTER(c_int)), ('site_size', POINTER(c_double)), ('site_pos', POINTER(c_double)), ('site_quat', POINTER(c_double)), ('site_user', POINTER(c_double)), ('site_rgba', POINTER(c_float)), ('cam_mode', POINTER(c_int)), ('cam_bodyid', POINTER(c_int)), ('cam_targetbodyid', POINTER(c_int)), ('cam_pos', POINTER(c_double)), ('cam_quat', POINTER(c_double)), ('cam_poscom0', POINTER(c_double)), ('cam_pos0', POINTER(c_double)), ('cam_mat0', POINTER(c_double)), ('cam_fovy', POINTER(c_double)), ('cam_ipd', POINTER(c_double)), ('light_mode', POINTER(c_int)), ('light_bodyid', POINTER(c_int)), ('light_targetbodyid', POINTER(c_int)), ('light_directional', POINTER(c_ubyte)), ('light_castshadow', POINTER(c_ubyte)), ('light_active', POINTER(c_ubyte)), ('light_pos', POINTER(c_double)), ('light_dir', POINTER(c_double)), ('light_poscom0', POINTER(c_double)), ('light_pos0', POINTER(c_double)), ('light_dir0', POINTER(c_double)), ('light_attenuation', POINTER(c_float)), ('light_cutoff', POINTER(c_float)), ('light_exponent', POINTER(c_float)), ('light_ambient', POINTER(c_float)), ('light_diffuse', POINTER(c_float)), ('light_specular', POINTER(c_float)), ('mesh_faceadr', POINTER(c_int)), ('mesh_facenum', POINTER(c_int)), ('mesh_vertadr', POINTER(c_int)), ('mesh_vertnum', POINTER(c_int)), ('mesh_graphadr', POINTER(c_int)), ('mesh_vert', POINTER(c_float)), ('mesh_normal', POINTER(c_float)), ('mesh_face', POINTER(c_int)), ('mesh_graph', POINTER(c_int)), ('hfield_size', POINTER(c_double)), ('hfield_nrow', POINTER(c_int)), ('hfield_ncol', POINTER(c_int)), ('hfield_adr', POINTER(c_int)), ('hfield_data', POINTER(c_float)), ('tex_type', POINTER(c_int)), ('tex_height', POINTER(c_int)), ('tex_width', POINTER(c_int)), ('tex_adr', POINTER(c_int)), ('tex_rgb', POINTER(c_ubyte)), ('mat_texid', POINTER(c_int)), ('mat_texuniform', POINTER(c_ubyte)), ('mat_texrepeat', POINTER(c_float)), ('mat_emission', POINTER(c_float)), ('mat_specular', POINTER(c_float)), ('mat_shininess', POINTER(c_float)), ('mat_reflectance', POINTER(c_float)), ('mat_rgba', POINTER(c_float)), ('pair_dim', POINTER(c_int)), ('pair_geom1', POINTER(c_int)), ('pair_geom2', POINTER(c_int)), ('pair_signature', POINTER(c_int)), ('pair_solref', POINTER(c_double)), ('pair_solimp', POINTER(c_double)), ('pair_margin', POINTER(c_double)), ('pair_gap', POINTER(c_double)), ('pair_friction', POINTER(c_double)), ('exclude_signature', POINTER(c_int)), ('eq_type', POINTER(c_int)), ('eq_obj1id', POINTER(c_int)), ('eq_obj2id', POINTER(c_int)), ('eq_active', POINTER(c_ubyte)), ('eq_solref', POINTER(c_double)), ('eq_solimp', POINTER(c_double)), ('eq_data', POINTER(c_double)), ('tendon_adr', POINTER(c_int)), ('tendon_num', POINTER(c_int)), ('tendon_matid', POINTER(c_int)), ('tendon_limited', POINTER(c_ubyte)), ('tendon_frictional', POINTER(c_ubyte)), ('tendon_width', POINTER(c_double)), ('tendon_solref_lim', POINTER(c_double)), ('tendon_solimp_lim', POINTER(c_double)), ('tendon_solref_fri', POINTER(c_double)), ('tendon_solimp_fri', POINTER(c_double)), ('tendon_range', POINTER(c_double)), ('tendon_margin', POINTER(c_double)), ('tendon_stiffness', POINTER(c_double)), ('tendon_damping', POINTER(c_double)), ('tendon_frictionloss', POINTER(c_double)), ('tendon_lengthspring', POINTER(c_double)), ('tendon_length0', POINTER(c_double)), ('tendon_invweight0', POINTER(c_double)), ('tendon_user', POINTER(c_double)), ('tendon_rgba', POINTER(c_float)), ('wrap_type', POINTER(c_int)), ('wrap_objid', POINTER(c_int)), ('wrap_prm', POINTER(c_double)), ('actuator_trntype', POINTER(c_int)), ('actuator_dyntype', POINTER(c_int)), ('actuator_gaintype', POINTER(c_int)), ('actuator_biastype', POINTER(c_int)), ('actuator_trnid', POINTER(c_int)), ('actuator_ctrllimited', POINTER(c_ubyte)), ('actuator_forcelimited', POINTER(c_ubyte)), ('actuator_dynprm', POINTER(c_double)), ('actuator_gainprm', POINTER(c_double)), ('actuator_biasprm', POINTER(c_double)), ('actuator_ctrlrange', POINTER(c_double)), ('actuator_forcerange', POINTER(c_double)), ('actuator_gear', POINTER(c_double)), ('actuator_cranklength', POINTER(c_double)), ('actuator_invweight0', POINTER(c_double)), ('actuator_length0', POINTER(c_double)), ('actuator_lengthrange', POINTER(c_double)), ('actuator_user', POINTER(c_double)), ('sensor_type', POINTER(c_int)), ('sensor_objid', POINTER(c_int)), ('sensor_dim', POINTER(c_int)), ('sensor_adr', POINTER(c_int)), ('sensor_scale', POINTER(c_double)), ('sensor_user', POINTER(c_double)), ('numeric_adr', POINTER(c_int)), ('numeric_size', POINTER(c_int)), ('numeric_data', POINTER(c_double)), ('text_adr', POINTER(c_int)), ('text_data', POINTER(c_char)), ('key_time', POINTER(c_double)), ('key_qpos', POINTER(c_double)), ('key_qvel', POINTER(c_double)), ('key_act', POINTER(c_double)), ('name_bodyadr', POINTER(c_int)), ('name_jntadr', POINTER(c_int)), ('name_geomadr', POINTER(c_int)), ('name_siteadr', POINTER(c_int)), ('name_camadr', POINTER(c_int)), ('name_lightadr', POINTER(c_int)), ('name_meshadr', POINTER(c_int)), ('name_hfieldadr', POINTER(c_int)), ('name_texadr', POINTER(c_int)), ('name_matadr', POINTER(c_int)), ('name_eqadr', POINTER(c_int)), ('name_tendonadr', POINTER(c_int)), ('name_actuatoradr', POINTER(c_int)), ('name_sensoradr', POINTER(c_int)), ('name_numericadr', POINTER(c_int)), ('name_textadr', POINTER(c_int)), ('names', POINTER(c_char))]
class MjContactWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def dist(self): return self._wrapped.contents.dist @dist.setter def dist(self, value): self._wrapped.contents.dist = value @property def pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pos, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @pos.setter def pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pos, val_ptr, (3 * sizeof(c_double))) @property def frame(self): arr = np.reshape(np.fromiter(self._wrapped.contents.frame, dtype=np.double, count=9), (9,)) arr.setflags(write=False) return arr @frame.setter def frame(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.frame, val_ptr, (9 * sizeof(c_double))) @property def includemargin(self): return self._wrapped.contents.includemargin @includemargin.setter def includemargin(self, value): self._wrapped.contents.includemargin = value @property def friction(self): arr = np.reshape(np.fromiter(self._wrapped.contents.friction, dtype=np.double, count=5), (5,)) arr.setflags(write=False) return arr @friction.setter def friction(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.friction, val_ptr, (5 * sizeof(c_double))) @property def solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.solref, dtype=np.double, count=2), (2,)) arr.setflags(write=False) return arr @solref.setter def solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.solref, val_ptr, (2 * sizeof(c_double))) @property def solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.solimp, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @solimp.setter def solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.solimp, val_ptr, (3 * sizeof(c_double))) @property def mu(self): return self._wrapped.contents.mu @mu.setter def mu(self, value): self._wrapped.contents.mu = value @property def coef(self): arr = np.reshape(np.fromiter(self._wrapped.contents.coef, dtype=np.double, count=5), (5,)) arr.setflags(write=False) return arr @coef.setter def coef(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.coef, val_ptr, (5 * sizeof(c_double))) @property def zone(self): return self._wrapped.contents.zone @zone.setter def zone(self, value): self._wrapped.contents.zone = value @property def dim(self): return self._wrapped.contents.dim @dim.setter def dim(self, value): self._wrapped.contents.dim = value @property def geom1(self): return self._wrapped.contents.geom1 @geom1.setter def geom1(self, value): self._wrapped.contents.geom1 = value @property def geom2(self): return self._wrapped.contents.geom2 @geom2.setter def geom2(self, value): self._wrapped.contents.geom2 = value @property def exclude(self): return self._wrapped.contents.exclude @exclude.setter def exclude(self, value): self._wrapped.contents.exclude = value @property def efc_address(self): return self._wrapped.contents.efc_address @efc_address.setter def efc_address(self, value): self._wrapped.contents.efc_address = value
class MjrRectWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def left(self): return self._wrapped.contents.left @left.setter def left(self, value): self._wrapped.contents.left = value @property def bottom(self): return self._wrapped.contents.bottom @bottom.setter def bottom(self, value): self._wrapped.contents.bottom = value @property def width(self): return self._wrapped.contents.width @width.setter def width(self, value): self._wrapped.contents.width = value @property def height(self): return self._wrapped.contents.height @height.setter def height(self, value): self._wrapped.contents.height = value
class MjvCameraPoseWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def head_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.head_pos, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @head_pos.setter def head_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.head_pos, val_ptr, (3 * sizeof(c_double))) @property def head_right(self): arr = np.reshape(np.fromiter(self._wrapped.contents.head_right, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @head_right.setter def head_right(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.head_right, val_ptr, (3 * sizeof(c_double))) @property def window_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.window_pos, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @window_pos.setter def window_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.window_pos, val_ptr, (3 * sizeof(c_double))) @property def window_right(self): arr = np.reshape(np.fromiter(self._wrapped.contents.window_right, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @window_right.setter def window_right(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.window_right, val_ptr, (3 * sizeof(c_double))) @property def window_up(self): arr = np.reshape(np.fromiter(self._wrapped.contents.window_up, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @window_up.setter def window_up(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.window_up, val_ptr, (3 * sizeof(c_double))) @property def window_normal(self): arr = np.reshape(np.fromiter(self._wrapped.contents.window_normal, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @window_normal.setter def window_normal(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.window_normal, val_ptr, (3 * sizeof(c_double))) @property def window_size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.window_size, dtype=np.double, count=2), (2,)) arr.setflags(write=False) return arr @window_size.setter def window_size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.window_size, val_ptr, (2 * sizeof(c_double))) @property def scale(self): return self._wrapped.contents.scale @scale.setter def scale(self, value): self._wrapped.contents.scale = value @property def ipd(self): return self._wrapped.contents.ipd @ipd.setter def ipd(self, value): self._wrapped.contents.ipd = value
class MjrOptionWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def stereo(self): return self._wrapped.contents.stereo @stereo.setter def stereo(self, value): self._wrapped.contents.stereo = value @property def flags(self): arr = np.reshape(np.fromiter(self._wrapped.contents.flags, dtype=np.uint8, count=6), (6,)) arr.setflags(write=False) return arr @flags.setter def flags(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.flags, val_ptr, (6 * sizeof(c_ubyte)))
class MjrContextWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def linewidth(self): return self._wrapped.contents.linewidth @linewidth.setter def linewidth(self, value): self._wrapped.contents.linewidth = value @property def znear(self): return self._wrapped.contents.znear @znear.setter def znear(self, value): self._wrapped.contents.znear = value @property def zfar(self): return self._wrapped.contents.zfar @zfar.setter def zfar(self, value): self._wrapped.contents.zfar = value @property def shadowclip(self): return self._wrapped.contents.shadowclip @shadowclip.setter def shadowclip(self, value): self._wrapped.contents.shadowclip = value @property def shadowscale(self): return self._wrapped.contents.shadowscale @shadowscale.setter def shadowscale(self, value): self._wrapped.contents.shadowscale = value @property def shadowsize(self): return self._wrapped.contents.shadowsize @shadowsize.setter def shadowsize(self, value): self._wrapped.contents.shadowsize = value @property def offwidth(self): return self._wrapped.contents.offwidth @offwidth.setter def offwidth(self, value): self._wrapped.contents.offwidth = value @property def offheight(self): return self._wrapped.contents.offheight @offheight.setter def offheight(self, value): self._wrapped.contents.offheight = value @property def offFBO(self): return self._wrapped.contents.offFBO @offFBO.setter def offFBO(self, value): self._wrapped.contents.offFBO = value @property def offColor(self): return self._wrapped.contents.offColor @offColor.setter def offColor(self, value): self._wrapped.contents.offColor = value @property def offDepthStencil(self): return self._wrapped.contents.offDepthStencil @offDepthStencil.setter def offDepthStencil(self, value): self._wrapped.contents.offDepthStencil = value @property def shadowFBO(self): return self._wrapped.contents.shadowFBO @shadowFBO.setter def shadowFBO(self, value): self._wrapped.contents.shadowFBO = value @property def shadowTex(self): return self._wrapped.contents.shadowTex @shadowTex.setter def shadowTex(self, value): self._wrapped.contents.shadowTex = value @property def ntexture(self): return self._wrapped.contents.ntexture @ntexture.setter def ntexture(self, value): self._wrapped.contents.ntexture = value @property def texture(self): arr = np.reshape(np.fromiter(self._wrapped.contents.texture, dtype=np.int, count=100), (100,)) arr.setflags(write=False) return arr @texture.setter def texture(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.texture, val_ptr, (100 * sizeof(c_int))) @property def textureType(self): arr = np.reshape(np.fromiter(self._wrapped.contents.textureType, dtype=np.int, count=100), (100,)) arr.setflags(write=False) return arr @textureType.setter def textureType(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.textureType, val_ptr, (100 * sizeof(c_int))) @property def basePlane(self): return self._wrapped.contents.basePlane @basePlane.setter def basePlane(self, value): self._wrapped.contents.basePlane = value @property def baseMesh(self): return self._wrapped.contents.baseMesh @baseMesh.setter def baseMesh(self, value): self._wrapped.contents.baseMesh = value @property def baseHField(self): return self._wrapped.contents.baseHField @baseHField.setter def baseHField(self, value): self._wrapped.contents.baseHField = value @property def baseBuiltin(self): return self._wrapped.contents.baseBuiltin @baseBuiltin.setter def baseBuiltin(self, value): self._wrapped.contents.baseBuiltin = value @property def baseFontNormal(self): return self._wrapped.contents.baseFontNormal @baseFontNormal.setter def baseFontNormal(self, value): self._wrapped.contents.baseFontNormal = value @property def baseFontBack(self): return self._wrapped.contents.baseFontBack @baseFontBack.setter def baseFontBack(self, value): self._wrapped.contents.baseFontBack = value @property def baseFontBig(self): return self._wrapped.contents.baseFontBig @baseFontBig.setter def baseFontBig(self, value): self._wrapped.contents.baseFontBig = value @property def rangePlane(self): return self._wrapped.contents.rangePlane @rangePlane.setter def rangePlane(self, value): self._wrapped.contents.rangePlane = value @property def rangeMesh(self): return self._wrapped.contents.rangeMesh @rangeMesh.setter def rangeMesh(self, value): self._wrapped.contents.rangeMesh = value @property def rangeHField(self): return self._wrapped.contents.rangeHField @rangeHField.setter def rangeHField(self, value): self._wrapped.contents.rangeHField = value @property def rangeBuiltin(self): return self._wrapped.contents.rangeBuiltin @rangeBuiltin.setter def rangeBuiltin(self, value): self._wrapped.contents.rangeBuiltin = value @property def rangeFont(self): return self._wrapped.contents.rangeFont @rangeFont.setter def rangeFont(self, value): self._wrapped.contents.rangeFont = value @property def charWidth(self): arr = np.reshape(np.fromiter(self._wrapped.contents.charWidth, dtype=np.int, count=127), (127,)) arr.setflags(write=False) return arr @charWidth.setter def charWidth(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.charWidth, val_ptr, (127 * sizeof(c_int))) @property def charWidthBig(self): arr = np.reshape(np.fromiter(self._wrapped.contents.charWidthBig, dtype=np.int, count=127), (127,)) arr.setflags(write=False) return arr @charWidthBig.setter def charWidthBig(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.charWidthBig, val_ptr, (127 * sizeof(c_int))) @property def charHeight(self): return self._wrapped.contents.charHeight @charHeight.setter def charHeight(self, value): self._wrapped.contents.charHeight = value @property def charHeightBig(self): return self._wrapped.contents.charHeightBig @charHeightBig.setter def charHeightBig(self, value): self._wrapped.contents.charHeightBig = value @property def glewInitialized(self): return self._wrapped.contents.glewInitialized @glewInitialized.setter def glewInitialized(self, value): self._wrapped.contents.glewInitialized = value
class MjvCameraWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def fovy(self): return self._wrapped.contents.fovy @fovy.setter def fovy(self, value): self._wrapped.contents.fovy = value @property def camid(self): return self._wrapped.contents.camid @camid.setter def camid(self, value): self._wrapped.contents.camid = value @property def trackbodyid(self): return self._wrapped.contents.trackbodyid @trackbodyid.setter def trackbodyid(self, value): self._wrapped.contents.trackbodyid = value @property def lookat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.lookat, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @lookat.setter def lookat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.lookat, val_ptr, (3 * sizeof(c_double))) @property def azimuth(self): return self._wrapped.contents.azimuth @azimuth.setter def azimuth(self, value): self._wrapped.contents.azimuth = value @property def elevation(self): return self._wrapped.contents.elevation @elevation.setter def elevation(self, value): self._wrapped.contents.elevation = value @property def distance(self): return self._wrapped.contents.distance @distance.setter def distance(self, value): self._wrapped.contents.distance = value @property def pose(self): return self._wrapped.contents.pose @pose.setter def pose(self, value): self._wrapped.contents.pose = value @property def VR(self): return self._wrapped.contents.VR @VR.setter def VR(self, value): self._wrapped.contents.VR = value
class MjvOptionWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def label(self): return self._wrapped.contents.label @label.setter def label(self, value): self._wrapped.contents.label = value @property def frame(self): return self._wrapped.contents.frame @frame.setter def frame(self, value): self._wrapped.contents.frame = value @property def geomgroup(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geomgroup, dtype=np.uint8, count=5), (5,)) arr.setflags(write=False) return arr @geomgroup.setter def geomgroup(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.geomgroup, val_ptr, (5 * sizeof(c_ubyte))) @property def sitegroup(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sitegroup, dtype=np.uint8, count=5), (5,)) arr.setflags(write=False) return arr @sitegroup.setter def sitegroup(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.sitegroup, val_ptr, (5 * sizeof(c_ubyte))) @property def flags(self): arr = np.reshape(np.fromiter(self._wrapped.contents.flags, dtype=np.uint8, count=18), (18,)) arr.setflags(write=False) return arr @flags.setter def flags(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.flags, val_ptr, (18 * sizeof(c_ubyte)))
class MjvGeomWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def type(self): return self._wrapped.contents.type @type.setter def type(self, value): self._wrapped.contents.type = value @property def dataid(self): return self._wrapped.contents.dataid @dataid.setter def dataid(self, value): self._wrapped.contents.dataid = value @property def objtype(self): return self._wrapped.contents.objtype @objtype.setter def objtype(self, value): self._wrapped.contents.objtype = value @property def objid(self): return self._wrapped.contents.objid @objid.setter def objid(self, value): self._wrapped.contents.objid = value @property def category(self): return self._wrapped.contents.category @category.setter def category(self, value): self._wrapped.contents.category = value @property def texid(self): return self._wrapped.contents.texid @texid.setter def texid(self, value): self._wrapped.contents.texid = value @property def texuniform(self): return self._wrapped.contents.texuniform @texuniform.setter def texuniform(self, value): self._wrapped.contents.texuniform = value @property def texrepeat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.texrepeat, dtype=np.float, count=2), (2,)) arr.setflags(write=False) return arr @texrepeat.setter def texrepeat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.texrepeat, val_ptr, (2 * sizeof(c_float))) @property def size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.size, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @size.setter def size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.size, val_ptr, (3 * sizeof(c_float))) @property def pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pos, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @pos.setter def pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.pos, val_ptr, (3 * sizeof(c_float))) @property def mat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat, dtype=np.float, count=9), (9,)) arr.setflags(write=False) return arr @mat.setter def mat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat, val_ptr, (9 * sizeof(c_float))) @property def rgba(self): arr = np.reshape(np.fromiter(self._wrapped.contents.rgba, dtype=np.float, count=4), (4,)) arr.setflags(write=False) return arr @rgba.setter def rgba(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.rgba, val_ptr, (4 * sizeof(c_float))) @property def emission(self): return self._wrapped.contents.emission @emission.setter def emission(self, value): self._wrapped.contents.emission = value @property def specular(self): return self._wrapped.contents.specular @specular.setter def specular(self, value): self._wrapped.contents.specular = value @property def shininess(self): return self._wrapped.contents.shininess @shininess.setter def shininess(self, value): self._wrapped.contents.shininess = value @property def reflectance(self): return self._wrapped.contents.reflectance @reflectance.setter def reflectance(self, value): self._wrapped.contents.reflectance = value @property def label(self): return self._wrapped.contents.label @label.setter def label(self, value): self._wrapped.contents.label = value @property def camdist(self): return self._wrapped.contents.camdist @camdist.setter def camdist(self, value): self._wrapped.contents.camdist = value @property def rbound(self): return self._wrapped.contents.rbound @rbound.setter def rbound(self, value): self._wrapped.contents.rbound = value @property def transparent(self): return self._wrapped.contents.transparent @transparent.setter def transparent(self, value): self._wrapped.contents.transparent = value
class MjvLightWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pos, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @pos.setter def pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.pos, val_ptr, (3 * sizeof(c_float))) @property def dir(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dir, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @dir.setter def dir(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.dir, val_ptr, (3 * sizeof(c_float))) @property def attenuation(self): arr = np.reshape(np.fromiter(self._wrapped.contents.attenuation, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @attenuation.setter def attenuation(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.attenuation, val_ptr, (3 * sizeof(c_float))) @property def cutoff(self): return self._wrapped.contents.cutoff @cutoff.setter def cutoff(self, value): self._wrapped.contents.cutoff = value @property def exponent(self): return self._wrapped.contents.exponent @exponent.setter def exponent(self, value): self._wrapped.contents.exponent = value @property def ambient(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ambient, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @ambient.setter def ambient(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.ambient, val_ptr, (3 * sizeof(c_float))) @property def diffuse(self): arr = np.reshape(np.fromiter(self._wrapped.contents.diffuse, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @diffuse.setter def diffuse(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.diffuse, val_ptr, (3 * sizeof(c_float))) @property def specular(self): arr = np.reshape(np.fromiter(self._wrapped.contents.specular, dtype=np.float, count=3), (3,)) arr.setflags(write=False) return arr @specular.setter def specular(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.specular, val_ptr, (3 * sizeof(c_float))) @property def headlight(self): return self._wrapped.contents.headlight @headlight.setter def headlight(self, value): self._wrapped.contents.headlight = value @property def directional(self): return self._wrapped.contents.directional @directional.setter def directional(self, value): self._wrapped.contents.directional = value @property def castshadow(self): return self._wrapped.contents.castshadow @castshadow.setter def castshadow(self, value): self._wrapped.contents.castshadow = value
class MjvObjectsWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def nlight(self): return self._wrapped.contents.nlight @nlight.setter def nlight(self, value): self._wrapped.contents.nlight = value @property def ngeom(self): return self._wrapped.contents.ngeom @ngeom.setter def ngeom(self, value): self._wrapped.contents.ngeom = value @property def maxgeom(self): return self._wrapped.contents.maxgeom @maxgeom.setter def maxgeom(self, value): self._wrapped.contents.maxgeom = value @property def lights(self): return self._wrapped.contents.lights @lights.setter def lights(self, value): self._wrapped.contents.lights = value
class MjOptionWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def timestep(self): return self._wrapped.contents.timestep @timestep.setter def timestep(self, value): self._wrapped.contents.timestep = value @property def apirate(self): return self._wrapped.contents.apirate @apirate.setter def apirate(self, value): self._wrapped.contents.apirate = value @property def tolerance(self): return self._wrapped.contents.tolerance @tolerance.setter def tolerance(self, value): self._wrapped.contents.tolerance = value @property def impratio(self): return self._wrapped.contents.impratio @impratio.setter def impratio(self, value): self._wrapped.contents.impratio = value @property def gravity(self): arr = np.reshape(np.fromiter(self._wrapped.contents.gravity, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @gravity.setter def gravity(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.gravity, val_ptr, (3 * sizeof(c_double))) @property def wind(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wind, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @wind.setter def wind(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.wind, val_ptr, (3 * sizeof(c_double))) @property def magnetic(self): arr = np.reshape(np.fromiter(self._wrapped.contents.magnetic, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @magnetic.setter def magnetic(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.magnetic, val_ptr, (3 * sizeof(c_double))) @property def density(self): return self._wrapped.contents.density @density.setter def density(self, value): self._wrapped.contents.density = value @property def viscosity(self): return self._wrapped.contents.viscosity @viscosity.setter def viscosity(self, value): self._wrapped.contents.viscosity = value @property def o_margin(self): return self._wrapped.contents.o_margin @o_margin.setter def o_margin(self, value): self._wrapped.contents.o_margin = value @property def o_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.o_solref, dtype=np.double, count=2), (2,)) arr.setflags(write=False) return arr @o_solref.setter def o_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.o_solref, val_ptr, (2 * sizeof(c_double))) @property def o_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.o_solimp, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @o_solimp.setter def o_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.o_solimp, val_ptr, (3 * sizeof(c_double))) @property def mpr_tolerance(self): return self._wrapped.contents.mpr_tolerance @mpr_tolerance.setter def mpr_tolerance(self, value): self._wrapped.contents.mpr_tolerance = value @property def mpr_iterations(self): return self._wrapped.contents.mpr_iterations @mpr_iterations.setter def mpr_iterations(self, value): self._wrapped.contents.mpr_iterations = value @property def integrator(self): return self._wrapped.contents.integrator @integrator.setter def integrator(self, value): self._wrapped.contents.integrator = value @property def collision(self): return self._wrapped.contents.collision @collision.setter def collision(self, value): self._wrapped.contents.collision = value @property def impedance(self): return self._wrapped.contents.impedance @impedance.setter def impedance(self, value): self._wrapped.contents.impedance = value @property def reference(self): return self._wrapped.contents.reference @reference.setter def reference(self, value): self._wrapped.contents.reference = value @property def solver(self): return self._wrapped.contents.solver @solver.setter def solver(self, value): self._wrapped.contents.solver = value @property def iterations(self): return self._wrapped.contents.iterations @iterations.setter def iterations(self, value): self._wrapped.contents.iterations = value @property def disableflags(self): return self._wrapped.contents.disableflags @disableflags.setter def disableflags(self, value): self._wrapped.contents.disableflags = value @property def enableflags(self): return self._wrapped.contents.enableflags @enableflags.setter def enableflags(self, value): self._wrapped.contents.enableflags = value
class MjVisualWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def global_(self): return self._wrapped.contents.global_ @global_.setter def global_(self, value): self._wrapped.contents.global_ = value @property def quality(self): return self._wrapped.contents.quality @quality.setter def quality(self, value): self._wrapped.contents.quality = value @property def headlight(self): return self._wrapped.contents.headlight @headlight.setter def headlight(self, value): self._wrapped.contents.headlight = value @property def map_(self): return self._wrapped.contents.map_ @map_.setter def map_(self, value): self._wrapped.contents.map_ = value @property def scale(self): return self._wrapped.contents.scale @scale.setter def scale(self, value): self._wrapped.contents.scale = value @property def rgba(self): return self._wrapped.contents.rgba @rgba.setter def rgba(self, value): self._wrapped.contents.rgba = value
class MjStatisticWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def meanmass(self): return self._wrapped.contents.meanmass @meanmass.setter def meanmass(self, value): self._wrapped.contents.meanmass = value @property def meansize(self): return self._wrapped.contents.meansize @meansize.setter def meansize(self, value): self._wrapped.contents.meansize = value @property def extent(self): return self._wrapped.contents.extent @extent.setter def extent(self, value): self._wrapped.contents.extent = value @property def center(self): arr = np.reshape(np.fromiter(self._wrapped.contents.center, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @center.setter def center(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.center, val_ptr, (3 * sizeof(c_double)))
class MjDataWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def nstack(self): return self._wrapped.contents.nstack @nstack.setter def nstack(self, value): self._wrapped.contents.nstack = value @property def nbuffer(self): return self._wrapped.contents.nbuffer @nbuffer.setter def nbuffer(self, value): self._wrapped.contents.nbuffer = value @property def pstack(self): return self._wrapped.contents.pstack @pstack.setter def pstack(self, value): self._wrapped.contents.pstack = value @property def maxstackuse(self): return self._wrapped.contents.maxstackuse @maxstackuse.setter def maxstackuse(self, value): self._wrapped.contents.maxstackuse = value @property def ne(self): return self._wrapped.contents.ne @ne.setter def ne(self, value): self._wrapped.contents.ne = value @property def nf(self): return self._wrapped.contents.nf @nf.setter def nf(self, value): self._wrapped.contents.nf = value @property def nefc(self): return self._wrapped.contents.nefc @nefc.setter def nefc(self, value): self._wrapped.contents.nefc = value @property def ncon(self): return self._wrapped.contents.ncon @ncon.setter def ncon(self, value): self._wrapped.contents.ncon = value @property def nwarning(self): arr = np.reshape(np.fromiter(self._wrapped.contents.nwarning, dtype=np.int, count=8), (8,)) arr.setflags(write=False) return arr @nwarning.setter def nwarning(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.nwarning, val_ptr, (8 * sizeof(c_int))) @property def warning_info(self): arr = np.reshape(np.fromiter(self._wrapped.contents.warning_info, dtype=np.int, count=8), (8,)) arr.setflags(write=False) return arr @warning_info.setter def warning_info(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.warning_info, val_ptr, (8 * sizeof(c_int))) @property def timer_duration(self): arr = np.reshape(np.fromiter(self._wrapped.contents.timer_duration, dtype=np.double, count=14), (14,)) arr.setflags(write=False) return arr @timer_duration.setter def timer_duration(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.timer_duration, val_ptr, (14 * sizeof(c_double))) @property def timer_ncall(self): arr = np.reshape(np.fromiter(self._wrapped.contents.timer_ncall, dtype=np.double, count=14), (14,)) arr.setflags(write=False) return arr @timer_ncall.setter def timer_ncall(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.timer_ncall, val_ptr, (14 * sizeof(c_double))) @property def mocaptime(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mocaptime, dtype=np.double, count=3), (3,)) arr.setflags(write=False) return arr @mocaptime.setter def mocaptime(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.mocaptime, val_ptr, (3 * sizeof(c_double))) @property def time(self): return self._wrapped.contents.time @time.setter def time(self, value): self._wrapped.contents.time = value @property def energy(self): arr = np.reshape(np.fromiter(self._wrapped.contents.energy, dtype=np.double, count=2), (2,)) arr.setflags(write=False) return arr @energy.setter def energy(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.energy, val_ptr, (2 * sizeof(c_double))) @property def solverstat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.solverstat, dtype=np.double, count=4), (4,)) arr.setflags(write=False) return arr @solverstat.setter def solverstat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.solverstat, val_ptr, (4 * sizeof(c_double))) @property def solvertrace(self): arr = np.reshape(np.fromiter(self._wrapped.contents.solvertrace, dtype=np.double, count=200), (200,)) arr.setflags(write=False) return arr @solvertrace.setter def solvertrace(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.solvertrace, val_ptr, (200 * sizeof(c_double))) @property def buffer(self): arr = np.reshape(np.fromiter(self._wrapped.contents.buffer, dtype=np.uint8, count=self.nbuffer), (self.nbuffer,)) arr.setflags(write=False) return arr @buffer.setter def buffer(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.buffer, val_ptr, (self.nbuffer * sizeof(c_ubyte))) @property def stack(self): arr = np.reshape(np.fromiter(self._wrapped.contents.stack, dtype=np.double, count=self.nstack), (self.nstack,)) arr.setflags(write=False) return arr @stack.setter def stack(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.stack, val_ptr, (self.nstack * sizeof(c_double))) @property def qpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qpos, dtype=np.double, count=(self._size_src.nq * 1)), (self._size_src.nq, 1)) arr.setflags(write=False) return arr @qpos.setter def qpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qpos, val_ptr, ((self._size_src.nq * 1) * sizeof(c_double))) @property def qvel(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qvel, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qvel.setter def qvel(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qvel, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def act(self): arr = np.reshape(np.fromiter(self._wrapped.contents.act, dtype=np.double, count=(self._size_src.na * 1)), (self._size_src.na, 1)) arr.setflags(write=False) return arr @act.setter def act(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.act, val_ptr, ((self._size_src.na * 1) * sizeof(c_double))) @property def ctrl(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ctrl, dtype=np.double, count=(self._size_src.nu * 1)), (self._size_src.nu, 1)) arr.setflags(write=False) return arr @ctrl.setter def ctrl(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.ctrl, val_ptr, ((self._size_src.nu * 1) * sizeof(c_double))) @property def qfrc_applied(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_applied, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_applied.setter def qfrc_applied(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_applied, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def xfrc_applied(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xfrc_applied, dtype=np.double, count=(self._size_src.nbody * 6)), (self._size_src.nbody, 6)) arr.setflags(write=False) return arr @xfrc_applied.setter def xfrc_applied(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xfrc_applied, val_ptr, ((self._size_src.nbody * 6) * sizeof(c_double))) @property def qacc(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qacc, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qacc.setter def qacc(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qacc, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def act_dot(self): arr = np.reshape(np.fromiter(self._wrapped.contents.act_dot, dtype=np.double, count=(self._size_src.na * 1)), (self._size_src.na, 1)) arr.setflags(write=False) return arr @act_dot.setter def act_dot(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.act_dot, val_ptr, ((self._size_src.na * 1) * sizeof(c_double))) @property def mocap_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mocap_pos, dtype=np.double, count=(self._size_src.nmocap * 3)), (self._size_src.nmocap, 3)) arr.setflags(write=False) return arr @mocap_pos.setter def mocap_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.mocap_pos, val_ptr, ((self._size_src.nmocap * 3) * sizeof(c_double))) @property def mocap_quat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mocap_quat, dtype=np.double, count=(self._size_src.nmocap * 4)), (self._size_src.nmocap, 4)) arr.setflags(write=False) return arr @mocap_quat.setter def mocap_quat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.mocap_quat, val_ptr, ((self._size_src.nmocap * 4) * sizeof(c_double))) @property def userdata(self): arr = np.reshape(np.fromiter(self._wrapped.contents.userdata, dtype=np.double, count=(self._size_src.nuserdata * 1)), (self._size_src.nuserdata, 1)) arr.setflags(write=False) return arr @userdata.setter def userdata(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.userdata, val_ptr, ((self._size_src.nuserdata * 1) * sizeof(c_double))) @property def sensordata(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensordata, dtype=np.double, count=(self._size_src.nsensordata * 1)), (self._size_src.nsensordata, 1)) arr.setflags(write=False) return arr @sensordata.setter def sensordata(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.sensordata, val_ptr, ((self._size_src.nsensordata * 1) * sizeof(c_double))) @property def xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xpos, dtype=np.double, count=(self._size_src.nbody * 3)), (self._size_src.nbody, 3)) arr.setflags(write=False) return arr @xpos.setter def xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xpos, val_ptr, ((self._size_src.nbody * 3) * sizeof(c_double))) @property def xquat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xquat, dtype=np.double, count=(self._size_src.nbody * 4)), (self._size_src.nbody, 4)) arr.setflags(write=False) return arr @xquat.setter def xquat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xquat, val_ptr, ((self._size_src.nbody * 4) * sizeof(c_double))) @property def xmat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xmat, dtype=np.double, count=(self._size_src.nbody * 9)), (self._size_src.nbody, 9)) arr.setflags(write=False) return arr @xmat.setter def xmat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xmat, val_ptr, ((self._size_src.nbody * 9) * sizeof(c_double))) @property def xipos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xipos, dtype=np.double, count=(self._size_src.nbody * 3)), (self._size_src.nbody, 3)) arr.setflags(write=False) return arr @xipos.setter def xipos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xipos, val_ptr, ((self._size_src.nbody * 3) * sizeof(c_double))) @property def ximat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ximat, dtype=np.double, count=(self._size_src.nbody * 9)), (self._size_src.nbody, 9)) arr.setflags(write=False) return arr @ximat.setter def ximat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.ximat, val_ptr, ((self._size_src.nbody * 9) * sizeof(c_double))) @property def xanchor(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xanchor, dtype=np.double, count=(self._size_src.njnt * 3)), (self._size_src.njnt, 3)) arr.setflags(write=False) return arr @xanchor.setter def xanchor(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xanchor, val_ptr, ((self._size_src.njnt * 3) * sizeof(c_double))) @property def xaxis(self): arr = np.reshape(np.fromiter(self._wrapped.contents.xaxis, dtype=np.double, count=(self._size_src.njnt * 3)), (self._size_src.njnt, 3)) arr.setflags(write=False) return arr @xaxis.setter def xaxis(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.xaxis, val_ptr, ((self._size_src.njnt * 3) * sizeof(c_double))) @property def geom_xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_xpos, dtype=np.double, count=(self._size_src.ngeom * 3)), (self._size_src.ngeom, 3)) arr.setflags(write=False) return arr @geom_xpos.setter def geom_xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_xpos, val_ptr, ((self._size_src.ngeom * 3) * sizeof(c_double))) @property def geom_xmat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_xmat, dtype=np.double, count=(self._size_src.ngeom * 9)), (self._size_src.ngeom, 9)) arr.setflags(write=False) return arr @geom_xmat.setter def geom_xmat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_xmat, val_ptr, ((self._size_src.ngeom * 9) * sizeof(c_double))) @property def site_xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_xpos, dtype=np.double, count=(self._size_src.nsite * 3)), (self._size_src.nsite, 3)) arr.setflags(write=False) return arr @site_xpos.setter def site_xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_xpos, val_ptr, ((self._size_src.nsite * 3) * sizeof(c_double))) @property def site_xmat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_xmat, dtype=np.double, count=(self._size_src.nsite * 9)), (self._size_src.nsite, 9)) arr.setflags(write=False) return arr @site_xmat.setter def site_xmat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_xmat, val_ptr, ((self._size_src.nsite * 9) * sizeof(c_double))) @property def cam_xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_xpos, dtype=np.double, count=(self._size_src.ncam * 3)), (self._size_src.ncam, 3)) arr.setflags(write=False) return arr @cam_xpos.setter def cam_xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_xpos, val_ptr, ((self._size_src.ncam * 3) * sizeof(c_double))) @property def cam_xmat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_xmat, dtype=np.double, count=(self._size_src.ncam * 9)), (self._size_src.ncam, 9)) arr.setflags(write=False) return arr @cam_xmat.setter def cam_xmat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_xmat, val_ptr, ((self._size_src.ncam * 9) * sizeof(c_double))) @property def light_xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_xpos, dtype=np.double, count=(self._size_src.nlight * 3)), (self._size_src.nlight, 3)) arr.setflags(write=False) return arr @light_xpos.setter def light_xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_xpos, val_ptr, ((self._size_src.nlight * 3) * sizeof(c_double))) @property def light_xdir(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_xdir, dtype=np.double, count=(self._size_src.nlight * 3)), (self._size_src.nlight, 3)) arr.setflags(write=False) return arr @light_xdir.setter def light_xdir(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_xdir, val_ptr, ((self._size_src.nlight * 3) * sizeof(c_double))) @property def com_subtree(self): arr = np.reshape(np.fromiter(self._wrapped.contents.com_subtree, dtype=np.double, count=(self._size_src.nbody * 3)), (self._size_src.nbody, 3)) arr.setflags(write=False) return arr @com_subtree.setter def com_subtree(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.com_subtree, val_ptr, ((self._size_src.nbody * 3) * sizeof(c_double))) @property def cdof(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cdof, dtype=np.double, count=(self._size_src.nv * 6)), (self._size_src.nv, 6)) arr.setflags(write=False) return arr @cdof.setter def cdof(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cdof, val_ptr, ((self._size_src.nv * 6) * sizeof(c_double))) @property def cinert(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cinert, dtype=np.double, count=(self._size_src.nbody * 10)), (self._size_src.nbody, 10)) arr.setflags(write=False) return arr @cinert.setter def cinert(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cinert, val_ptr, ((self._size_src.nbody * 10) * sizeof(c_double))) @property def ten_wrapadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ten_wrapadr, dtype=np.int, count=(self._size_src.ntendon * 1)), (self._size_src.ntendon, 1)) arr.setflags(write=False) return arr @ten_wrapadr.setter def ten_wrapadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.ten_wrapadr, val_ptr, ((self._size_src.ntendon * 1) * sizeof(c_int))) @property def ten_wrapnum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ten_wrapnum, dtype=np.int, count=(self._size_src.ntendon * 1)), (self._size_src.ntendon, 1)) arr.setflags(write=False) return arr @ten_wrapnum.setter def ten_wrapnum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.ten_wrapnum, val_ptr, ((self._size_src.ntendon * 1) * sizeof(c_int))) @property def ten_length(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ten_length, dtype=np.double, count=(self._size_src.ntendon * 1)), (self._size_src.ntendon, 1)) arr.setflags(write=False) return arr @ten_length.setter def ten_length(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.ten_length, val_ptr, ((self._size_src.ntendon * 1) * sizeof(c_double))) @property def ten_moment(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ten_moment, dtype=np.double, count=(self._size_src.ntendon * self._size_src.nv)), (self._size_src.ntendon, self._size_src.nv)) arr.setflags(write=False) return arr @ten_moment.setter def ten_moment(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.ten_moment, val_ptr, ((self._size_src.ntendon * self._size_src.nv) * sizeof(c_double))) @property def wrap_obj(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wrap_obj, dtype=np.int, count=(self._size_src.nwrap * 2)), (self._size_src.nwrap, 2)) arr.setflags(write=False) return arr @wrap_obj.setter def wrap_obj(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.wrap_obj, val_ptr, ((self._size_src.nwrap * 2) * sizeof(c_int))) @property def wrap_xpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wrap_xpos, dtype=np.double, count=(self._size_src.nwrap * 6)), (self._size_src.nwrap, 6)) arr.setflags(write=False) return arr @wrap_xpos.setter def wrap_xpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.wrap_xpos, val_ptr, ((self._size_src.nwrap * 6) * sizeof(c_double))) @property def actuator_length(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_length, dtype=np.double, count=(self._size_src.nu * 1)), (self._size_src.nu, 1)) arr.setflags(write=False) return arr @actuator_length.setter def actuator_length(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_length, val_ptr, ((self._size_src.nu * 1) * sizeof(c_double))) @property def actuator_moment(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_moment, dtype=np.double, count=(self._size_src.nu * self._size_src.nv)), (self._size_src.nu, self._size_src.nv)) arr.setflags(write=False) return arr @actuator_moment.setter def actuator_moment(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_moment, val_ptr, ((self._size_src.nu * self._size_src.nv) * sizeof(c_double))) @property def crb(self): arr = np.reshape(np.fromiter(self._wrapped.contents.crb, dtype=np.double, count=(self._size_src.nbody * 10)), (self._size_src.nbody, 10)) arr.setflags(write=False) return arr @crb.setter def crb(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.crb, val_ptr, ((self._size_src.nbody * 10) * sizeof(c_double))) @property def qM(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qM, dtype=np.double, count=(self._size_src.nM * 1)), (self._size_src.nM, 1)) arr.setflags(write=False) return arr @qM.setter def qM(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qM, val_ptr, ((self._size_src.nM * 1) * sizeof(c_double))) @property def qLD(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qLD, dtype=np.double, count=(self._size_src.nM * 1)), (self._size_src.nM, 1)) arr.setflags(write=False) return arr @qLD.setter def qLD(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qLD, val_ptr, ((self._size_src.nM * 1) * sizeof(c_double))) @property def qLDiagInv(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qLDiagInv, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qLDiagInv.setter def qLDiagInv(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qLDiagInv, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def qLDiagSqrtInv(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qLDiagSqrtInv, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qLDiagSqrtInv.setter def qLDiagSqrtInv(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qLDiagSqrtInv, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def efc_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_type, dtype=np.int, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_type.setter def efc_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_type, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_int))) @property def efc_id(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_id, dtype=np.int, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_id.setter def efc_id(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_id, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_int))) @property def efc_rownnz(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_rownnz, dtype=np.int, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_rownnz.setter def efc_rownnz(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_rownnz, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_int))) @property def efc_rowadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_rowadr, dtype=np.int, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_rowadr.setter def efc_rowadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_rowadr, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_int))) @property def efc_colind(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_colind, dtype=np.int, count=(self._size_src.njmax * self._size_src.nv)), (self._size_src.njmax, self._size_src.nv)) arr.setflags(write=False) return arr @efc_colind.setter def efc_colind(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_colind, val_ptr, ((self._size_src.njmax * self._size_src.nv) * sizeof(c_int))) @property def efc_rownnz_T(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_rownnz_T, dtype=np.int, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @efc_rownnz_T.setter def efc_rownnz_T(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_rownnz_T, val_ptr, ((self._size_src.nv * 1) * sizeof(c_int))) @property def efc_rowadr_T(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_rowadr_T, dtype=np.int, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @efc_rowadr_T.setter def efc_rowadr_T(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_rowadr_T, val_ptr, ((self._size_src.nv * 1) * sizeof(c_int))) @property def efc_colind_T(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_colind_T, dtype=np.int, count=(self._size_src.nv * self._size_src.njmax)), (self._size_src.nv, self._size_src.njmax)) arr.setflags(write=False) return arr @efc_colind_T.setter def efc_colind_T(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.efc_colind_T, val_ptr, ((self._size_src.nv * self._size_src.njmax) * sizeof(c_int))) @property def efc_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_solref, dtype=np.double, count=(self._size_src.njmax * 2)), (self._size_src.njmax, 2)) arr.setflags(write=False) return arr @efc_solref.setter def efc_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_solref, val_ptr, ((self._size_src.njmax * 2) * sizeof(c_double))) @property def efc_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_solimp, dtype=np.double, count=(self._size_src.njmax * 3)), (self._size_src.njmax, 3)) arr.setflags(write=False) return arr @efc_solimp.setter def efc_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_solimp, val_ptr, ((self._size_src.njmax * 3) * sizeof(c_double))) @property def efc_margin(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_margin, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_margin.setter def efc_margin(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_margin, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_frictionloss(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_frictionloss, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_frictionloss.setter def efc_frictionloss(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_frictionloss, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_pos, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_pos.setter def efc_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_pos, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_J(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_J, dtype=np.double, count=(self._size_src.njmax * self._size_src.nv)), (self._size_src.njmax, self._size_src.nv)) arr.setflags(write=False) return arr @efc_J.setter def efc_J(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_J, val_ptr, ((self._size_src.njmax * self._size_src.nv) * sizeof(c_double))) @property def efc_J_T(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_J_T, dtype=np.double, count=(self._size_src.nv * self._size_src.njmax)), (self._size_src.nv, self._size_src.njmax)) arr.setflags(write=False) return arr @efc_J_T.setter def efc_J_T(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_J_T, val_ptr, ((self._size_src.nv * self._size_src.njmax) * sizeof(c_double))) @property def efc_diagApprox(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_diagApprox, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_diagApprox.setter def efc_diagApprox(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_diagApprox, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_D(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_D, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_D.setter def efc_D(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_D, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_R(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_R, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_R.setter def efc_R(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_R, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_AR(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_AR, dtype=np.double, count=(self._size_src.njmax * self._size_src.njmax)), (self._size_src.njmax, self._size_src.njmax)) arr.setflags(write=False) return arr @efc_AR.setter def efc_AR(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_AR, val_ptr, ((self._size_src.njmax * self._size_src.njmax) * sizeof(c_double))) @property def e_ARchol(self): arr = np.reshape(np.fromiter(self._wrapped.contents.e_ARchol, dtype=np.double, count=(self._size_src.nemax * self._size_src.nemax)), (self._size_src.nemax, self._size_src.nemax)) arr.setflags(write=False) return arr @e_ARchol.setter def e_ARchol(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.e_ARchol, val_ptr, ((self._size_src.nemax * self._size_src.nemax) * sizeof(c_double))) @property def fc_e_rect(self): arr = np.reshape(np.fromiter(self._wrapped.contents.fc_e_rect, dtype=np.double, count=(self._size_src.njmax * self._size_src.nemax)), (self._size_src.njmax, self._size_src.nemax)) arr.setflags(write=False) return arr @fc_e_rect.setter def fc_e_rect(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.fc_e_rect, val_ptr, ((self._size_src.njmax * self._size_src.nemax) * sizeof(c_double))) @property def fc_AR(self): arr = np.reshape(np.fromiter(self._wrapped.contents.fc_AR, dtype=np.double, count=(self._size_src.njmax * self._size_src.njmax)), (self._size_src.njmax, self._size_src.njmax)) arr.setflags(write=False) return arr @fc_AR.setter def fc_AR(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.fc_AR, val_ptr, ((self._size_src.njmax * self._size_src.njmax) * sizeof(c_double))) @property def ten_velocity(self): arr = np.reshape(np.fromiter(self._wrapped.contents.ten_velocity, dtype=np.double, count=(self._size_src.ntendon * 1)), (self._size_src.ntendon, 1)) arr.setflags(write=False) return arr @ten_velocity.setter def ten_velocity(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.ten_velocity, val_ptr, ((self._size_src.ntendon * 1) * sizeof(c_double))) @property def actuator_velocity(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_velocity, dtype=np.double, count=(self._size_src.nu * 1)), (self._size_src.nu, 1)) arr.setflags(write=False) return arr @actuator_velocity.setter def actuator_velocity(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_velocity, val_ptr, ((self._size_src.nu * 1) * sizeof(c_double))) @property def cvel(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cvel, dtype=np.double, count=(self._size_src.nbody * 6)), (self._size_src.nbody, 6)) arr.setflags(write=False) return arr @cvel.setter def cvel(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cvel, val_ptr, ((self._size_src.nbody * 6) * sizeof(c_double))) @property def cdof_dot(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cdof_dot, dtype=np.double, count=(self._size_src.nv * 6)), (self._size_src.nv, 6)) arr.setflags(write=False) return arr @cdof_dot.setter def cdof_dot(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cdof_dot, val_ptr, ((self._size_src.nv * 6) * sizeof(c_double))) @property def qfrc_bias(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_bias, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_bias.setter def qfrc_bias(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_bias, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def qfrc_passive(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_passive, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_passive.setter def qfrc_passive(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_passive, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def efc_vel(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_vel, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_vel.setter def efc_vel(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_vel, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_aref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_aref, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_aref.setter def efc_aref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_aref, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def actuator_force(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_force, dtype=np.double, count=(self._size_src.nu * 1)), (self._size_src.nu, 1)) arr.setflags(write=False) return arr @actuator_force.setter def actuator_force(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_force, val_ptr, ((self._size_src.nu * 1) * sizeof(c_double))) @property def qfrc_actuator(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_actuator, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_actuator.setter def qfrc_actuator(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_actuator, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def qfrc_unc(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_unc, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_unc.setter def qfrc_unc(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_unc, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def qacc_unc(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qacc_unc, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qacc_unc.setter def qacc_unc(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qacc_unc, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def efc_b(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_b, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_b.setter def efc_b(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_b, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def fc_b(self): arr = np.reshape(np.fromiter(self._wrapped.contents.fc_b, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @fc_b.setter def fc_b(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.fc_b, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def efc_force(self): arr = np.reshape(np.fromiter(self._wrapped.contents.efc_force, dtype=np.double, count=(self._size_src.njmax * 1)), (self._size_src.njmax, 1)) arr.setflags(write=False) return arr @efc_force.setter def efc_force(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.efc_force, val_ptr, ((self._size_src.njmax * 1) * sizeof(c_double))) @property def qfrc_constraint(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_constraint, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_constraint.setter def qfrc_constraint(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_constraint, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def qfrc_inverse(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qfrc_inverse, dtype=np.double, count=(self._size_src.nv * 1)), (self._size_src.nv, 1)) arr.setflags(write=False) return arr @qfrc_inverse.setter def qfrc_inverse(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qfrc_inverse, val_ptr, ((self._size_src.nv * 1) * sizeof(c_double))) @property def cacc(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cacc, dtype=np.double, count=(self._size_src.nbody * 6)), (self._size_src.nbody, 6)) arr.setflags(write=False) return arr @cacc.setter def cacc(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cacc, val_ptr, ((self._size_src.nbody * 6) * sizeof(c_double))) @property def cfrc_int(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cfrc_int, dtype=np.double, count=(self._size_src.nbody * 6)), (self._size_src.nbody, 6)) arr.setflags(write=False) return arr @cfrc_int.setter def cfrc_int(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cfrc_int, val_ptr, ((self._size_src.nbody * 6) * sizeof(c_double))) @property def cfrc_ext(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cfrc_ext, dtype=np.double, count=(self._size_src.nbody * 6)), (self._size_src.nbody, 6)) arr.setflags(write=False) return arr @cfrc_ext.setter def cfrc_ext(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cfrc_ext, val_ptr, ((self._size_src.nbody * 6) * sizeof(c_double)))
class MjModelWrapper(object): def __init__(self, wrapped, size_src=None): self._wrapped = wrapped self._size_src = size_src @property def ptr(self): return self._wrapped @property def obj(self): return self._wrapped.contents @property def nq(self): return self._wrapped.contents.nq @nq.setter def nq(self, value): self._wrapped.contents.nq = value @property def nv(self): return self._wrapped.contents.nv @nv.setter def nv(self, value): self._wrapped.contents.nv = value @property def nu(self): return self._wrapped.contents.nu @nu.setter def nu(self, value): self._wrapped.contents.nu = value @property def na(self): return self._wrapped.contents.na @na.setter def na(self, value): self._wrapped.contents.na = value @property def nbody(self): return self._wrapped.contents.nbody @nbody.setter def nbody(self, value): self._wrapped.contents.nbody = value @property def njnt(self): return self._wrapped.contents.njnt @njnt.setter def njnt(self, value): self._wrapped.contents.njnt = value @property def ngeom(self): return self._wrapped.contents.ngeom @ngeom.setter def ngeom(self, value): self._wrapped.contents.ngeom = value @property def nsite(self): return self._wrapped.contents.nsite @nsite.setter def nsite(self, value): self._wrapped.contents.nsite = value @property def ncam(self): return self._wrapped.contents.ncam @ncam.setter def ncam(self, value): self._wrapped.contents.ncam = value @property def nlight(self): return self._wrapped.contents.nlight @nlight.setter def nlight(self, value): self._wrapped.contents.nlight = value @property def nmesh(self): return self._wrapped.contents.nmesh @nmesh.setter def nmesh(self, value): self._wrapped.contents.nmesh = value @property def nmeshvert(self): return self._wrapped.contents.nmeshvert @nmeshvert.setter def nmeshvert(self, value): self._wrapped.contents.nmeshvert = value @property def nmeshface(self): return self._wrapped.contents.nmeshface @nmeshface.setter def nmeshface(self, value): self._wrapped.contents.nmeshface = value @property def nmeshgraph(self): return self._wrapped.contents.nmeshgraph @nmeshgraph.setter def nmeshgraph(self, value): self._wrapped.contents.nmeshgraph = value @property def nhfield(self): return self._wrapped.contents.nhfield @nhfield.setter def nhfield(self, value): self._wrapped.contents.nhfield = value @property def nhfielddata(self): return self._wrapped.contents.nhfielddata @nhfielddata.setter def nhfielddata(self, value): self._wrapped.contents.nhfielddata = value @property def ntex(self): return self._wrapped.contents.ntex @ntex.setter def ntex(self, value): self._wrapped.contents.ntex = value @property def ntexdata(self): return self._wrapped.contents.ntexdata @ntexdata.setter def ntexdata(self, value): self._wrapped.contents.ntexdata = value @property def nmat(self): return self._wrapped.contents.nmat @nmat.setter def nmat(self, value): self._wrapped.contents.nmat = value @property def npair(self): return self._wrapped.contents.npair @npair.setter def npair(self, value): self._wrapped.contents.npair = value @property def nexclude(self): return self._wrapped.contents.nexclude @nexclude.setter def nexclude(self, value): self._wrapped.contents.nexclude = value @property def neq(self): return self._wrapped.contents.neq @neq.setter def neq(self, value): self._wrapped.contents.neq = value @property def ntendon(self): return self._wrapped.contents.ntendon @ntendon.setter def ntendon(self, value): self._wrapped.contents.ntendon = value @property def nwrap(self): return self._wrapped.contents.nwrap @nwrap.setter def nwrap(self, value): self._wrapped.contents.nwrap = value @property def nsensor(self): return self._wrapped.contents.nsensor @nsensor.setter def nsensor(self, value): self._wrapped.contents.nsensor = value @property def nnumeric(self): return self._wrapped.contents.nnumeric @nnumeric.setter def nnumeric(self, value): self._wrapped.contents.nnumeric = value @property def nnumericdata(self): return self._wrapped.contents.nnumericdata @nnumericdata.setter def nnumericdata(self, value): self._wrapped.contents.nnumericdata = value @property def ntext(self): return self._wrapped.contents.ntext @ntext.setter def ntext(self, value): self._wrapped.contents.ntext = value @property def ntextdata(self): return self._wrapped.contents.ntextdata @ntextdata.setter def ntextdata(self, value): self._wrapped.contents.ntextdata = value @property def nkey(self): return self._wrapped.contents.nkey @nkey.setter def nkey(self, value): self._wrapped.contents.nkey = value @property def nuser_body(self): return self._wrapped.contents.nuser_body @nuser_body.setter def nuser_body(self, value): self._wrapped.contents.nuser_body = value @property def nuser_jnt(self): return self._wrapped.contents.nuser_jnt @nuser_jnt.setter def nuser_jnt(self, value): self._wrapped.contents.nuser_jnt = value @property def nuser_geom(self): return self._wrapped.contents.nuser_geom @nuser_geom.setter def nuser_geom(self, value): self._wrapped.contents.nuser_geom = value @property def nuser_site(self): return self._wrapped.contents.nuser_site @nuser_site.setter def nuser_site(self, value): self._wrapped.contents.nuser_site = value @property def nuser_tendon(self): return self._wrapped.contents.nuser_tendon @nuser_tendon.setter def nuser_tendon(self, value): self._wrapped.contents.nuser_tendon = value @property def nuser_actuator(self): return self._wrapped.contents.nuser_actuator @nuser_actuator.setter def nuser_actuator(self, value): self._wrapped.contents.nuser_actuator = value @property def nuser_sensor(self): return self._wrapped.contents.nuser_sensor @nuser_sensor.setter def nuser_sensor(self, value): self._wrapped.contents.nuser_sensor = value @property def nnames(self): return self._wrapped.contents.nnames @nnames.setter def nnames(self, value): self._wrapped.contents.nnames = value @property def nM(self): return self._wrapped.contents.nM @nM.setter def nM(self, value): self._wrapped.contents.nM = value @property def nemax(self): return self._wrapped.contents.nemax @nemax.setter def nemax(self, value): self._wrapped.contents.nemax = value @property def njmax(self): return self._wrapped.contents.njmax @njmax.setter def njmax(self, value): self._wrapped.contents.njmax = value @property def nconmax(self): return self._wrapped.contents.nconmax @nconmax.setter def nconmax(self, value): self._wrapped.contents.nconmax = value @property def nstack(self): return self._wrapped.contents.nstack @nstack.setter def nstack(self, value): self._wrapped.contents.nstack = value @property def nuserdata(self): return self._wrapped.contents.nuserdata @nuserdata.setter def nuserdata(self, value): self._wrapped.contents.nuserdata = value @property def nmocap(self): return self._wrapped.contents.nmocap @nmocap.setter def nmocap(self, value): self._wrapped.contents.nmocap = value @property def nsensordata(self): return self._wrapped.contents.nsensordata @nsensordata.setter def nsensordata(self, value): self._wrapped.contents.nsensordata = value @property def nbuffer(self): return self._wrapped.contents.nbuffer @nbuffer.setter def nbuffer(self, value): self._wrapped.contents.nbuffer = value @property def opt(self): return self._wrapped.contents.opt @opt.setter def opt(self, value): self._wrapped.contents.opt = value @property def vis(self): return self._wrapped.contents.vis @vis.setter def vis(self, value): self._wrapped.contents.vis = value @property def stat(self): return self._wrapped.contents.stat @stat.setter def stat(self, value): self._wrapped.contents.stat = value @property def buffer(self): arr = np.reshape(np.fromiter(self._wrapped.contents.buffer, dtype=np.uint8, count=self.nbuffer), (self.nbuffer,)) arr.setflags(write=False) return arr @buffer.setter def buffer(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.buffer, val_ptr, (self.nbuffer * sizeof(c_ubyte))) @property def qpos0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qpos0, dtype=np.double, count=(self.nq * 1)), (self.nq, 1)) arr.setflags(write=False) return arr @qpos0.setter def qpos0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qpos0, val_ptr, ((self.nq * 1) * sizeof(c_double))) @property def qpos_spring(self): arr = np.reshape(np.fromiter(self._wrapped.contents.qpos_spring, dtype=np.double, count=(self.nq * 1)), (self.nq, 1)) arr.setflags(write=False) return arr @qpos_spring.setter def qpos_spring(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.qpos_spring, val_ptr, ((self.nq * 1) * sizeof(c_double))) @property def body_parentid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_parentid, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_parentid.setter def body_parentid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_parentid, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_rootid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_rootid, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_rootid.setter def body_rootid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_rootid, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_weldid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_weldid, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_weldid.setter def body_weldid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_weldid, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_mocapid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_mocapid, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_mocapid.setter def body_mocapid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_mocapid, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_jntnum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_jntnum, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_jntnum.setter def body_jntnum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_jntnum, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_jntadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_jntadr, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_jntadr.setter def body_jntadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_jntadr, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_dofnum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_dofnum, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_dofnum.setter def body_dofnum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_dofnum, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_dofadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_dofadr, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_dofadr.setter def body_dofadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_dofadr, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_geomnum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_geomnum, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_geomnum.setter def body_geomnum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_geomnum, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_geomadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_geomadr, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_geomadr.setter def body_geomadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.body_geomadr, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def body_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_pos, dtype=np.double, count=(self.nbody * 3)), (self.nbody, 3)) arr.setflags(write=False) return arr @body_pos.setter def body_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_pos, val_ptr, ((self.nbody * 3) * sizeof(c_double))) @property def body_quat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_quat, dtype=np.double, count=(self.nbody * 4)), (self.nbody, 4)) arr.setflags(write=False) return arr @body_quat.setter def body_quat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_quat, val_ptr, ((self.nbody * 4) * sizeof(c_double))) @property def body_ipos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_ipos, dtype=np.double, count=(self.nbody * 3)), (self.nbody, 3)) arr.setflags(write=False) return arr @body_ipos.setter def body_ipos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_ipos, val_ptr, ((self.nbody * 3) * sizeof(c_double))) @property def body_iquat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_iquat, dtype=np.double, count=(self.nbody * 4)), (self.nbody, 4)) arr.setflags(write=False) return arr @body_iquat.setter def body_iquat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_iquat, val_ptr, ((self.nbody * 4) * sizeof(c_double))) @property def body_mass(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_mass, dtype=np.double, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @body_mass.setter def body_mass(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_mass, val_ptr, ((self.nbody * 1) * sizeof(c_double))) @property def body_inertia(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_inertia, dtype=np.double, count=(self.nbody * 3)), (self.nbody, 3)) arr.setflags(write=False) return arr @body_inertia.setter def body_inertia(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_inertia, val_ptr, ((self.nbody * 3) * sizeof(c_double))) @property def body_invweight0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_invweight0, dtype=np.double, count=(self.nbody * 2)), (self.nbody, 2)) arr.setflags(write=False) return arr @body_invweight0.setter def body_invweight0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_invweight0, val_ptr, ((self.nbody * 2) * sizeof(c_double))) @property def body_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.body_user, dtype=np.double, count=(self.nbody * self.nuser_body)), (self.nbody, self.nuser_body)) arr.setflags(write=False) return arr @body_user.setter def body_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.body_user, val_ptr, ((self.nbody * self.nuser_body) * sizeof(c_double))) @property def jnt_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_type, dtype=np.int, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_type.setter def jnt_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.jnt_type, val_ptr, ((self.njnt * 1) * sizeof(c_int))) @property def jnt_qposadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_qposadr, dtype=np.int, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_qposadr.setter def jnt_qposadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.jnt_qposadr, val_ptr, ((self.njnt * 1) * sizeof(c_int))) @property def jnt_dofadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_dofadr, dtype=np.int, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_dofadr.setter def jnt_dofadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.jnt_dofadr, val_ptr, ((self.njnt * 1) * sizeof(c_int))) @property def jnt_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_bodyid, dtype=np.int, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_bodyid.setter def jnt_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.jnt_bodyid, val_ptr, ((self.njnt * 1) * sizeof(c_int))) @property def jnt_limited(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_limited, dtype=np.uint8, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_limited.setter def jnt_limited(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.jnt_limited, val_ptr, ((self.njnt * 1) * sizeof(c_ubyte))) @property def jnt_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_solref, dtype=np.double, count=(self.njnt * 2)), (self.njnt, 2)) arr.setflags(write=False) return arr @jnt_solref.setter def jnt_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_solref, val_ptr, ((self.njnt * 2) * sizeof(c_double))) @property def jnt_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_solimp, dtype=np.double, count=(self.njnt * 3)), (self.njnt, 3)) arr.setflags(write=False) return arr @jnt_solimp.setter def jnt_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_solimp, val_ptr, ((self.njnt * 3) * sizeof(c_double))) @property def jnt_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_pos, dtype=np.double, count=(self.njnt * 3)), (self.njnt, 3)) arr.setflags(write=False) return arr @jnt_pos.setter def jnt_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_pos, val_ptr, ((self.njnt * 3) * sizeof(c_double))) @property def jnt_axis(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_axis, dtype=np.double, count=(self.njnt * 3)), (self.njnt, 3)) arr.setflags(write=False) return arr @jnt_axis.setter def jnt_axis(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_axis, val_ptr, ((self.njnt * 3) * sizeof(c_double))) @property def jnt_stiffness(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_stiffness, dtype=np.double, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_stiffness.setter def jnt_stiffness(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_stiffness, val_ptr, ((self.njnt * 1) * sizeof(c_double))) @property def jnt_range(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_range, dtype=np.double, count=(self.njnt * 2)), (self.njnt, 2)) arr.setflags(write=False) return arr @jnt_range.setter def jnt_range(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_range, val_ptr, ((self.njnt * 2) * sizeof(c_double))) @property def jnt_margin(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_margin, dtype=np.double, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @jnt_margin.setter def jnt_margin(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_margin, val_ptr, ((self.njnt * 1) * sizeof(c_double))) @property def jnt_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.jnt_user, dtype=np.double, count=(self.njnt * self.nuser_jnt)), (self.njnt, self.nuser_jnt)) arr.setflags(write=False) return arr @jnt_user.setter def jnt_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.jnt_user, val_ptr, ((self.njnt * self.nuser_jnt) * sizeof(c_double))) @property def dof_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_bodyid, dtype=np.int, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_bodyid.setter def dof_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.dof_bodyid, val_ptr, ((self.nv * 1) * sizeof(c_int))) @property def dof_jntid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_jntid, dtype=np.int, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_jntid.setter def dof_jntid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.dof_jntid, val_ptr, ((self.nv * 1) * sizeof(c_int))) @property def dof_parentid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_parentid, dtype=np.int, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_parentid.setter def dof_parentid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.dof_parentid, val_ptr, ((self.nv * 1) * sizeof(c_int))) @property def dof_Madr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_Madr, dtype=np.int, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_Madr.setter def dof_Madr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.dof_Madr, val_ptr, ((self.nv * 1) * sizeof(c_int))) @property def dof_frictional(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_frictional, dtype=np.uint8, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_frictional.setter def dof_frictional(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.dof_frictional, val_ptr, ((self.nv * 1) * sizeof(c_ubyte))) @property def dof_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_solref, dtype=np.double, count=(self.nv * 2)), (self.nv, 2)) arr.setflags(write=False) return arr @dof_solref.setter def dof_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_solref, val_ptr, ((self.nv * 2) * sizeof(c_double))) @property def dof_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_solimp, dtype=np.double, count=(self.nv * 3)), (self.nv, 3)) arr.setflags(write=False) return arr @dof_solimp.setter def dof_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_solimp, val_ptr, ((self.nv * 3) * sizeof(c_double))) @property def dof_frictionloss(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_frictionloss, dtype=np.double, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_frictionloss.setter def dof_frictionloss(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_frictionloss, val_ptr, ((self.nv * 1) * sizeof(c_double))) @property def dof_armature(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_armature, dtype=np.double, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_armature.setter def dof_armature(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_armature, val_ptr, ((self.nv * 1) * sizeof(c_double))) @property def dof_damping(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_damping, dtype=np.double, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_damping.setter def dof_damping(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_damping, val_ptr, ((self.nv * 1) * sizeof(c_double))) @property def dof_invweight0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.dof_invweight0, dtype=np.double, count=(self.nv * 1)), (self.nv, 1)) arr.setflags(write=False) return arr @dof_invweight0.setter def dof_invweight0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.dof_invweight0, val_ptr, ((self.nv * 1) * sizeof(c_double))) @property def geom_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_type, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_type.setter def geom_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_type, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_contype(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_contype, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_contype.setter def geom_contype(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_contype, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_conaffinity(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_conaffinity, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_conaffinity.setter def geom_conaffinity(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_conaffinity, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_condim(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_condim, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_condim.setter def geom_condim(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_condim, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_bodyid, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_bodyid.setter def geom_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_bodyid, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_dataid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_dataid, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_dataid.setter def geom_dataid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_dataid, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_matid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_matid, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_matid.setter def geom_matid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_matid, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_group(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_group, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_group.setter def geom_group(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.geom_group, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def geom_solmix(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_solmix, dtype=np.double, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_solmix.setter def geom_solmix(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_solmix, val_ptr, ((self.ngeom * 1) * sizeof(c_double))) @property def geom_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_solref, dtype=np.double, count=(self.ngeom * 2)), (self.ngeom, 2)) arr.setflags(write=False) return arr @geom_solref.setter def geom_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_solref, val_ptr, ((self.ngeom * 2) * sizeof(c_double))) @property def geom_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_solimp, dtype=np.double, count=(self.ngeom * 3)), (self.ngeom, 3)) arr.setflags(write=False) return arr @geom_solimp.setter def geom_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_solimp, val_ptr, ((self.ngeom * 3) * sizeof(c_double))) @property def geom_size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_size, dtype=np.double, count=(self.ngeom * 3)), (self.ngeom, 3)) arr.setflags(write=False) return arr @geom_size.setter def geom_size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_size, val_ptr, ((self.ngeom * 3) * sizeof(c_double))) @property def geom_rbound(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_rbound, dtype=np.double, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_rbound.setter def geom_rbound(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_rbound, val_ptr, ((self.ngeom * 1) * sizeof(c_double))) @property def geom_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_pos, dtype=np.double, count=(self.ngeom * 3)), (self.ngeom, 3)) arr.setflags(write=False) return arr @geom_pos.setter def geom_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_pos, val_ptr, ((self.ngeom * 3) * sizeof(c_double))) @property def geom_quat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_quat, dtype=np.double, count=(self.ngeom * 4)), (self.ngeom, 4)) arr.setflags(write=False) return arr @geom_quat.setter def geom_quat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_quat, val_ptr, ((self.ngeom * 4) * sizeof(c_double))) @property def geom_friction(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_friction, dtype=np.double, count=(self.ngeom * 3)), (self.ngeom, 3)) arr.setflags(write=False) return arr @geom_friction.setter def geom_friction(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_friction, val_ptr, ((self.ngeom * 3) * sizeof(c_double))) @property def geom_margin(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_margin, dtype=np.double, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_margin.setter def geom_margin(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_margin, val_ptr, ((self.ngeom * 1) * sizeof(c_double))) @property def geom_gap(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_gap, dtype=np.double, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @geom_gap.setter def geom_gap(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_gap, val_ptr, ((self.ngeom * 1) * sizeof(c_double))) @property def geom_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_user, dtype=np.double, count=(self.ngeom * self.nuser_geom)), (self.ngeom, self.nuser_geom)) arr.setflags(write=False) return arr @geom_user.setter def geom_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.geom_user, val_ptr, ((self.ngeom * self.nuser_geom) * sizeof(c_double))) @property def geom_rgba(self): arr = np.reshape(np.fromiter(self._wrapped.contents.geom_rgba, dtype=np.float, count=(self.ngeom * 4)), (self.ngeom, 4)) arr.setflags(write=False) return arr @geom_rgba.setter def geom_rgba(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.geom_rgba, val_ptr, ((self.ngeom * 4) * sizeof(c_float))) @property def site_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_type, dtype=np.int, count=(self.nsite * 1)), (self.nsite, 1)) arr.setflags(write=False) return arr @site_type.setter def site_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.site_type, val_ptr, ((self.nsite * 1) * sizeof(c_int))) @property def site_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_bodyid, dtype=np.int, count=(self.nsite * 1)), (self.nsite, 1)) arr.setflags(write=False) return arr @site_bodyid.setter def site_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.site_bodyid, val_ptr, ((self.nsite * 1) * sizeof(c_int))) @property def site_matid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_matid, dtype=np.int, count=(self.nsite * 1)), (self.nsite, 1)) arr.setflags(write=False) return arr @site_matid.setter def site_matid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.site_matid, val_ptr, ((self.nsite * 1) * sizeof(c_int))) @property def site_group(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_group, dtype=np.int, count=(self.nsite * 1)), (self.nsite, 1)) arr.setflags(write=False) return arr @site_group.setter def site_group(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.site_group, val_ptr, ((self.nsite * 1) * sizeof(c_int))) @property def site_size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_size, dtype=np.double, count=(self.nsite * 3)), (self.nsite, 3)) arr.setflags(write=False) return arr @site_size.setter def site_size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_size, val_ptr, ((self.nsite * 3) * sizeof(c_double))) @property def site_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_pos, dtype=np.double, count=(self.nsite * 3)), (self.nsite, 3)) arr.setflags(write=False) return arr @site_pos.setter def site_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_pos, val_ptr, ((self.nsite * 3) * sizeof(c_double))) @property def site_quat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_quat, dtype=np.double, count=(self.nsite * 4)), (self.nsite, 4)) arr.setflags(write=False) return arr @site_quat.setter def site_quat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_quat, val_ptr, ((self.nsite * 4) * sizeof(c_double))) @property def site_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_user, dtype=np.double, count=(self.nsite * self.nuser_site)), (self.nsite, self.nuser_site)) arr.setflags(write=False) return arr @site_user.setter def site_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.site_user, val_ptr, ((self.nsite * self.nuser_site) * sizeof(c_double))) @property def site_rgba(self): arr = np.reshape(np.fromiter(self._wrapped.contents.site_rgba, dtype=np.float, count=(self.nsite * 4)), (self.nsite, 4)) arr.setflags(write=False) return arr @site_rgba.setter def site_rgba(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.site_rgba, val_ptr, ((self.nsite * 4) * sizeof(c_float))) @property def cam_mode(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_mode, dtype=np.int, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @cam_mode.setter def cam_mode(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.cam_mode, val_ptr, ((self.ncam * 1) * sizeof(c_int))) @property def cam_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_bodyid, dtype=np.int, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @cam_bodyid.setter def cam_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.cam_bodyid, val_ptr, ((self.ncam * 1) * sizeof(c_int))) @property def cam_targetbodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_targetbodyid, dtype=np.int, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @cam_targetbodyid.setter def cam_targetbodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.cam_targetbodyid, val_ptr, ((self.ncam * 1) * sizeof(c_int))) @property def cam_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_pos, dtype=np.double, count=(self.ncam * 3)), (self.ncam, 3)) arr.setflags(write=False) return arr @cam_pos.setter def cam_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_pos, val_ptr, ((self.ncam * 3) * sizeof(c_double))) @property def cam_quat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_quat, dtype=np.double, count=(self.ncam * 4)), (self.ncam, 4)) arr.setflags(write=False) return arr @cam_quat.setter def cam_quat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_quat, val_ptr, ((self.ncam * 4) * sizeof(c_double))) @property def cam_poscom0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_poscom0, dtype=np.double, count=(self.ncam * 3)), (self.ncam, 3)) arr.setflags(write=False) return arr @cam_poscom0.setter def cam_poscom0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_poscom0, val_ptr, ((self.ncam * 3) * sizeof(c_double))) @property def cam_pos0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_pos0, dtype=np.double, count=(self.ncam * 3)), (self.ncam, 3)) arr.setflags(write=False) return arr @cam_pos0.setter def cam_pos0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_pos0, val_ptr, ((self.ncam * 3) * sizeof(c_double))) @property def cam_mat0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_mat0, dtype=np.double, count=(self.ncam * 9)), (self.ncam, 9)) arr.setflags(write=False) return arr @cam_mat0.setter def cam_mat0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_mat0, val_ptr, ((self.ncam * 9) * sizeof(c_double))) @property def cam_fovy(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_fovy, dtype=np.double, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @cam_fovy.setter def cam_fovy(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_fovy, val_ptr, ((self.ncam * 1) * sizeof(c_double))) @property def cam_ipd(self): arr = np.reshape(np.fromiter(self._wrapped.contents.cam_ipd, dtype=np.double, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @cam_ipd.setter def cam_ipd(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.cam_ipd, val_ptr, ((self.ncam * 1) * sizeof(c_double))) @property def light_mode(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_mode, dtype=np.int, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_mode.setter def light_mode(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.light_mode, val_ptr, ((self.nlight * 1) * sizeof(c_int))) @property def light_bodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_bodyid, dtype=np.int, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_bodyid.setter def light_bodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.light_bodyid, val_ptr, ((self.nlight * 1) * sizeof(c_int))) @property def light_targetbodyid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_targetbodyid, dtype=np.int, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_targetbodyid.setter def light_targetbodyid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.light_targetbodyid, val_ptr, ((self.nlight * 1) * sizeof(c_int))) @property def light_directional(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_directional, dtype=np.uint8, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_directional.setter def light_directional(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.light_directional, val_ptr, ((self.nlight * 1) * sizeof(c_ubyte))) @property def light_castshadow(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_castshadow, dtype=np.uint8, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_castshadow.setter def light_castshadow(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.light_castshadow, val_ptr, ((self.nlight * 1) * sizeof(c_ubyte))) @property def light_active(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_active, dtype=np.uint8, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_active.setter def light_active(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.light_active, val_ptr, ((self.nlight * 1) * sizeof(c_ubyte))) @property def light_pos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_pos, dtype=np.double, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_pos.setter def light_pos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_pos, val_ptr, ((self.nlight * 3) * sizeof(c_double))) @property def light_dir(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_dir, dtype=np.double, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_dir.setter def light_dir(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_dir, val_ptr, ((self.nlight * 3) * sizeof(c_double))) @property def light_poscom0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_poscom0, dtype=np.double, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_poscom0.setter def light_poscom0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_poscom0, val_ptr, ((self.nlight * 3) * sizeof(c_double))) @property def light_pos0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_pos0, dtype=np.double, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_pos0.setter def light_pos0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_pos0, val_ptr, ((self.nlight * 3) * sizeof(c_double))) @property def light_dir0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_dir0, dtype=np.double, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_dir0.setter def light_dir0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.light_dir0, val_ptr, ((self.nlight * 3) * sizeof(c_double))) @property def light_attenuation(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_attenuation, dtype=np.float, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_attenuation.setter def light_attenuation(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_attenuation, val_ptr, ((self.nlight * 3) * sizeof(c_float))) @property def light_cutoff(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_cutoff, dtype=np.float, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_cutoff.setter def light_cutoff(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_cutoff, val_ptr, ((self.nlight * 1) * sizeof(c_float))) @property def light_exponent(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_exponent, dtype=np.float, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @light_exponent.setter def light_exponent(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_exponent, val_ptr, ((self.nlight * 1) * sizeof(c_float))) @property def light_ambient(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_ambient, dtype=np.float, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_ambient.setter def light_ambient(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_ambient, val_ptr, ((self.nlight * 3) * sizeof(c_float))) @property def light_diffuse(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_diffuse, dtype=np.float, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_diffuse.setter def light_diffuse(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_diffuse, val_ptr, ((self.nlight * 3) * sizeof(c_float))) @property def light_specular(self): arr = np.reshape(np.fromiter(self._wrapped.contents.light_specular, dtype=np.float, count=(self.nlight * 3)), (self.nlight, 3)) arr.setflags(write=False) return arr @light_specular.setter def light_specular(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.light_specular, val_ptr, ((self.nlight * 3) * sizeof(c_float))) @property def mesh_faceadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_faceadr, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @mesh_faceadr.setter def mesh_faceadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_faceadr, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def mesh_facenum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_facenum, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @mesh_facenum.setter def mesh_facenum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_facenum, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def mesh_vertadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_vertadr, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @mesh_vertadr.setter def mesh_vertadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_vertadr, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def mesh_vertnum(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_vertnum, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @mesh_vertnum.setter def mesh_vertnum(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_vertnum, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def mesh_graphadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_graphadr, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @mesh_graphadr.setter def mesh_graphadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_graphadr, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def mesh_vert(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_vert, dtype=np.float, count=(self.nmeshvert * 3)), (self.nmeshvert, 3)) arr.setflags(write=False) return arr @mesh_vert.setter def mesh_vert(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mesh_vert, val_ptr, ((self.nmeshvert * 3) * sizeof(c_float))) @property def mesh_normal(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_normal, dtype=np.float, count=(self.nmeshvert * 3)), (self.nmeshvert, 3)) arr.setflags(write=False) return arr @mesh_normal.setter def mesh_normal(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mesh_normal, val_ptr, ((self.nmeshvert * 3) * sizeof(c_float))) @property def mesh_face(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_face, dtype=np.int, count=(self.nmeshface * 3)), (self.nmeshface, 3)) arr.setflags(write=False) return arr @mesh_face.setter def mesh_face(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_face, val_ptr, ((self.nmeshface * 3) * sizeof(c_int))) @property def mesh_graph(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mesh_graph, dtype=np.int, count=(self.nmeshgraph * 1)), (self.nmeshgraph, 1)) arr.setflags(write=False) return arr @mesh_graph.setter def mesh_graph(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mesh_graph, val_ptr, ((self.nmeshgraph * 1) * sizeof(c_int))) @property def hfield_size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.hfield_size, dtype=np.double, count=(self.nhfield * 4)), (self.nhfield, 4)) arr.setflags(write=False) return arr @hfield_size.setter def hfield_size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.hfield_size, val_ptr, ((self.nhfield * 4) * sizeof(c_double))) @property def hfield_nrow(self): arr = np.reshape(np.fromiter(self._wrapped.contents.hfield_nrow, dtype=np.int, count=(self.nhfield * 1)), (self.nhfield, 1)) arr.setflags(write=False) return arr @hfield_nrow.setter def hfield_nrow(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.hfield_nrow, val_ptr, ((self.nhfield * 1) * sizeof(c_int))) @property def hfield_ncol(self): arr = np.reshape(np.fromiter(self._wrapped.contents.hfield_ncol, dtype=np.int, count=(self.nhfield * 1)), (self.nhfield, 1)) arr.setflags(write=False) return arr @hfield_ncol.setter def hfield_ncol(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.hfield_ncol, val_ptr, ((self.nhfield * 1) * sizeof(c_int))) @property def hfield_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.hfield_adr, dtype=np.int, count=(self.nhfield * 1)), (self.nhfield, 1)) arr.setflags(write=False) return arr @hfield_adr.setter def hfield_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.hfield_adr, val_ptr, ((self.nhfield * 1) * sizeof(c_int))) @property def hfield_data(self): arr = np.reshape(np.fromiter(self._wrapped.contents.hfield_data, dtype=np.float, count=(self.nhfielddata * 1)), (self.nhfielddata, 1)) arr.setflags(write=False) return arr @hfield_data.setter def hfield_data(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.hfield_data, val_ptr, ((self.nhfielddata * 1) * sizeof(c_float))) @property def tex_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tex_type, dtype=np.int, count=(self.ntex * 1)), (self.ntex, 1)) arr.setflags(write=False) return arr @tex_type.setter def tex_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tex_type, val_ptr, ((self.ntex * 1) * sizeof(c_int))) @property def tex_height(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tex_height, dtype=np.int, count=(self.ntex * 1)), (self.ntex, 1)) arr.setflags(write=False) return arr @tex_height.setter def tex_height(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tex_height, val_ptr, ((self.ntex * 1) * sizeof(c_int))) @property def tex_width(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tex_width, dtype=np.int, count=(self.ntex * 1)), (self.ntex, 1)) arr.setflags(write=False) return arr @tex_width.setter def tex_width(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tex_width, val_ptr, ((self.ntex * 1) * sizeof(c_int))) @property def tex_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tex_adr, dtype=np.int, count=(self.ntex * 1)), (self.ntex, 1)) arr.setflags(write=False) return arr @tex_adr.setter def tex_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tex_adr, val_ptr, ((self.ntex * 1) * sizeof(c_int))) @property def tex_rgb(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tex_rgb, dtype=np.uint8, count=(self.ntexdata * 1)), (self.ntexdata, 1)) arr.setflags(write=False) return arr @tex_rgb.setter def tex_rgb(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.tex_rgb, val_ptr, ((self.ntexdata * 1) * sizeof(c_ubyte))) @property def mat_texid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_texid, dtype=np.int, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_texid.setter def mat_texid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.mat_texid, val_ptr, ((self.nmat * 1) * sizeof(c_int))) @property def mat_texuniform(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_texuniform, dtype=np.uint8, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_texuniform.setter def mat_texuniform(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.mat_texuniform, val_ptr, ((self.nmat * 1) * sizeof(c_ubyte))) @property def mat_texrepeat(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_texrepeat, dtype=np.float, count=(self.nmat * 2)), (self.nmat, 2)) arr.setflags(write=False) return arr @mat_texrepeat.setter def mat_texrepeat(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_texrepeat, val_ptr, ((self.nmat * 2) * sizeof(c_float))) @property def mat_emission(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_emission, dtype=np.float, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_emission.setter def mat_emission(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_emission, val_ptr, ((self.nmat * 1) * sizeof(c_float))) @property def mat_specular(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_specular, dtype=np.float, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_specular.setter def mat_specular(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_specular, val_ptr, ((self.nmat * 1) * sizeof(c_float))) @property def mat_shininess(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_shininess, dtype=np.float, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_shininess.setter def mat_shininess(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_shininess, val_ptr, ((self.nmat * 1) * sizeof(c_float))) @property def mat_reflectance(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_reflectance, dtype=np.float, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @mat_reflectance.setter def mat_reflectance(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_reflectance, val_ptr, ((self.nmat * 1) * sizeof(c_float))) @property def mat_rgba(self): arr = np.reshape(np.fromiter(self._wrapped.contents.mat_rgba, dtype=np.float, count=(self.nmat * 4)), (self.nmat, 4)) arr.setflags(write=False) return arr @mat_rgba.setter def mat_rgba(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.mat_rgba, val_ptr, ((self.nmat * 4) * sizeof(c_float))) @property def pair_dim(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_dim, dtype=np.int, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_dim.setter def pair_dim(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.pair_dim, val_ptr, ((self.npair * 1) * sizeof(c_int))) @property def pair_geom1(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_geom1, dtype=np.int, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_geom1.setter def pair_geom1(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.pair_geom1, val_ptr, ((self.npair * 1) * sizeof(c_int))) @property def pair_geom2(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_geom2, dtype=np.int, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_geom2.setter def pair_geom2(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.pair_geom2, val_ptr, ((self.npair * 1) * sizeof(c_int))) @property def pair_signature(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_signature, dtype=np.int, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_signature.setter def pair_signature(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.pair_signature, val_ptr, ((self.npair * 1) * sizeof(c_int))) @property def pair_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_solref, dtype=np.double, count=(self.npair * 2)), (self.npair, 2)) arr.setflags(write=False) return arr @pair_solref.setter def pair_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pair_solref, val_ptr, ((self.npair * 2) * sizeof(c_double))) @property def pair_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_solimp, dtype=np.double, count=(self.npair * 3)), (self.npair, 3)) arr.setflags(write=False) return arr @pair_solimp.setter def pair_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pair_solimp, val_ptr, ((self.npair * 3) * sizeof(c_double))) @property def pair_margin(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_margin, dtype=np.double, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_margin.setter def pair_margin(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pair_margin, val_ptr, ((self.npair * 1) * sizeof(c_double))) @property def pair_gap(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_gap, dtype=np.double, count=(self.npair * 1)), (self.npair, 1)) arr.setflags(write=False) return arr @pair_gap.setter def pair_gap(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pair_gap, val_ptr, ((self.npair * 1) * sizeof(c_double))) @property def pair_friction(self): arr = np.reshape(np.fromiter(self._wrapped.contents.pair_friction, dtype=np.double, count=(self.npair * 5)), (self.npair, 5)) arr.setflags(write=False) return arr @pair_friction.setter def pair_friction(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.pair_friction, val_ptr, ((self.npair * 5) * sizeof(c_double))) @property def exclude_signature(self): arr = np.reshape(np.fromiter(self._wrapped.contents.exclude_signature, dtype=np.int, count=(self.nexclude * 1)), (self.nexclude, 1)) arr.setflags(write=False) return arr @exclude_signature.setter def exclude_signature(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.exclude_signature, val_ptr, ((self.nexclude * 1) * sizeof(c_int))) @property def eq_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_type, dtype=np.int, count=(self.neq * 1)), (self.neq, 1)) arr.setflags(write=False) return arr @eq_type.setter def eq_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.eq_type, val_ptr, ((self.neq * 1) * sizeof(c_int))) @property def eq_obj1id(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_obj1id, dtype=np.int, count=(self.neq * 1)), (self.neq, 1)) arr.setflags(write=False) return arr @eq_obj1id.setter def eq_obj1id(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.eq_obj1id, val_ptr, ((self.neq * 1) * sizeof(c_int))) @property def eq_obj2id(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_obj2id, dtype=np.int, count=(self.neq * 1)), (self.neq, 1)) arr.setflags(write=False) return arr @eq_obj2id.setter def eq_obj2id(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.eq_obj2id, val_ptr, ((self.neq * 1) * sizeof(c_int))) @property def eq_active(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_active, dtype=np.uint8, count=(self.neq * 1)), (self.neq, 1)) arr.setflags(write=False) return arr @eq_active.setter def eq_active(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.eq_active, val_ptr, ((self.neq * 1) * sizeof(c_ubyte))) @property def eq_solref(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_solref, dtype=np.double, count=(self.neq * 2)), (self.neq, 2)) arr.setflags(write=False) return arr @eq_solref.setter def eq_solref(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.eq_solref, val_ptr, ((self.neq * 2) * sizeof(c_double))) @property def eq_solimp(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_solimp, dtype=np.double, count=(self.neq * 3)), (self.neq, 3)) arr.setflags(write=False) return arr @eq_solimp.setter def eq_solimp(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.eq_solimp, val_ptr, ((self.neq * 3) * sizeof(c_double))) @property def eq_data(self): arr = np.reshape(np.fromiter(self._wrapped.contents.eq_data, dtype=np.double, count=(self.neq * 7)), (self.neq, 7)) arr.setflags(write=False) return arr @eq_data.setter def eq_data(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.eq_data, val_ptr, ((self.neq * 7) * sizeof(c_double))) @property def tendon_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_adr, dtype=np.int, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_adr.setter def tendon_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tendon_adr, val_ptr, ((self.ntendon * 1) * sizeof(c_int))) @property def tendon_num(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_num, dtype=np.int, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_num.setter def tendon_num(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tendon_num, val_ptr, ((self.ntendon * 1) * sizeof(c_int))) @property def tendon_matid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_matid, dtype=np.int, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_matid.setter def tendon_matid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.tendon_matid, val_ptr, ((self.ntendon * 1) * sizeof(c_int))) @property def tendon_limited(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_limited, dtype=np.uint8, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_limited.setter def tendon_limited(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.tendon_limited, val_ptr, ((self.ntendon * 1) * sizeof(c_ubyte))) @property def tendon_frictional(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_frictional, dtype=np.uint8, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_frictional.setter def tendon_frictional(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.tendon_frictional, val_ptr, ((self.ntendon * 1) * sizeof(c_ubyte))) @property def tendon_width(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_width, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_width.setter def tendon_width(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_width, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_solref_lim(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_solref_lim, dtype=np.double, count=(self.ntendon * 2)), (self.ntendon, 2)) arr.setflags(write=False) return arr @tendon_solref_lim.setter def tendon_solref_lim(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_solref_lim, val_ptr, ((self.ntendon * 2) * sizeof(c_double))) @property def tendon_solimp_lim(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_solimp_lim, dtype=np.double, count=(self.ntendon * 3)), (self.ntendon, 3)) arr.setflags(write=False) return arr @tendon_solimp_lim.setter def tendon_solimp_lim(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_solimp_lim, val_ptr, ((self.ntendon * 3) * sizeof(c_double))) @property def tendon_solref_fri(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_solref_fri, dtype=np.double, count=(self.ntendon * 2)), (self.ntendon, 2)) arr.setflags(write=False) return arr @tendon_solref_fri.setter def tendon_solref_fri(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_solref_fri, val_ptr, ((self.ntendon * 2) * sizeof(c_double))) @property def tendon_solimp_fri(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_solimp_fri, dtype=np.double, count=(self.ntendon * 3)), (self.ntendon, 3)) arr.setflags(write=False) return arr @tendon_solimp_fri.setter def tendon_solimp_fri(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_solimp_fri, val_ptr, ((self.ntendon * 3) * sizeof(c_double))) @property def tendon_range(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_range, dtype=np.double, count=(self.ntendon * 2)), (self.ntendon, 2)) arr.setflags(write=False) return arr @tendon_range.setter def tendon_range(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_range, val_ptr, ((self.ntendon * 2) * sizeof(c_double))) @property def tendon_margin(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_margin, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_margin.setter def tendon_margin(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_margin, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_stiffness(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_stiffness, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_stiffness.setter def tendon_stiffness(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_stiffness, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_damping(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_damping, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_damping.setter def tendon_damping(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_damping, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_frictionloss(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_frictionloss, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_frictionloss.setter def tendon_frictionloss(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_frictionloss, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_lengthspring(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_lengthspring, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_lengthspring.setter def tendon_lengthspring(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_lengthspring, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_length0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_length0, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_length0.setter def tendon_length0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_length0, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_invweight0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_invweight0, dtype=np.double, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @tendon_invweight0.setter def tendon_invweight0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_invweight0, val_ptr, ((self.ntendon * 1) * sizeof(c_double))) @property def tendon_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_user, dtype=np.double, count=(self.ntendon * self.nuser_tendon)), (self.ntendon, self.nuser_tendon)) arr.setflags(write=False) return arr @tendon_user.setter def tendon_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.tendon_user, val_ptr, ((self.ntendon * self.nuser_tendon) * sizeof(c_double))) @property def tendon_rgba(self): arr = np.reshape(np.fromiter(self._wrapped.contents.tendon_rgba, dtype=np.float, count=(self.ntendon * 4)), (self.ntendon, 4)) arr.setflags(write=False) return arr @tendon_rgba.setter def tendon_rgba(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_float)) memmove(self._wrapped.contents.tendon_rgba, val_ptr, ((self.ntendon * 4) * sizeof(c_float))) @property def wrap_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wrap_type, dtype=np.int, count=(self.nwrap * 1)), (self.nwrap, 1)) arr.setflags(write=False) return arr @wrap_type.setter def wrap_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.wrap_type, val_ptr, ((self.nwrap * 1) * sizeof(c_int))) @property def wrap_objid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wrap_objid, dtype=np.int, count=(self.nwrap * 1)), (self.nwrap, 1)) arr.setflags(write=False) return arr @wrap_objid.setter def wrap_objid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.wrap_objid, val_ptr, ((self.nwrap * 1) * sizeof(c_int))) @property def wrap_prm(self): arr = np.reshape(np.fromiter(self._wrapped.contents.wrap_prm, dtype=np.double, count=(self.nwrap * 1)), (self.nwrap, 1)) arr.setflags(write=False) return arr @wrap_prm.setter def wrap_prm(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.wrap_prm, val_ptr, ((self.nwrap * 1) * sizeof(c_double))) @property def actuator_trntype(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_trntype, dtype=np.int, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_trntype.setter def actuator_trntype(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.actuator_trntype, val_ptr, ((self.nu * 1) * sizeof(c_int))) @property def actuator_dyntype(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_dyntype, dtype=np.int, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_dyntype.setter def actuator_dyntype(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.actuator_dyntype, val_ptr, ((self.nu * 1) * sizeof(c_int))) @property def actuator_gaintype(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_gaintype, dtype=np.int, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_gaintype.setter def actuator_gaintype(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.actuator_gaintype, val_ptr, ((self.nu * 1) * sizeof(c_int))) @property def actuator_biastype(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_biastype, dtype=np.int, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_biastype.setter def actuator_biastype(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.actuator_biastype, val_ptr, ((self.nu * 1) * sizeof(c_int))) @property def actuator_trnid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_trnid, dtype=np.int, count=(self.nu * 2)), (self.nu, 2)) arr.setflags(write=False) return arr @actuator_trnid.setter def actuator_trnid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.actuator_trnid, val_ptr, ((self.nu * 2) * sizeof(c_int))) @property def actuator_ctrllimited(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_ctrllimited, dtype=np.uint8, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_ctrllimited.setter def actuator_ctrllimited(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.actuator_ctrllimited, val_ptr, ((self.nu * 1) * sizeof(c_ubyte))) @property def actuator_forcelimited(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_forcelimited, dtype=np.uint8, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_forcelimited.setter def actuator_forcelimited(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_ubyte)) memmove(self._wrapped.contents.actuator_forcelimited, val_ptr, ((self.nu * 1) * sizeof(c_ubyte))) @property def actuator_dynprm(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_dynprm, dtype=np.double, count=(self.nu * 3)), (self.nu, 3)) arr.setflags(write=False) return arr @actuator_dynprm.setter def actuator_dynprm(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_dynprm, val_ptr, ((self.nu * 3) * sizeof(c_double))) @property def actuator_gainprm(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_gainprm, dtype=np.double, count=(self.nu * 3)), (self.nu, 3)) arr.setflags(write=False) return arr @actuator_gainprm.setter def actuator_gainprm(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_gainprm, val_ptr, ((self.nu * 3) * sizeof(c_double))) @property def actuator_biasprm(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_biasprm, dtype=np.double, count=(self.nu * 3)), (self.nu, 3)) arr.setflags(write=False) return arr @actuator_biasprm.setter def actuator_biasprm(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_biasprm, val_ptr, ((self.nu * 3) * sizeof(c_double))) @property def actuator_ctrlrange(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_ctrlrange, dtype=np.double, count=(self.nu * 2)), (self.nu, 2)) arr.setflags(write=False) return arr @actuator_ctrlrange.setter def actuator_ctrlrange(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_ctrlrange, val_ptr, ((self.nu * 2) * sizeof(c_double))) @property def actuator_forcerange(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_forcerange, dtype=np.double, count=(self.nu * 2)), (self.nu, 2)) arr.setflags(write=False) return arr @actuator_forcerange.setter def actuator_forcerange(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_forcerange, val_ptr, ((self.nu * 2) * sizeof(c_double))) @property def actuator_gear(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_gear, dtype=np.double, count=(self.nu * 6)), (self.nu, 6)) arr.setflags(write=False) return arr @actuator_gear.setter def actuator_gear(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_gear, val_ptr, ((self.nu * 6) * sizeof(c_double))) @property def actuator_cranklength(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_cranklength, dtype=np.double, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_cranklength.setter def actuator_cranklength(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_cranklength, val_ptr, ((self.nu * 1) * sizeof(c_double))) @property def actuator_invweight0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_invweight0, dtype=np.double, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_invweight0.setter def actuator_invweight0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_invweight0, val_ptr, ((self.nu * 1) * sizeof(c_double))) @property def actuator_length0(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_length0, dtype=np.double, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @actuator_length0.setter def actuator_length0(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_length0, val_ptr, ((self.nu * 1) * sizeof(c_double))) @property def actuator_lengthrange(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_lengthrange, dtype=np.double, count=(self.nu * 2)), (self.nu, 2)) arr.setflags(write=False) return arr @actuator_lengthrange.setter def actuator_lengthrange(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_lengthrange, val_ptr, ((self.nu * 2) * sizeof(c_double))) @property def actuator_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.actuator_user, dtype=np.double, count=(self.nu * self.nuser_actuator)), (self.nu, self.nuser_actuator)) arr.setflags(write=False) return arr @actuator_user.setter def actuator_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.actuator_user, val_ptr, ((self.nu * self.nuser_actuator) * sizeof(c_double))) @property def sensor_type(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_type, dtype=np.int, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @sensor_type.setter def sensor_type(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.sensor_type, val_ptr, ((self.nsensor * 1) * sizeof(c_int))) @property def sensor_objid(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_objid, dtype=np.int, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @sensor_objid.setter def sensor_objid(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.sensor_objid, val_ptr, ((self.nsensor * 1) * sizeof(c_int))) @property def sensor_dim(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_dim, dtype=np.int, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @sensor_dim.setter def sensor_dim(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.sensor_dim, val_ptr, ((self.nsensor * 1) * sizeof(c_int))) @property def sensor_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_adr, dtype=np.int, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @sensor_adr.setter def sensor_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.sensor_adr, val_ptr, ((self.nsensor * 1) * sizeof(c_int))) @property def sensor_scale(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_scale, dtype=np.double, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @sensor_scale.setter def sensor_scale(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.sensor_scale, val_ptr, ((self.nsensor * 1) * sizeof(c_double))) @property def sensor_user(self): arr = np.reshape(np.fromiter(self._wrapped.contents.sensor_user, dtype=np.double, count=(self.nsensor * self.nuser_sensor)), (self.nsensor, self.nuser_sensor)) arr.setflags(write=False) return arr @sensor_user.setter def sensor_user(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.sensor_user, val_ptr, ((self.nsensor * self.nuser_sensor) * sizeof(c_double))) @property def numeric_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.numeric_adr, dtype=np.int, count=(self.nnumeric * 1)), (self.nnumeric, 1)) arr.setflags(write=False) return arr @numeric_adr.setter def numeric_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.numeric_adr, val_ptr, ((self.nnumeric * 1) * sizeof(c_int))) @property def numeric_size(self): arr = np.reshape(np.fromiter(self._wrapped.contents.numeric_size, dtype=np.int, count=(self.nnumeric * 1)), (self.nnumeric, 1)) arr.setflags(write=False) return arr @numeric_size.setter def numeric_size(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.numeric_size, val_ptr, ((self.nnumeric * 1) * sizeof(c_int))) @property def numeric_data(self): arr = np.reshape(np.fromiter(self._wrapped.contents.numeric_data, dtype=np.double, count=(self.nnumericdata * 1)), (self.nnumericdata, 1)) arr.setflags(write=False) return arr @numeric_data.setter def numeric_data(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.numeric_data, val_ptr, ((self.nnumericdata * 1) * sizeof(c_double))) @property def text_adr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.text_adr, dtype=np.int, count=(self.ntext * 1)), (self.ntext, 1)) arr.setflags(write=False) return arr @text_adr.setter def text_adr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.text_adr, val_ptr, ((self.ntext * 1) * sizeof(c_int))) @property def text_data(self): return self._wrapped.contents.text_data @property def key_time(self): arr = np.reshape(np.fromiter(self._wrapped.contents.key_time, dtype=np.double, count=(self.nkey * 1)), (self.nkey, 1)) arr.setflags(write=False) return arr @key_time.setter def key_time(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.key_time, val_ptr, ((self.nkey * 1) * sizeof(c_double))) @property def key_qpos(self): arr = np.reshape(np.fromiter(self._wrapped.contents.key_qpos, dtype=np.double, count=(self.nkey * self.nq)), (self.nkey, self.nq)) arr.setflags(write=False) return arr @key_qpos.setter def key_qpos(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.key_qpos, val_ptr, ((self.nkey * self.nq) * sizeof(c_double))) @property def key_qvel(self): arr = np.reshape(np.fromiter(self._wrapped.contents.key_qvel, dtype=np.double, count=(self.nkey * self.nv)), (self.nkey, self.nv)) arr.setflags(write=False) return arr @key_qvel.setter def key_qvel(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.key_qvel, val_ptr, ((self.nkey * self.nv) * sizeof(c_double))) @property def key_act(self): arr = np.reshape(np.fromiter(self._wrapped.contents.key_act, dtype=np.double, count=(self.nkey * self.na)), (self.nkey, self.na)) arr.setflags(write=False) return arr @key_act.setter def key_act(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_double)) memmove(self._wrapped.contents.key_act, val_ptr, ((self.nkey * self.na) * sizeof(c_double))) @property def name_bodyadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_bodyadr, dtype=np.int, count=(self.nbody * 1)), (self.nbody, 1)) arr.setflags(write=False) return arr @name_bodyadr.setter def name_bodyadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_bodyadr, val_ptr, ((self.nbody * 1) * sizeof(c_int))) @property def name_jntadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_jntadr, dtype=np.int, count=(self.njnt * 1)), (self.njnt, 1)) arr.setflags(write=False) return arr @name_jntadr.setter def name_jntadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_jntadr, val_ptr, ((self.njnt * 1) * sizeof(c_int))) @property def name_geomadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_geomadr, dtype=np.int, count=(self.ngeom * 1)), (self.ngeom, 1)) arr.setflags(write=False) return arr @name_geomadr.setter def name_geomadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_geomadr, val_ptr, ((self.ngeom * 1) * sizeof(c_int))) @property def name_siteadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_siteadr, dtype=np.int, count=(self.nsite * 1)), (self.nsite, 1)) arr.setflags(write=False) return arr @name_siteadr.setter def name_siteadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_siteadr, val_ptr, ((self.nsite * 1) * sizeof(c_int))) @property def name_camadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_camadr, dtype=np.int, count=(self.ncam * 1)), (self.ncam, 1)) arr.setflags(write=False) return arr @name_camadr.setter def name_camadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_camadr, val_ptr, ((self.ncam * 1) * sizeof(c_int))) @property def name_lightadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_lightadr, dtype=np.int, count=(self.nlight * 1)), (self.nlight, 1)) arr.setflags(write=False) return arr @name_lightadr.setter def name_lightadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_lightadr, val_ptr, ((self.nlight * 1) * sizeof(c_int))) @property def name_meshadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_meshadr, dtype=np.int, count=(self.nmesh * 1)), (self.nmesh, 1)) arr.setflags(write=False) return arr @name_meshadr.setter def name_meshadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_meshadr, val_ptr, ((self.nmesh * 1) * sizeof(c_int))) @property def name_hfieldadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_hfieldadr, dtype=np.int, count=(self.nhfield * 1)), (self.nhfield, 1)) arr.setflags(write=False) return arr @name_hfieldadr.setter def name_hfieldadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_hfieldadr, val_ptr, ((self.nhfield * 1) * sizeof(c_int))) @property def name_texadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_texadr, dtype=np.int, count=(self.ntex * 1)), (self.ntex, 1)) arr.setflags(write=False) return arr @name_texadr.setter def name_texadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_texadr, val_ptr, ((self.ntex * 1) * sizeof(c_int))) @property def name_matadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_matadr, dtype=np.int, count=(self.nmat * 1)), (self.nmat, 1)) arr.setflags(write=False) return arr @name_matadr.setter def name_matadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_matadr, val_ptr, ((self.nmat * 1) * sizeof(c_int))) @property def name_eqadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_eqadr, dtype=np.int, count=(self.neq * 1)), (self.neq, 1)) arr.setflags(write=False) return arr @name_eqadr.setter def name_eqadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_eqadr, val_ptr, ((self.neq * 1) * sizeof(c_int))) @property def name_tendonadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_tendonadr, dtype=np.int, count=(self.ntendon * 1)), (self.ntendon, 1)) arr.setflags(write=False) return arr @name_tendonadr.setter def name_tendonadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_tendonadr, val_ptr, ((self.ntendon * 1) * sizeof(c_int))) @property def name_actuatoradr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_actuatoradr, dtype=np.int, count=(self.nu * 1)), (self.nu, 1)) arr.setflags(write=False) return arr @name_actuatoradr.setter def name_actuatoradr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_actuatoradr, val_ptr, ((self.nu * 1) * sizeof(c_int))) @property def name_sensoradr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_sensoradr, dtype=np.int, count=(self.nsensor * 1)), (self.nsensor, 1)) arr.setflags(write=False) return arr @name_sensoradr.setter def name_sensoradr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_sensoradr, val_ptr, ((self.nsensor * 1) * sizeof(c_int))) @property def name_numericadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_numericadr, dtype=np.int, count=(self.nnumeric * 1)), (self.nnumeric, 1)) arr.setflags(write=False) return arr @name_numericadr.setter def name_numericadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_numericadr, val_ptr, ((self.nnumeric * 1) * sizeof(c_int))) @property def name_textadr(self): arr = np.reshape(np.fromiter(self._wrapped.contents.name_textadr, dtype=np.int, count=(self.ntext * 1)), (self.ntext, 1)) arr.setflags(write=False) return arr @name_textadr.setter def name_textadr(self, value): val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int)) memmove(self._wrapped.contents.name_textadr, val_ptr, ((self.ntext * 1) * sizeof(c_int))) @property def names(self): return self._wrapped.contents.names
def _glfw_error_callback(e, d): logger.error('GLFW error: %s, desc: %s', e, d)
class MjViewer(object): def __init__(self, visible=True, init_width=500, init_height=500, go_fast=False): '\n Set go_fast=True to run at full speed instead of waiting for the 60 Hz monitor refresh\n init_width and init_height set window size. On Mac Retina displays, they are in nominal\n pixels but .render returns an array of device pixels, so the array will be twice as big\n as you expect.\n ' self.visible = visible self.init_width = init_width self.init_height = init_height self.go_fast = ((not visible) or go_fast) self.last_render_time = 0 self.objects = mjcore.MJVOBJECTS() self.cam = mjcore.MJVCAMERA() self.vopt = mjcore.MJVOPTION() self.ropt = mjcore.MJROPTION() self.con = mjcore.MJRCONTEXT() self.running = False self.speedtype = 1 self.window = None self.model = None self.gui_lock = Lock() self._fbo = None self._rbo = None self._last_button = 0 self._last_click_time = 0 self._button_left_pressed = False self._button_middle_pressed = False self._button_right_pressed = False self._last_mouse_x = 0 self._last_mouse_y = 0 def set_model(self, model): self.model = model if model: self.data = model.data else: self.data = None if self.running: if model: mjlib.mjr_makeContext(model.ptr, byref(self.con), 150) else: mjlib.mjr_makeContext(None, byref(self.con), 150) self.render() if model: self.autoscale() def autoscale(self): self.cam.lookat[0] = self.model.stat.center[0] self.cam.lookat[1] = self.model.stat.center[1] self.cam.lookat[2] = self.model.stat.center[2] self.cam.distance = (0.5 * self.model.stat.extent) self.cam.camid = (- 1) self.cam.trackbodyid = 1 (width, height) = self.get_dimensions() mjlib.mjv_updateCameraPose(byref(self.cam), ((width * 1.0) / height)) def get_rect(self): rect = mjcore.MJRRECT(0, 0, 0, 0) (rect.width, rect.height) = self.get_dimensions() return rect def render(self): if (not self.data): return self.gui_lock.acquire() rect = self.get_rect() arr = (ctypes.c_double * 3)(0, 0, 0) mjlib.mjv_makeGeoms(self.model.ptr, self.data.ptr, byref(self.objects), byref(self.vopt), mjCAT_ALL, 0, None, None, ctypes.cast(arr, ctypes.POINTER(ctypes.c_double))) mjlib.mjv_makeLights(self.model.ptr, self.data.ptr, byref(self.objects)) mjlib.mjv_setCamera(self.model.ptr, self.data.ptr, byref(self.cam)) mjlib.mjv_updateCameraPose(byref(self.cam), ((rect.width * 1.0) / rect.height)) mjlib.mjr_render(0, rect, byref(self.objects), byref(self.ropt), byref(self.cam.pose), byref(self.con)) self.gui_lock.release() def get_dimensions(self): '\n returns a tuple (width, height)\n ' if self.window: return glfw.get_framebuffer_size(self.window) return (self.init_width, self.init_height) def get_image(self): '\n returns a tuple (data, width, height), where:\n - data is a string with raw bytes representing the pixels in 3-channel RGB\n (i.e. every three bytes = 1 pixel)\n - width is the width of the image\n - height is the height of the image\n ' (width, height) = self.get_dimensions() gl.glReadBuffer(gl.GL_BACK) data = gl.glReadPixels(0, 0, width, height, gl.GL_RGB, gl.GL_UNSIGNED_BYTE) return (data, width, height) def _init_framebuffer_object(self): '\n returns a Framebuffer Object to support offscreen rendering.\n http://learnopengl.com/#!Advanced-OpenGL/Framebuffers\n ' fbo = gl.glGenFramebuffers(1) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, fbo) rbo = gl.glGenRenderbuffers(1) gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, rbo) gl.glRenderbufferStorage(gl.GL_RENDERBUFFER, gl.GL_RGBA, self.init_width, self.init_height) gl.glFramebufferRenderbuffer(gl.GL_FRAMEBUFFER, gl.GL_COLOR_ATTACHMENT0, gl.GL_RENDERBUFFER, rbo) gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, 0) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0) fbo_status = gl.glCheckFramebufferStatus(gl.GL_FRAMEBUFFER) if (fbo_status != gl.GL_FRAMEBUFFER_COMPLETE): gl.glDeleteFramebuffers([fbo]) glfw.terminate() raise Exception(('Framebuffer failed status check: %s' % fbo_status)) self._fbo = fbo self._rbo = rbo def start(self): logger.info('initializing glfw@%s', glfw.get_version()) glfw.set_error_callback(_glfw_error_callback) if (not glfw.init()): raise Exception('glfw failed to initialize') window = None if self.visible: glfw.window_hint(glfw.SAMPLES, 4) else: glfw.window_hint(glfw.VISIBLE, 0) stereo_available = False (_, _, refresh_rate) = glfw.get_video_mode(glfw.get_primary_monitor()) if (refresh_rate >= 100): glfw.window_hint(glfw.STEREO, 1) window = glfw.create_window(self.init_width, self.init_height, 'Simulate', None, None) if window: stereo_available = True if (not window): glfw.window_hint(glfw.STEREO, 0) window = glfw.create_window(self.init_width, self.init_height, 'Simulate', None, None) if (not window): glfw.terminate() return self.running = True glfw.make_context_current(window) if self.go_fast: glfw.swap_interval(0) self._init_framebuffer_object() (width, height) = glfw.get_framebuffer_size(window) (width1, height) = glfw.get_window_size(window) self._scale = ((width * 1.0) / width1) self.window = window mjlib.mjv_makeObjects(byref(self.objects), 1000) mjlib.mjv_defaultCamera(byref(self.cam)) mjlib.mjv_defaultOption(byref(self.vopt)) mjlib.mjr_defaultOption(byref(self.ropt)) mjlib.mjr_defaultContext(byref(self.con)) if self.model: mjlib.mjr_makeContext(self.model.ptr, byref(self.con), 150) self.autoscale() else: mjlib.mjr_makeContext(None, byref(self.con), 150) glfw.set_cursor_pos_callback(window, self.handle_mouse_move) glfw.set_mouse_button_callback(window, self.handle_mouse_button) glfw.set_scroll_callback(window, self.handle_scroll) def handle_mouse_move(self, window, xpos, ypos): if ((not self._button_left_pressed) and (not self._button_middle_pressed) and (not self._button_right_pressed)): return dx = (int((self._scale * xpos)) - self._last_mouse_x) dy = (int((self._scale * ypos)) - self._last_mouse_y) self._last_mouse_x = int((self._scale * xpos)) self._last_mouse_y = int((self._scale * ypos)) if (not self.model): return (width, height) = glfw.get_framebuffer_size(self.window) mod_shift = ((glfw.get_key(window, glfw.KEY_LEFT_SHIFT) == glfw.PRESS) or (glfw.get_key(window, glfw.KEY_RIGHT_SHIFT) == glfw.PRESS)) action = None if self._button_right_pressed: action = (mjconstants.MOUSE_MOVE_H if mod_shift else mjconstants.MOUSE_MOVE_V) elif self._button_left_pressed: action = (mjconstants.MOUSE_ROTATE_H if mod_shift else mjconstants.MOUSE_ROTATE_V) else: action = mjconstants.MOUSE_ZOOM self.gui_lock.acquire() mjlib.mjv_moveCamera(action, dx, dy, byref(self.cam), width, height) self.gui_lock.release() def handle_mouse_button(self, window, button, act, mods): self._button_left_pressed = (glfw.get_mouse_button(window, glfw.MOUSE_BUTTON_LEFT) == glfw.PRESS) self._button_middle_pressed = (glfw.get_mouse_button(window, glfw.MOUSE_BUTTON_MIDDLE) == glfw.PRESS) self._button_right_pressed = (glfw.get_mouse_button(window, glfw.MOUSE_BUTTON_RIGHT) == glfw.PRESS) (x, y) = glfw.get_cursor_pos(window) self._last_mouse_x = int((self._scale * x)) self._last_mouse_y = int((self._scale * y)) if (not self.model): return self.gui_lock.acquire() if (act == glfw.PRESS): self._last_button = button self._last_click_time = glfw.get_time() self.gui_lock.release() def handle_scroll(self, window, x_offset, y_offset): if (not self.model): return (width, height) = glfw.get_framebuffer_size(window) self.gui_lock.acquire() mjlib.mjv_moveCamera(mjconstants.MOUSE_ZOOM, 0, ((- 20) * y_offset), byref(self.cam), width, height) self.gui_lock.release() def should_stop(self): return glfw.window_should_close(self.window) def loop_once(self): self.render() glfw.swap_buffers(self.window) glfw.poll_events() def finish(self): glfw.terminate() if gl.glIsFramebuffer(self._fbo): gl.glDeleteFramebuffers(int(self._fbo)) if gl.glIsRenderbuffer(self._rbo): gl.glDeleteRenderbuffers(1, int(self._rbo)) mjlib.mjr_freeContext(byref(self.con)) mjlib.mjv_freeObjects(byref(self.objects)) self.running = False
class UserString(): def __init__(self, seq): if isinstance(seq, basestring): self.data = seq elif isinstance(seq, UserString): self.data = seq.data[:] else: self.data = str(seq) def __str__(self): return str(self.data) def __repr__(self): return repr(self.data) def __int__(self): return int(self.data) def __long__(self): return long(self.data) def __float__(self): return float(self.data) def __complex__(self): return complex(self.data) def __hash__(self): return hash(self.data) def __cmp__(self, string): if isinstance(string, UserString): return cmp(self.data, string.data) else: return cmp(self.data, string) def __contains__(self, char): return (char in self.data) def __len__(self): return len(self.data) def __getitem__(self, index): return self.__class__(self.data[index]) def __getslice__(self, start, end): start = max(start, 0) end = max(end, 0) return self.__class__(self.data[start:end]) def __add__(self, other): if isinstance(other, UserString): return self.__class__((self.data + other.data)) elif isinstance(other, basestring): return self.__class__((self.data + other)) else: return self.__class__((self.data + str(other))) def __radd__(self, other): if isinstance(other, basestring): return self.__class__((other + self.data)) else: return self.__class__((str(other) + self.data)) def __mul__(self, n): return self.__class__((self.data * n)) __rmul__ = __mul__ def __mod__(self, args): return self.__class__((self.data % args)) def capitalize(self): return self.__class__(self.data.capitalize()) def center(self, width, *args): return self.__class__(self.data.center(width, *args)) def count(self, sub, start=0, end=MAXINT): return self.data.count(sub, start, end) def decode(self, encoding=None, errors=None): if encoding: if errors: return self.__class__(self.data.decode(encoding, errors)) else: return self.__class__(self.data.decode(encoding)) else: return self.__class__(self.data.decode()) def encode(self, encoding=None, errors=None): if encoding: if errors: return self.__class__(self.data.encode(encoding, errors)) else: return self.__class__(self.data.encode(encoding)) else: return self.__class__(self.data.encode()) def endswith(self, suffix, start=0, end=MAXINT): return self.data.endswith(suffix, start, end) def expandtabs(self, tabsize=8): return self.__class__(self.data.expandtabs(tabsize)) def find(self, sub, start=0, end=MAXINT): return self.data.find(sub, start, end) def index(self, sub, start=0, end=MAXINT): return self.data.index(sub, start, end) def isalpha(self): return self.data.isalpha() def isalnum(self): return self.data.isalnum() def isdecimal(self): return self.data.isdecimal() def isdigit(self): return self.data.isdigit() def islower(self): return self.data.islower() def isnumeric(self): return self.data.isnumeric() def isspace(self): return self.data.isspace() def istitle(self): return self.data.istitle() def isupper(self): return self.data.isupper() def join(self, seq): return self.data.join(seq) def ljust(self, width, *args): return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) def partition(self, sep): return self.data.partition(sep) def replace(self, old, new, maxsplit=(- 1)): return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=MAXINT): return self.data.rfind(sub, start, end) def rindex(self, sub, start=0, end=MAXINT): return self.data.rindex(sub, start, end) def rjust(self, width, *args): return self.__class__(self.data.rjust(width, *args)) def rpartition(self, sep): return self.data.rpartition(sep) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=(- 1)): return self.data.split(sep, maxsplit) def rsplit(self, sep=None, maxsplit=(- 1)): return self.data.rsplit(sep, maxsplit) def splitlines(self, keepends=0): return self.data.splitlines(keepends) def startswith(self, prefix, start=0, end=MAXINT): return self.data.startswith(prefix, start, end) def strip(self, chars=None): return self.__class__(self.data.strip(chars)) def swapcase(self): return self.__class__(self.data.swapcase()) def title(self): return self.__class__(self.data.title()) def translate(self, *args): return self.__class__(self.data.translate(*args)) def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width))
class MutableString(UserString): "mutable string objects\n\n Python strings are immutable objects. This has the advantage, that\n strings may be used as dictionary keys. If this property isn't needed\n and you insist on changing string values in place instead, you may cheat\n and use MutableString.\n\n But the purpose of this class is an educational one: to prevent\n people from inventing their own mutable string class derived\n from UserString and than forget thereby to remove (override) the\n __hash__ method inherited from UserString. This would lead to\n errors that would be very hard to track down.\n\n A faster and better solution is to rewrite your program using lists." def __init__(self, string=''): self.data = string def __hash__(self): raise TypeError('unhashable type (it is mutable)') def __setitem__(self, index, sub): if (index < 0): index += len(self.data) if ((index < 0) or (index >= len(self.data))): raise IndexError self.data = ((self.data[:index] + sub) + self.data[(index + 1):]) def __delitem__(self, index): if (index < 0): index += len(self.data) if ((index < 0) or (index >= len(self.data))): raise IndexError self.data = (self.data[:index] + self.data[(index + 1):]) def __setslice__(self, start, end, sub): start = max(start, 0) end = max(end, 0) if isinstance(sub, UserString): self.data = ((self.data[:start] + sub.data) + self.data[end:]) elif isinstance(sub, basestring): self.data = ((self.data[:start] + sub) + self.data[end:]) else: self.data = ((self.data[:start] + str(sub)) + self.data[end:]) def __delslice__(self, start, end): start = max(start, 0) end = max(end, 0) self.data = (self.data[:start] + self.data[end:]) def immutable(self): return UserString(self.data) def __iadd__(self, other): if isinstance(other, UserString): self.data += other.data elif isinstance(other, basestring): self.data += other else: self.data += str(other) return self def __imul__(self, n): self.data *= n return self
class String(MutableString, Union): _fields_ = [('raw', POINTER(c_char)), ('data', c_char_p)] def __init__(self, obj=''): if isinstance(obj, six.text_type): self.data = obj.encode('ascii') elif isinstance(obj, six.binary_type): self.data = obj elif isinstance(obj, UserString): self.data = six.b(obj) else: self.raw = obj def __len__(self): return ((self.data and len(self.data)) or 0) def from_param(cls, obj): if ((obj is None) or (obj == 0)): return cls(POINTER(c_char)()) elif isinstance(obj, String): return obj elif isinstance(obj, str): return cls(obj) elif isinstance(obj, c_char_p): return obj elif isinstance(obj, POINTER(c_char)): return obj elif isinstance(obj, int): return cls(cast(obj, POINTER(c_char))) else: return String.from_param(obj._as_parameter_) from_param = classmethod(from_param)
def ReturnString(obj, func=None, arguments=None): return String.from_param(obj)
class PerlmutterHvp(Serializable): def __init__(self, num_slices=1): Serializable.quick_init(self, locals()) self.target = None self.reg_coeff = None self.opt_fun = None self._num_slices = num_slices def update_opt(self, f, target, inputs, reg_coeff): self.target = target self.reg_coeff = reg_coeff params = target.get_params(trainable=True) constraint_grads = theano.grad(f, wrt=params, disconnected_inputs='warn') xs = tuple([ext.new_tensor_like(('%s x' % p.name), p) for p in params]) def Hx_plain(): Hx_plain_splits = TT.grad(TT.sum([TT.sum((g * x)) for (g, x) in zip(constraint_grads, xs)]), wrt=params, disconnected_inputs='warn') return TT.concatenate([TT.flatten(s) for s in Hx_plain_splits]) self.opt_fun = ext.lazydict(f_Hx_plain=(lambda : ext.compile_function(inputs=(inputs + xs), outputs=Hx_plain(), log_name='f_Hx_plain'))) def build_eval(self, inputs): def eval(x): xs = tuple(self.target.flat_to_params(x, trainable=True)) ret = (sliced_fun(self.opt_fun['f_Hx_plain'], self._num_slices)(inputs, xs) + (self.reg_coeff * x)) return ret return eval
class FiniteDifferenceHvp(Serializable): def __init__(self, base_eps=1e-08, symmetric=True, grad_clip=None, num_slices=1): Serializable.quick_init(self, locals()) self.base_eps = base_eps self.symmetric = symmetric self.grad_clip = grad_clip self._num_slices = num_slices def update_opt(self, f, target, inputs, reg_coeff): self.target = target self.reg_coeff = reg_coeff params = target.get_params(trainable=True) constraint_grads = theano.grad(f, wrt=params, disconnected_inputs='warn') flat_grad = ext.flatten_tensor_variables(constraint_grads) def f_Hx_plain(*args): inputs_ = args[:len(inputs)] xs = args[len(inputs):] flat_xs = np.concatenate([np.reshape(x, ((- 1),)) for x in xs]) param_val = self.target.get_param_values(trainable=True) eps = np.cast['float32']((self.base_eps / (np.linalg.norm(param_val) + 1e-08))) self.target.set_param_values((param_val + (eps * flat_xs)), trainable=True) flat_grad_dvplus = self.opt_fun['f_grad'](*inputs_) if self.symmetric: self.target.set_param_values((param_val - (eps * flat_xs)), trainable=True) flat_grad_dvminus = self.opt_fun['f_grad'](*inputs_) hx = ((flat_grad_dvplus - flat_grad_dvminus) / (2 * eps)) self.target.set_param_values(param_val, trainable=True) else: self.target.set_param_values(param_val, trainable=True) flat_grad = self.opt_fun['f_grad'](*inputs_) hx = ((flat_grad_dvplus - flat_grad) / eps) return hx self.opt_fun = ext.lazydict(f_grad=(lambda : ext.compile_function(inputs=inputs, outputs=flat_grad, log_name='f_grad')), f_Hx_plain=(lambda : f_Hx_plain)) def build_eval(self, inputs): def eval(x): xs = tuple(self.target.flat_to_params(x, trainable=True)) ret = (sliced_fun(self.opt_fun['f_Hx_plain'], self._num_slices)(inputs, xs) + (self.reg_coeff * x)) return ret return eval
class ConjugateGradientOptimizer(Serializable): '\n Performs constrained optimization via line search. The search direction is computed using a conjugate gradient\n algorithm, which gives x = A^{-1}g, where A is a second order approximation of the constraint and g is the gradient\n of the loss function.\n ' def __init__(self, cg_iters=10, reg_coeff=1e-05, subsample_factor=1.0, backtrack_ratio=0.8, max_backtracks=15, accept_violation=False, hvp_approach=None, num_slices=1): '\n\n :param cg_iters: The number of CG iterations used to calculate A^-1 g\n :param reg_coeff: A small value so that A -> A + reg*I\n :param subsample_factor: Subsampling factor to reduce samples when using "conjugate gradient. Since the\n computation time for the descent direction dominates, this can greatly reduce the overall computation time.\n :param accept_violation: whether to accept the descent step if it violates the line search condition after\n exhausting all backtracking budgets\n :return:\n ' Serializable.quick_init(self, locals()) self._cg_iters = cg_iters self._reg_coeff = reg_coeff self._subsample_factor = subsample_factor self._backtrack_ratio = backtrack_ratio self._max_backtracks = max_backtracks self._num_slices = num_slices self._opt_fun = None self._target = None self._max_constraint_val = None self._constraint_name = None self._accept_violation = accept_violation if (hvp_approach is None): hvp_approach = PerlmutterHvp(num_slices) self._hvp_approach = hvp_approach def update_opt(self, loss, target, leq_constraint, inputs, extra_inputs=None, constraint_name='constraint', *args, **kwargs): '\n :param loss: Symbolic expression for the loss function.\n :param target: A parameterized object to optimize over. It should implement methods of the\n :class:`rllab.core.paramerized.Parameterized` class.\n :param leq_constraint: A constraint provided as a tuple (f, epsilon), of the form f(*inputs) <= epsilon.\n :param inputs: A list of symbolic variables as inputs, which could be subsampled if needed. It is assumed\n that the first dimension of these inputs should correspond to the number of data points\n :param extra_inputs: A list of symbolic variables as extra inputs which should not be subsampled\n :return: No return value.\n ' inputs = tuple(inputs) if (extra_inputs is None): extra_inputs = tuple() else: extra_inputs = tuple(extra_inputs) (constraint_term, constraint_value) = leq_constraint params = target.get_params(trainable=True) grads = theano.grad(loss, wrt=params, disconnected_inputs='warn') flat_grad = ext.flatten_tensor_variables(grads) self._hvp_approach.update_opt(f=constraint_term, target=target, inputs=(inputs + extra_inputs), reg_coeff=self._reg_coeff) self._target = target self._max_constraint_val = constraint_value self._constraint_name = constraint_name self._opt_fun = ext.lazydict(f_loss=(lambda : ext.compile_function(inputs=(inputs + extra_inputs), outputs=loss, log_name='f_loss')), f_grad=(lambda : ext.compile_function(inputs=(inputs + extra_inputs), outputs=flat_grad, log_name='f_grad')), f_constraint=(lambda : ext.compile_function(inputs=(inputs + extra_inputs), outputs=constraint_term, log_name='constraint')), f_loss_constraint=(lambda : ext.compile_function(inputs=(inputs + extra_inputs), outputs=[loss, constraint_term], log_name='f_loss_constraint'))) def loss(self, inputs, extra_inputs=None): inputs = tuple(inputs) if (extra_inputs is None): extra_inputs = tuple() return sliced_fun(self._opt_fun['f_loss'], self._num_slices)(inputs, extra_inputs) def constraint_val(self, inputs, extra_inputs=None): inputs = tuple(inputs) if (extra_inputs is None): extra_inputs = tuple() return sliced_fun(self._opt_fun['f_constraint'], self._num_slices)(inputs, extra_inputs) def optimize(self, inputs, extra_inputs=None, subsample_grouped_inputs=None): inputs = tuple(inputs) if (extra_inputs is None): extra_inputs = tuple() if (self._subsample_factor < 1): if (subsample_grouped_inputs is None): subsample_grouped_inputs = [inputs] subsample_inputs = tuple() for inputs_grouped in subsample_grouped_inputs: n_samples = len(inputs_grouped[0]) inds = np.random.choice(n_samples, int((n_samples * self._subsample_factor)), replace=False) subsample_inputs += tuple([x[inds] for x in inputs_grouped]) else: subsample_inputs = inputs logger.log('computing loss before') loss_before = sliced_fun(self._opt_fun['f_loss'], self._num_slices)(inputs, extra_inputs) logger.log('performing update') logger.log('computing descent direction') flat_g = sliced_fun(self._opt_fun['f_grad'], self._num_slices)(inputs, extra_inputs) Hx = self._hvp_approach.build_eval((subsample_inputs + extra_inputs)) descent_direction = krylov.cg(Hx, flat_g, cg_iters=self._cg_iters) initial_step_size = np.sqrt(((2.0 * self._max_constraint_val) * (1.0 / (descent_direction.dot(Hx(descent_direction)) + 1e-08)))) if np.isnan(initial_step_size): initial_step_size = 1.0 flat_descent_step = (initial_step_size * descent_direction) logger.log('descent direction computed') prev_param = np.copy(self._target.get_param_values(trainable=True)) n_iter = 0 for (n_iter, ratio) in enumerate((self._backtrack_ratio ** np.arange(self._max_backtracks))): cur_step = (ratio * flat_descent_step) cur_param = (prev_param - cur_step) self._target.set_param_values(cur_param, trainable=True) (loss, constraint_val) = sliced_fun(self._opt_fun['f_loss_constraint'], self._num_slices)(inputs, extra_inputs) if ((loss < loss_before) and (constraint_val <= self._max_constraint_val)): break if ((np.isnan(loss) or np.isnan(constraint_val) or (loss >= loss_before) or (constraint_val >= self._max_constraint_val)) and (not self._accept_violation)): logger.log('Line search condition violated. Rejecting the step!') if np.isnan(loss): logger.log('Violated because loss is NaN') if np.isnan(constraint_val): logger.log(('Violated because constraint %s is NaN' % self._constraint_name)) if (loss >= loss_before): logger.log('Violated because loss not improving') if (constraint_val >= self._max_constraint_val): logger.log(('Violated because constraint %s is violated' % self._constraint_name)) self._target.set_param_values(prev_param, trainable=True) logger.log(('backtrack iters: %d' % n_iter)) logger.log('computing loss after') logger.log('optimization finished')
class FirstOrderOptimizer(Serializable): '\n Performs (stochastic) gradient descent, possibly using fancier methods like adam etc.\n ' def __init__(self, update_method=lasagne.updates.adam, learning_rate=0.001, max_epochs=1000, tolerance=1e-06, batch_size=32, callback=None, verbose=False, **kwargs): '\n\n :param max_epochs:\n :param tolerance:\n :param update_method:\n :param batch_size: None or an integer. If None the whole dataset will be used.\n :param callback:\n :param kwargs:\n :return:\n ' Serializable.quick_init(self, locals()) self._opt_fun = None self._target = None self._callback = callback update_method = partial(update_method, learning_rate=learning_rate) self._update_method = update_method self._max_epochs = max_epochs self._tolerance = tolerance self._batch_size = batch_size self._verbose = verbose def update_opt(self, loss, target, inputs, extra_inputs=None, gradients=None, **kwargs): '\n :param loss: Symbolic expression for the loss function.\n :param target: A parameterized object to optimize over. It should implement methods of the\n :class:`rllab.core.paramerized.Parameterized` class.\n :param leq_constraint: A constraint provided as a tuple (f, epsilon), of the form f(*inputs) <= epsilon.\n :param inputs: A list of symbolic variables as inputs\n :return: No return value.\n ' self._target = target if (gradients is None): gradients = theano.grad(loss, target.get_params(trainable=True), disconnected_inputs='ignore') updates = self._update_method(gradients, target.get_params(trainable=True)) updates = OrderedDict([(k, v.astype(k.dtype)) for (k, v) in updates.items()]) if (extra_inputs is None): extra_inputs = list() self._opt_fun = ext.lazydict(f_loss=(lambda : ext.compile_function((inputs + extra_inputs), loss)), f_opt=(lambda : ext.compile_function(inputs=(inputs + extra_inputs), outputs=loss, updates=updates))) def loss(self, inputs, extra_inputs=None): if (extra_inputs is None): extra_inputs = tuple() return self._opt_fun['f_loss'](*(tuple(inputs) + extra_inputs)) def optimize_gen(self, inputs, extra_inputs=None, callback=None, yield_itr=None): if (len(inputs) == 0): raise NotImplementedError f_opt = self._opt_fun['f_opt'] f_loss = self._opt_fun['f_loss'] if (extra_inputs is None): extra_inputs = tuple() last_loss = f_loss(*(tuple(inputs) + extra_inputs)) start_time = time.time() dataset = BatchDataset(inputs, self._batch_size, extra_inputs=extra_inputs) itr = 0 for epoch in pyprind.prog_bar(list(range(self._max_epochs))): for batch in dataset.iterate(update=True): f_opt(*batch) if ((yield_itr is not None) and ((itr % (yield_itr + 1)) == 0)): (yield) itr += 1 new_loss = f_loss(*(tuple(inputs) + extra_inputs)) if self._verbose: logger.log(('Epoch %d, loss %s' % (epoch, new_loss))) if (self._callback or callback): elapsed = (time.time() - start_time) callback_args = dict(loss=new_loss, params=(self._target.get_param_values(trainable=True) if self._target else None), itr=epoch, elapsed=elapsed) if self._callback: self._callback(callback_args) if callback: callback(**callback_args) if (abs((last_loss - new_loss)) < self._tolerance): break last_loss = new_loss def optimize(self, inputs, **kwargs): for _ in self.optimize_gen(inputs, **kwargs): pass
class HessianFreeOptimizer(Serializable): '\n Performs unconstrained optimization via Hessian-Free Optimization\n ' def __init__(self, max_opt_itr=20, batch_size=32, cg_batch_size=100, callback=None): Serializable.quick_init(self, locals()) self._max_opt_itr = max_opt_itr self._opt_fun = None self._target = None self._batch_size = batch_size self._cg_batch_size = cg_batch_size self._hf_optimizer = None self._callback = callback def update_opt(self, loss, target, inputs, network_outputs, extra_inputs=None): '\n :param loss: Symbolic expression for the loss function.\n :param target: A parameterized object to optimize over. It should implement methods of the\n :class:`rllab.core.paramerized.Parameterized` class.\n :param inputs: A list of symbolic variables as inputs\n :return: No return value.\n ' self._target = target if (extra_inputs is None): extra_inputs = list() self._hf_optimizer = hf_optimizer(_p=target.get_params(trainable=True), inputs=(inputs + extra_inputs), s=network_outputs, costs=[loss]) self._opt_fun = lazydict(f_loss=(lambda : compile_function((inputs + extra_inputs), loss))) def loss(self, inputs, extra_inputs=None): if (extra_inputs is None): extra_inputs = list() return self._opt_fun['f_loss'](*(inputs + extra_inputs)) def optimize(self, inputs, extra_inputs=None): if (extra_inputs is None): extra_inputs = list() dataset = BatchDataset(inputs=inputs, batch_size=self._batch_size, extra_inputs=extra_inputs) cg_dataset = BatchDataset(inputs=inputs, batch_size=self._cg_batch_size, extra_inputs=extra_inputs) itr = [0] start_time = time.time() if self._callback: def opt_callback(): loss = self._opt_fun['f_loss'](*(inputs + extra_inputs)) elapsed = (time.time() - start_time) self._callback(dict(loss=loss, params=self._target.get_param_values(trainable=True), itr=itr[0], elapsed=elapsed)) itr[0] += 1 else: opt_callback = None self._hf_optimizer.train(gradient_dataset=dataset, cg_dataset=cg_dataset, itr_callback=opt_callback, num_updates=self._max_opt_itr, preconditioner=True, verbose=True)
def gauss_newton_product(cost, p, v, s): if (not isinstance(s, (list, tuple))): s = [s] sum_Gv = None for si in s: Jv = T.Rop(si, p, v) HJv = T.grad(T.sum((T.grad(cost, si, disconnected_inputs='ignore') * Jv)), si, consider_constant=[Jv], disconnected_inputs='ignore') Gv = T.grad(T.sum((HJv * si)), p, consider_constant=[HJv, Jv], disconnected_inputs='ignore') Gv = list(map(T.as_tensor_variable, Gv)) if (sum_Gv is None): sum_Gv = Gv else: sum_Gv = [(a + b) for (a, b) in zip(Gv, sum_Gv)] return sum_Gv
class hf_optimizer(): 'Black-box Theano-based Hessian-free optimizer.\n See (Martens, ICML 2010) and (Martens & Sutskever, ICML 2011) for details.\n\n Useful functions:\n __init__ :\n Compiles necessary Theano functions from symbolic expressions.\n train :\n Performs HF optimization following the above references.' def __init__(self, _p, inputs, s, costs, h=None, ha=None): "Constructs and compiles the necessary Theano functions.\n\n p : list of Theano shared variables\n Parameters of the model to be optimized.\n inputs : list of Theano variables\n Symbolic variables that are inputs to your graph (they should also\n include your model 'output'). Your training examples must fit these.\n s : Theano variable\n Symbolic variable with respect to which the Hessian of the objective is\n positive-definite, implicitly defining the Gauss-Newton matrix. Typically,\n it is the activation of the output layer.\n costs : list of Theano variables\n Monitoring costs, the first of which will be the optimized objective.\n h: Theano variable or None\n Structural damping is applied to this variable (typically the hidden units\n of an RNN).\n ha: Theano variable or None\n Symbolic variable that implicitly defines the Gauss-Newton matrix for the\n structural damping term (typically the activation of the hidden layer). If\n None, it will be set to `h`." self.p = _p self.shapes = [i.get_value().shape for i in _p] self.sizes = list(map(numpy.prod, self.shapes)) self.positions = numpy.cumsum(([0] + self.sizes))[:(- 1)] g = T.grad(costs[0], _p) g = list(map(T.as_tensor_variable, g)) self.f_gc = compile_function(inputs, (g + costs)) self.f_cost = compile_function(inputs, costs) symbolic_types = (T.scalar, T.vector, T.matrix, T.tensor3, T.tensor4) v = [symbolic_types[len(i)]() for i in self.shapes] Gv = gauss_newton_product(costs[0], _p, v, s) coefficient = T.scalar() if (h is not None): h_constant = symbolic_types[h.ndim]() structural_damping = ((coefficient * (((- h_constant) * T.log((h + 1e-10))) - ((1 - h_constant) * T.log(((1 - h) + 1e-10)))).sum()) / h.shape[0]) if (ha is None): ha = h Gv_damping = gauss_newton_product(structural_damping, _p, v, ha) Gv = [(a + b) for (a, b) in zip(Gv, Gv_damping)] givens = {h_constant: h} else: givens = {} self.function_Gv = compile_function(((inputs + v) + [coefficient]), Gv, givens=givens) def quick_cost(self, delta=0): if isinstance(delta, numpy.ndarray): delta = self.flat_to_list(delta) if (type(delta) in (list, tuple)): for (i, d) in zip(self.p, delta): i.set_value((i.get_value() + d)) cost = numpy.mean([self.f_cost(*i)[0] for i in self.cg_dataset.iterate(update=False)]) if (type(delta) in (list, tuple)): for (i, d) in zip(self.p, delta): i.set_value((i.get_value() - d)) return cost def cg(self, b, verbose=False): if self.preconditioner: M = (self.lambda_ * numpy.ones_like(b)) for inputs in self.cg_dataset.iterate(update=False): M += (self.list_to_flat(self.f_gc(*inputs)[:len(self.p)]) ** 2) M **= (- 0.75) sys.stdout.flush() else: M = 1.0 x = (self.cg_last_x if hasattr(self, 'cg_last_x') else numpy.zeros_like(b)) r = (b - self.batch_Gv(x)) d = (M * r) delta_new = numpy.dot(r, d) phi = [] backtracking = [] backspaces = 0 for i in range(1, (1 + self.max_cg_iterations)): q = self.batch_Gv(d) dq = numpy.dot(d, q) alpha = (delta_new / dq) x = (x + (alpha * d)) r = (r - (alpha * q)) s = (M * r) delta_old = delta_new delta_new = numpy.dot(r, s) d = (s + ((delta_new / delta_old) * d)) if (i >= int(numpy.ceil((1.3 ** len(backtracking))))): backtracking.append((self.quick_cost(x), x.copy(), i)) phi_i = ((- 0.5) * numpy.dot(x, (r + b))) phi.append(phi_i) if verbose: progress = (' [CG iter %i, phi=%+.5f, cost=%.5f]' % (i, phi_i, backtracking[(- 1)][0])) sys.stdout.write((('\x08' * backspaces) + progress)) sys.stdout.flush() backspaces = len(progress) k = max(10, (i / 10)) if ((i > k) and (phi_i < 0) and (((phi_i - phi[((- k) - 1)]) / phi_i) < (k * 0.0005))): break self.cg_last_x = x.copy() if self.global_backtracking: j = numpy.argmin([b[0] for b in backtracking]) else: j = (len(backtracking) - 1) while ((j > 0) and (backtracking[(j - 1)][0] < backtracking[j][0])): j -= 1 if verbose: print((' backtracked %i/%i' % (backtracking[j][2], i)), end=' ') sys.stdout.flush() return (backtracking[j] + (i,)) def flat_to_list(self, vector): return [vector[position:(position + size)].reshape(shape) for (shape, size, position) in zip(self.shapes, self.sizes, self.positions)] def list_to_flat(self, l): return numpy.concatenate([i.flatten() for i in l]) def batch_Gv(self, vector, lambda_=None): v = self.flat_to_list(vector) if (lambda_ is None): lambda_ = self.lambda_ result = (lambda_ * vector) for inputs in self.cg_dataset.iterate(False): result += (self.list_to_flat(self.function_Gv(*((inputs + v) + [(lambda_ * self.mu)]))) / self.cg_dataset.number_batches) return result def train(self, gradient_dataset, cg_dataset, initial_lambda=0.1, mu=0.03, global_backtracking=False, preconditioner=False, max_cg_iterations=250, num_updates=100, validation=None, validation_frequency=1, patience=numpy.inf, save_progress=None, itr_callback=None, verbose=False): "Performs HF training.\n\n gradient_dataset : SequenceDataset-like object\n Defines batches used to compute the gradient.\n The `iterate(update=True)` method should yield shuffled training examples\n (tuples of variables matching your graph inputs).\n The same examples MUST be returned between multiple calls to iterator(),\n unless update is True, in which case the next batch should be different.\n cg_dataset : SequenceDataset-like object\n Defines batches used to compute CG iterations.\n initial_lambda : float\n Initial value of the Tikhonov damping coefficient.\n mu : float\n Coefficient for structural damping.\n global_backtracking : Boolean\n If True, backtracks as much as necessary to find the global minimum among\n all CG iterates. Else, Martens' heuristic is used.\n preconditioner : Boolean\n Whether to use Martens' preconditioner.\n max_cg_iterations : int\n CG stops after this many iterations regardless of the stopping criterion.\n num_updates : int\n Training stops after this many parameter updates regardless of `patience`.\n validation: SequenceDataset object, (lambda : tuple) callback, or None\n If a SequenceDataset object is provided, the training monitoring costs\n will be evaluated on that validation dataset.\n If a callback is provided, it should return a list of validation costs\n for monitoring, the first of which is also used for early stopping.\n If None, no early stopping nor validation monitoring is performed.\n validation_frequency: int\n Validation is performed every `validation_frequency` updates.\n patience: int\n Training stops after `patience` updates without improvement in validation\n cost.\n save_progress: string or None\n A checkpoint is automatically saved at this location after each update.\n Call the `train` function again with the same parameters to resume\n training." self.lambda_ = initial_lambda self.mu = mu self.global_backtracking = global_backtracking self.cg_dataset = cg_dataset self.preconditioner = preconditioner self.max_cg_iterations = max_cg_iterations best = [0, numpy.inf, None] first_iteration = 1 if (isinstance(save_progress, str) and os.path.isfile(save_progress)): save = pickle.load(file(save_progress)) (self.cg_last_x, best, self.lambda_, first_iteration, init_p) = save first_iteration += 1 if verbose: print('* recovered saved model') try: for u in range(first_iteration, (1 + num_updates)): if verbose: print(('update %i/%i,' % (u, num_updates)), end=' ') sys.stdout.flush() gradient = numpy.zeros(sum(self.sizes), dtype=theano.config.floatX) costs = [] for inputs in gradient_dataset.iterate(update=True): result = self.f_gc(*inputs) gradient += (self.list_to_flat(result[:len(self.p)]) / gradient_dataset.number_batches) costs.append(result[len(self.p):]) if verbose: print('cost=', numpy.mean(costs, axis=0), end=' ') if verbose: print(('lambda=%.5f,' % self.lambda_), end=' ') sys.stdout.flush() (after_cost, flat_delta, backtracking, num_cg_iterations) = self.cg((- gradient)) delta_cost = numpy.dot(flat_delta, (gradient + (0.5 * self.batch_Gv(flat_delta, lambda_=0)))) before_cost = self.quick_cost() for (i, delta) in zip(self.p, self.flat_to_list(flat_delta)): i.set_value((i.get_value() + delta)) cg_dataset.update() if (itr_callback is not None): itr_callback() rho = ((after_cost - before_cost) / delta_cost) if (rho < 0.25): self.lambda_ *= 1.5 elif (rho > 0.75): self.lambda_ /= 1.5 if ((validation is not None) and ((u % validation_frequency) == 0)): if hasattr(validation, 'iterate'): costs = numpy.mean([self.f_cost(*i) for i in validation.iterate()], axis=0) elif isinstance(validation, collections.Callable): costs = validation() if verbose: print('validation=', costs, end=' ') if (costs[0] < best[1]): best = (u, costs[0], [i.get_value().copy() for i in self.p]) if verbose: print('*NEW BEST', end=' ') if isinstance(save_progress, str): save = (self.cg_last_x, best, self.lambda_, u, [i.get_value().copy() for i in self.p]) pickle.dump(save, file(save_progress, 'wb'), pickle.HIGHEST_PROTOCOL) if ((u - best[0]) > patience): if verbose: print('PATIENCE ELAPSED, BAILING OUT') break if verbose: print() sys.stdout.flush() except KeyboardInterrupt: if verbose: print('Interrupted by user.') if (best[2] is None): best[2] = [i.get_value().copy() for i in self.p] return best[2]
class SequenceDataset(): 'Slices, shuffles and manages a small dataset for the HF optimizer.' def __init__(self, data, batch_size, number_batches, minimum_size=10): 'SequenceDataset __init__\n\n data : list of lists of numpy arrays\n Your dataset will be provided as a list (one list for each graph input) of\n variable-length tensors that will be used as mini-batches. Typically, each\n tensor is a sequence or a set of examples.\n batch_size : int or None\n If an int, the mini-batches will be further split in chunks of length\n `batch_size`. This is useful for slicing subsequences or provide the full\n dataset in a single tensor to be split here. All tensors in `data` must\n then have the same leading dimension.\n number_batches : int\n Number of mini-batches over which you iterate to compute a gradient or\n Gauss-Newton matrix product.\n minimum_size : int\n Reject all mini-batches that end up smaller than this length.' self.current_batch = 0 self.number_batches = number_batches self.items = [] for i_sequence in range(len(data[0])): if (batch_size is None): self.items.append([data[i][i_sequence] for i in range(len(data))]) else: for i_step in range(0, ((len(data[0][i_sequence]) - minimum_size) + 1), batch_size): self.items.append([data[i][i_sequence][i_step:(i_step + batch_size)] for i in range(len(data))]) self.shuffle() def shuffle(self): numpy.random.shuffle(self.items) def iterate(self, update=True): for b in range(self.number_batches): (yield self.items[((self.current_batch + b) % len(self.items))]) if update: self.update() def update(self): if ((self.current_batch + self.number_batches) >= len(self.items)): self.shuffle() self.current_batch = 0 else: self.current_batch += self.number_batches
class LbfgsOptimizer(Serializable): '\n Performs unconstrained optimization via L-BFGS.\n ' def __init__(self, max_opt_itr=20, callback=None): Serializable.quick_init(self, locals()) self._max_opt_itr = max_opt_itr self._opt_fun = None self._target = None self._callback = callback def update_opt(self, loss, target, inputs, extra_inputs=None, gradients=None, *args, **kwargs): '\n :param loss: Symbolic expression for the loss function.\n :param target: A parameterized object to optimize over. It should implement methods of the\n :class:`rllab.core.paramerized.Parameterized` class.\n :param leq_constraint: A constraint provided as a tuple (f, epsilon), of the form f(*inputs) <= epsilon.\n :param inputs: A list of symbolic variables as inputs\n :param gradients: symbolic expressions for the gradients of trainable parameters of the target. By default\n this will be computed by calling theano.grad\n :return: No return value.\n ' self._target = target def get_opt_output(gradients): if (gradients is None): gradients = theano.grad(loss, target.get_params(trainable=True)) flat_grad = flatten_tensor_variables(gradients) return [loss.astype('float64'), flat_grad.astype('float64')] if (extra_inputs is None): extra_inputs = list() self._opt_fun = lazydict(f_loss=(lambda : compile_function((inputs + extra_inputs), loss)), f_opt=(lambda : compile_function(inputs=(inputs + extra_inputs), outputs=get_opt_output(gradients)))) def loss(self, inputs, extra_inputs=None): if (extra_inputs is None): extra_inputs = list() return self._opt_fun['f_loss'](*(list(inputs) + list(extra_inputs))) def optimize(self, inputs, extra_inputs=None): f_opt = self._opt_fun['f_opt'] if (extra_inputs is None): extra_inputs = list() def f_opt_wrapper(flat_params): self._target.set_param_values(flat_params, trainable=True) return f_opt(*inputs) itr = [0] start_time = time.time() if self._callback: def opt_callback(params): loss = self._opt_fun['f_loss'](*(inputs + extra_inputs)) elapsed = (time.time() - start_time) self._callback(dict(loss=loss, params=params, itr=itr[0], elapsed=elapsed)) itr[0] += 1 else: opt_callback = None scipy.optimize.fmin_l_bfgs_b(func=f_opt_wrapper, x0=self._target.get_param_values(trainable=True), maxiter=self._max_opt_itr, callback=opt_callback)
class BatchDataset(object): def __init__(self, inputs, batch_size, extra_inputs=None): self._inputs = [i for i in inputs] if (extra_inputs is None): extra_inputs = [] self._extra_inputs = extra_inputs self._batch_size = batch_size if (batch_size is not None): self._ids = np.arange(self._inputs[0].shape[0]) self.update() @property def number_batches(self): if (self._batch_size is None): return 1 return int(np.ceil(((self._inputs[0].shape[0] * 1.0) / self._batch_size))) def iterate(self, update=True): if (self._batch_size is None): (yield (list(self._inputs) + list(self._extra_inputs))) else: for itr in range(self.number_batches): batch_start = (itr * self._batch_size) batch_end = ((itr + 1) * self._batch_size) batch_ids = self._ids[batch_start:batch_end] batch = [d[batch_ids] for d in self._inputs] (yield (list(batch) + list(self._extra_inputs))) if update: self.update() def update(self): np.random.shuffle(self._ids)
class PenaltyLbfgsOptimizer(Serializable): '\n Performs constrained optimization via penalized L-BFGS. The penalty term is adaptively adjusted to make sure that\n the constraint is satisfied.\n ' def __init__(self, max_opt_itr=20, initial_penalty=1.0, min_penalty=0.01, max_penalty=1000000.0, increase_penalty_factor=2, decrease_penalty_factor=0.5, max_penalty_itr=10, adapt_penalty=True): Serializable.quick_init(self, locals()) self._max_opt_itr = max_opt_itr self._penalty = initial_penalty self._initial_penalty = initial_penalty self._min_penalty = min_penalty self._max_penalty = max_penalty self._increase_penalty_factor = increase_penalty_factor self._decrease_penalty_factor = decrease_penalty_factor self._max_penalty_itr = max_penalty_itr self._adapt_penalty = adapt_penalty self._opt_fun = None self._target = None self._max_constraint_val = None self._constraint_name = None def update_opt(self, loss, target, leq_constraint, inputs, constraint_name='constraint', *args, **kwargs): '\n :param loss: Symbolic expression for the loss function.\n :param target: A parameterized object to optimize over. It should implement methods of the\n :class:`rllab.core.paramerized.Parameterized` class.\n :param leq_constraint: A constraint provided as a tuple (f, epsilon), of the form f(*inputs) <= epsilon.\n :param inputs: A list of symbolic variables as inputs\n :return: No return value.\n ' (constraint_term, constraint_value) = leq_constraint penalty_var = TT.scalar('penalty') penalized_loss = (loss + (penalty_var * constraint_term)) self._target = target self._max_constraint_val = constraint_value self._constraint_name = constraint_name def get_opt_output(): flat_grad = flatten_tensor_variables(theano.grad(penalized_loss, target.get_params(trainable=True), disconnected_inputs='ignore')) return [penalized_loss.astype('float64'), flat_grad.astype('float64')] self._opt_fun = lazydict(f_loss=(lambda : compile_function(inputs, loss, log_name='f_loss')), f_constraint=(lambda : compile_function(inputs, constraint_term, log_name='f_constraint')), f_penalized_loss=(lambda : compile_function(inputs=(inputs + [penalty_var]), outputs=[penalized_loss, loss, constraint_term], log_name='f_penalized_loss')), f_opt=(lambda : compile_function(inputs=(inputs + [penalty_var]), outputs=get_opt_output(), log_name='f_opt'))) def loss(self, inputs): return self._opt_fun['f_loss'](*inputs) def constraint_val(self, inputs): return self._opt_fun['f_constraint'](*inputs) def optimize(self, inputs): inputs = tuple(inputs) try_penalty = np.clip(self._penalty, self._min_penalty, self._max_penalty) penalty_scale_factor = None f_opt = self._opt_fun['f_opt'] f_penalized_loss = self._opt_fun['f_penalized_loss'] def gen_f_opt(penalty): def f(flat_params): self._target.set_param_values(flat_params, trainable=True) return f_opt(*(inputs + (penalty,))) return f cur_params = self._target.get_param_values(trainable=True).astype('float64') opt_params = cur_params for penalty_itr in range(self._max_penalty_itr): logger.log(('trying penalty=%.3f...' % try_penalty)) (itr_opt_params, _, _) = scipy.optimize.fmin_l_bfgs_b(func=gen_f_opt(try_penalty), x0=cur_params, maxiter=self._max_opt_itr) (_, try_loss, try_constraint_val) = f_penalized_loss(*(inputs + (try_penalty,))) logger.log(('penalty %f => loss %f, %s %f' % (try_penalty, try_loss, self._constraint_name, try_constraint_val))) if ((try_constraint_val < self._max_constraint_val) or ((penalty_itr == (self._max_penalty_itr - 1)) and (opt_params is None))): opt_params = itr_opt_params if (not self._adapt_penalty): break if ((penalty_scale_factor is None) or np.isnan(try_constraint_val)): if ((try_constraint_val > self._max_constraint_val) or np.isnan(try_constraint_val)): penalty_scale_factor = self._increase_penalty_factor else: penalty_scale_factor = self._decrease_penalty_factor opt_params = itr_opt_params elif ((penalty_scale_factor > 1) and (try_constraint_val <= self._max_constraint_val)): break elif ((penalty_scale_factor < 1) and (try_constraint_val >= self._max_constraint_val)): break if ((try_penalty >= self._max_penalty) and (penalty_scale_factor > 1)): logger.log('_max_penalty has already been tried!') self._penalty = try_penalty break elif ((try_penalty <= self._min_penalty) and (penalty_scale_factor < 1)): logger.log('_min_penalty has already been tried!') self._penalty = try_penalty break else: try_penalty *= penalty_scale_factor try_penalty = np.clip(try_penalty, self._min_penalty, self._max_penalty) self._penalty = try_penalty self._target.set_param_values(opt_params, trainable=True)
def _worker_start(): env = None policy = None max_length = None try: while True: msgs = {} while True: try: msg = queue.get_nowait() msgs[msg[0]] = msg[1:] except Empty: break if ('stop' in msgs): break elif ('update' in msgs): (env, policy) = msgs['update'] elif ('demo' in msgs): (param_values, max_length) = msgs['demo'] policy.set_param_values(param_values) rollout(env, policy, max_path_length=max_length, animated=True, speedup=5) elif max_length: rollout(env, policy, max_path_length=max_length, animated=True, speedup=5) except KeyboardInterrupt: pass
def _shutdown_worker(): if process: queue.put(['stop']) queue.close() process.join()
def init_worker(): global process, queue queue = Queue() process = Process(target=_worker_start) process.start() atexit.register(_shutdown_worker)
def init_plot(env, policy): queue.put(['update', env, policy])
def update_plot(policy, max_length=np.inf): queue.put(['demo', policy.get_param_values(), max_length])
class Policy(Parameterized): def __init__(self, env_spec): Parameterized.__init__(self) self._env_spec = env_spec def get_action(self, observation): raise NotImplementedError def reset(self): pass @property def observation_space(self): return self._env_spec.observation_space @property def action_space(self): return self._env_spec.action_space @property def recurrent(self): '\n Indicates whether the policy is recurrent.\n :return:\n ' return False def log_diagnostics(self, paths): '\n Log extra information per iteration based on the collected paths\n ' pass @property def state_info_keys(self): "\n Return keys for the information related to the policy's state when taking an action.\n :return:\n " return list() def terminate(self): '\n Clean up operation\n ' pass
class StochasticPolicy(Policy): @property def distribution(self): '\n :rtype Distribution\n ' raise NotImplementedError def dist_info_sym(self, obs_var, state_info_vars): '\n Return the symbolic distribution information about the actions.\n :param obs_var: symbolic variable for observations\n :param state_info_vars: a dictionary whose values should contain information about the state of the policy at\n the time it received the observation\n :return:\n ' raise NotImplementedError def dist_info(self, obs, state_infos): '\n Return the distribution information about the actions.\n :param obs_var: observation values\n :param state_info_vars: a dictionary whose values should contain information about the state of the policy at\n the time it received the observation\n :return:\n ' raise NotImplementedError
class CategoricalConvPolicy(StochasticPolicy, LasagnePowered, Serializable): def __init__(self, name, env_spec, conv_filters, conv_filter_sizes, conv_strides, conv_pads, hidden_sizes=[], hidden_nonlinearity=NL.rectify, output_nonlinearity=NL.softmax, prob_network=None): '\n :param env_spec: A spec for the mdp.\n :param hidden_sizes: list of sizes for the fully connected hidden layers\n :param hidden_nonlinearity: nonlinearity used for each hidden layer\n :param prob_network: manually specified network for this policy, other network params\n are ignored\n :return:\n ' Serializable.quick_init(self, locals()) assert isinstance(env_spec.action_space, Discrete) self._env_spec = env_spec if (prob_network is None): prob_network = ConvNetwork(input_shape=env_spec.observation_space.shape, output_dim=env_spec.action_space.n, conv_filters=conv_filters, conv_filter_sizes=conv_filter_sizes, conv_strides=conv_strides, conv_pads=conv_pads, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=NL.softmax, name='prob_network') self._l_prob = prob_network.output_layer self._l_obs = prob_network.input_layer self._f_prob = ext.compile_function([prob_network.input_layer.input_var], L.get_output(prob_network.output_layer)) self._dist = Categorical(env_spec.action_space.n) super(CategoricalConvPolicy, self).__init__(env_spec) LasagnePowered.__init__(self, [prob_network.output_layer]) @property def vectorized(self): return True @overrides def dist_info_sym(self, obs_var, state_info_vars=None): return dict(prob=L.get_output(self._l_prob, {self._l_obs: obs_var})) @overrides def dist_info(self, obs, state_infos=None): return dict(prob=self._f_prob(obs)) @overrides def get_action(self, observation): flat_obs = self.observation_space.flatten(observation) prob = self._f_prob([flat_obs])[0] action = self.action_space.weighted_sample(prob) return (action, dict(prob=prob)) def get_actions(self, observations): flat_obs = self.observation_space.flatten_n(observations) probs = self._f_prob(flat_obs) actions = list(map(self.action_space.weighted_sample, probs)) return (actions, dict(prob=probs)) @property def distribution(self): return self._dist
class CategoricalGRUPolicy(StochasticPolicy, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_dim=32, feature_network=None, state_include_action=True, hidden_nonlinearity=NL.tanh): '\n :param env_spec: A spec for the env.\n :param hidden_dim: dimension of hidden layer\n :param hidden_nonlinearity: nonlinearity used for each hidden layer\n :return:\n ' assert isinstance(env_spec.action_space, Discrete) Serializable.quick_init(self, locals()) super(CategoricalGRUPolicy, self).__init__(env_spec) obs_dim = env_spec.observation_space.flat_dim action_dim = env_spec.action_space.flat_dim if state_include_action: input_dim = (obs_dim + action_dim) else: input_dim = obs_dim l_input = L.InputLayer(shape=(None, None, input_dim), name='input') if (feature_network is None): feature_dim = input_dim l_flat_feature = None l_feature = l_input else: feature_dim = feature_network.output_layer.output_shape[(- 1)] l_flat_feature = feature_network.output_layer l_feature = OpLayer(l_flat_feature, extras=[l_input], name='reshape_feature', op=(lambda flat_feature, input: TT.reshape(flat_feature, [input.shape[0], input.shape[1], feature_dim])), shape_op=(lambda _, input_shape: (input_shape[0], input_shape[1], feature_dim))) prob_network = GRUNetwork(input_shape=(feature_dim,), input_layer=l_feature, output_dim=env_spec.action_space.n, hidden_dim=hidden_dim, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=TT.nnet.softmax, name='prob_network') self.prob_network = prob_network self.feature_network = feature_network self.l_input = l_input self.state_include_action = state_include_action flat_input_var = TT.matrix('flat_input') if (feature_network is None): feature_var = flat_input_var else: feature_var = L.get_output(l_flat_feature, {feature_network.input_layer: flat_input_var}) self.f_step_prob = ext.compile_function([flat_input_var, prob_network.step_prev_hidden_layer.input_var], L.get_output([prob_network.step_output_layer, prob_network.step_hidden_layer], {prob_network.step_input_layer: feature_var})) self.input_dim = input_dim self.action_dim = action_dim self.hidden_dim = hidden_dim self.prev_action = None self.prev_hidden = None self.dist = RecurrentCategorical(env_spec.action_space.n) out_layers = [prob_network.output_layer] if (feature_network is not None): out_layers.append(feature_network.output_layer) LasagnePowered.__init__(self, out_layers) @overrides def dist_info_sym(self, obs_var, state_info_vars): (n_batches, n_steps) = obs_var.shape[:2] obs_var = obs_var.reshape((n_batches, n_steps, (- 1))) if self.state_include_action: prev_action_var = state_info_vars['prev_action'] all_input_var = TT.concatenate([obs_var, prev_action_var], axis=2) else: all_input_var = obs_var if (self.feature_network is None): return dict(prob=L.get_output(self.prob_network.output_layer, {self.l_input: all_input_var})) else: flat_input_var = TT.reshape(all_input_var, ((- 1), self.input_dim)) return dict(prob=L.get_output(self.prob_network.output_layer, {self.l_input: all_input_var, self.feature_network.input_layer: flat_input_var})) def reset(self): self.prev_action = None self.prev_hidden = self.prob_network.hid_init_param.get_value() @overrides def get_action(self, observation): if self.state_include_action: if (self.prev_action is None): prev_action = np.zeros((self.action_space.flat_dim,)) else: prev_action = self.action_space.flatten(self.prev_action) all_input = np.concatenate([self.observation_space.flatten(observation), prev_action]) else: all_input = self.observation_space.flatten(observation) prev_action = np.nan (probs, hidden_vec) = [x[0] for x in self.f_step_prob([all_input], [self.prev_hidden])] action = special.weighted_sample(probs, range(self.action_space.n)) self.prev_action = action self.prev_hidden = hidden_vec agent_info = dict(prob=probs) if self.state_include_action: agent_info['prev_action'] = prev_action return (action, agent_info) @property @overrides def recurrent(self): return True @property def distribution(self): return self.dist @property def state_info_keys(self): if self.state_include_action: return ['prev_action'] else: return []
class CategoricalMLPPolicy(StochasticPolicy, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_sizes=(32, 32), hidden_nonlinearity=NL.tanh, num_seq_inputs=1, prob_network=None): '\n :param env_spec: A spec for the mdp.\n :param hidden_sizes: list of sizes for the fully connected hidden layers\n :param hidden_nonlinearity: nonlinearity used for each hidden layer\n :param prob_network: manually specified network for this policy, other network params\n are ignored\n :return:\n ' Serializable.quick_init(self, locals()) assert isinstance(env_spec.action_space, Discrete) if (prob_network is None): prob_network = MLP(input_shape=((env_spec.observation_space.flat_dim * num_seq_inputs),), output_dim=env_spec.action_space.n, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=NL.softmax) self._l_prob = prob_network.output_layer self._l_obs = prob_network.input_layer self._f_prob = ext.compile_function([prob_network.input_layer.input_var], L.get_output(prob_network.output_layer)) self._dist = Categorical(env_spec.action_space.n) super(CategoricalMLPPolicy, self).__init__(env_spec) LasagnePowered.__init__(self, [prob_network.output_layer]) @overrides def dist_info_sym(self, obs_var, state_info_vars=None): return dict(prob=L.get_output(self._l_prob, {self._l_obs: obs_var})) @overrides def dist_info(self, obs, state_infos=None): return dict(prob=self._f_prob(obs)) @overrides def get_action(self, observation, deterministic=False): flat_obs = self.observation_space.flatten(observation) prob = self._f_prob([flat_obs])[0] if deterministic: action = np.argmax(prob) else: action = self.action_space.weighted_sample(prob) return (action, dict(prob=prob)) def get_actions(self, observations): flat_obs = self.observation_space.flatten_n(observations) probs = self._f_prob(flat_obs) actions = list(map(self.action_space.weighted_sample, probs)) return (actions, dict(prob=probs)) @property def distribution(self): return self._dist
class DeterministicMLPPolicy(Policy, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_sizes=(32, 32), hidden_nonlinearity=NL.rectify, hidden_W_init=LI.HeUniform(), hidden_b_init=LI.Constant(0.0), output_nonlinearity=NL.tanh, output_W_init=LI.Uniform((- 0.003), 0.003), output_b_init=LI.Uniform((- 0.003), 0.003), bn=False): Serializable.quick_init(self, locals()) l_obs = L.InputLayer(shape=(None, env_spec.observation_space.flat_dim)) l_hidden = l_obs if bn: l_hidden = batch_norm(l_hidden) for (idx, size) in enumerate(hidden_sizes): l_hidden = L.DenseLayer(l_hidden, num_units=size, W=hidden_W_init, b=hidden_b_init, nonlinearity=hidden_nonlinearity, name=('h%d' % idx)) if bn: l_hidden = batch_norm(l_hidden) l_output = L.DenseLayer(l_hidden, num_units=env_spec.action_space.flat_dim, W=output_W_init, b=output_b_init, nonlinearity=output_nonlinearity, name='output') action_var = L.get_output(l_output, deterministic=True) self._output_layer = l_output self._f_actions = ext.compile_function([l_obs.input_var], action_var) super(DeterministicMLPPolicy, self).__init__(env_spec) LasagnePowered.__init__(self, [l_output]) def get_action(self, observation): action = self._f_actions([observation])[0] return (action, dict()) def get_actions(self, observations): return (self._f_actions(observations), dict()) def get_action_sym(self, obs_var): return L.get_output(self._output_layer, obs_var)
class GaussianGRUPolicy(StochasticPolicy, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_sizes=(32,), state_include_action=True, hidden_nonlinearity=NL.tanh, learn_std=True, init_std=1.0, output_nonlinearity=None): '\n :param env_spec: A spec for the env.\n :param hidden_sizes: list of sizes for the fully connected hidden layers\n :param hidden_nonlinearity: nonlinearity used for each hidden layer\n :return:\n ' Serializable.quick_init(self, locals()) super(GaussianGRUPolicy, self).__init__(env_spec) assert (len(hidden_sizes) == 1) if state_include_action: obs_dim = (env_spec.observation_space.flat_dim + env_spec.action_space.flat_dim) else: obs_dim = env_spec.observation_space.flat_dim action_dim = env_spec.action_space.flat_dim mean_network = GRUNetwork(input_shape=(obs_dim,), output_dim=action_dim, hidden_dim=hidden_sizes[0], hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=output_nonlinearity) l_mean = mean_network.output_layer obs_var = mean_network.input_var l_log_std = ParamLayer(mean_network.input_layer, num_units=action_dim, param=lasagne.init.Constant(np.log(init_std)), name='output_log_std', trainable=learn_std) l_step_log_std = ParamLayer(mean_network.step_input_layer, num_units=action_dim, param=l_log_std.param, name='step_output_log_std', trainable=learn_std) self._mean_network = mean_network self._l_log_std = l_log_std self._state_include_action = state_include_action self._f_step_mean_std = ext.compile_function([mean_network.step_input_layer.input_var, mean_network.step_prev_hidden_layer.input_var], L.get_output([mean_network.step_output_layer, l_step_log_std, mean_network.step_hidden_layer])) self._prev_action = None self._prev_hidden = None self._hidden_sizes = hidden_sizes self._dist = RecurrentDiagonalGaussian(action_dim) self.reset() LasagnePowered.__init__(self, [mean_network.output_layer, l_log_std]) @overrides def dist_info_sym(self, obs_var, state_info_vars): (n_batches, n_steps) = obs_var.shape[:2] obs_var = obs_var.reshape((n_batches, n_steps, (- 1))) if self._state_include_action: prev_action_var = state_info_vars['prev_action'] all_input_var = TT.concatenate([obs_var, prev_action_var], axis=2) else: all_input_var = obs_var (means, log_stds) = L.get_output([self._mean_network.output_layer, self._l_log_std], all_input_var) return dict(mean=means, log_std=log_stds) def reset(self): self._prev_action = None self._prev_hidden = self._mean_network.hid_init_param.get_value() @overrides def get_action(self, observation): if self._state_include_action: if (self._prev_action is None): prev_action = np.zeros((self.action_space.flat_dim,)) else: prev_action = self.action_space.flatten(self._prev_action) all_input = np.concatenate([self.observation_space.flatten(observation), prev_action]) else: all_input = self.observation_space.flatten(observation) prev_action = np.nan (mean, log_std, hidden_vec) = [x[0] for x in self._f_step_mean_std([all_input], [self._prev_hidden])] rnd = np.random.normal(size=mean.shape) action = ((rnd * np.exp(log_std)) + mean) self._prev_action = action self._prev_hidden = hidden_vec agent_info = dict(mean=mean, log_std=log_std) if self._state_include_action: agent_info['prev_action'] = prev_action return (action, agent_info) @property @overrides def recurrent(self): return True @property def distribution(self): return self._dist @property def state_info_keys(self): if self._state_include_action: return ['prev_action'] else: return []
class GaussianMLPPolicy(StochasticPolicy, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_sizes=(32, 32), learn_std=True, init_std=1.0, adaptive_std=False, std_share_network=False, std_hidden_sizes=(32, 32), min_std=1e-06, std_hidden_nonlinearity=NL.tanh, hidden_nonlinearity=NL.tanh, output_nonlinearity=None, mean_network=None, std_network=None, dist_cls=DiagonalGaussian): '\n :param env_spec:\n :param hidden_sizes: list of sizes for the fully-connected hidden layers\n :param learn_std: Is std trainable\n :param init_std: Initial std\n :param adaptive_std:\n :param std_share_network:\n :param std_hidden_sizes: list of sizes for the fully-connected layers for std\n :param min_std: whether to make sure that the std is at least some threshold value, to avoid numerical issues\n :param std_hidden_nonlinearity:\n :param hidden_nonlinearity: nonlinearity used for each hidden layer\n :param output_nonlinearity: nonlinearity for the output layer\n :param mean_network: custom network for the output mean\n :param std_network: custom network for the output log std\n :return:\n ' Serializable.quick_init(self, locals()) assert isinstance(env_spec.action_space, Box) obs_dim = env_spec.observation_space.flat_dim action_dim = env_spec.action_space.flat_dim if (mean_network is None): mean_network = MLP(input_shape=(obs_dim,), output_dim=action_dim, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=output_nonlinearity) self._mean_network = mean_network l_mean = mean_network.output_layer obs_var = mean_network.input_layer.input_var if (std_network is not None): l_log_std = std_network.output_layer elif adaptive_std: std_network = MLP(input_shape=(obs_dim,), input_layer=mean_network.input_layer, output_dim=action_dim, hidden_sizes=std_hidden_sizes, hidden_nonlinearity=std_hidden_nonlinearity, output_nonlinearity=None) l_log_std = std_network.output_layer else: l_log_std = ParamLayer(mean_network.input_layer, num_units=action_dim, param=lasagne.init.Constant(np.log(init_std)), name='output_log_std', trainable=learn_std) self.min_std = min_std (mean_var, log_std_var) = L.get_output([l_mean, l_log_std]) if (self.min_std is not None): log_std_var = TT.maximum(log_std_var, np.log(min_std)) (self._mean_var, self._log_std_var) = (mean_var, log_std_var) self._l_mean = l_mean self._l_log_std = l_log_std self._dist = dist_cls(action_dim) LasagnePowered.__init__(self, [l_mean, l_log_std]) super(GaussianMLPPolicy, self).__init__(env_spec) self._f_dist = ext.compile_function(inputs=[obs_var], outputs=[mean_var, log_std_var]) def dist_info_sym(self, obs_var, state_info_vars=None): (mean_var, log_std_var) = L.get_output([self._l_mean, self._l_log_std], obs_var) if (self.min_std is not None): log_std_var = TT.maximum(log_std_var, np.log(self.min_std)) return dict(mean=mean_var, log_std=log_std_var) @overrides def get_action(self, observation): flat_obs = self.observation_space.flatten(observation) (mean, log_std) = [x[0] for x in self._f_dist([flat_obs])] rnd = np.random.normal(size=mean.shape) action = ((rnd * np.exp(log_std)) + mean) return (action, dict(mean=mean, log_std=log_std)) def get_actions(self, observations): flat_obs = self.observation_space.flatten_n(observations) (means, log_stds) = self._f_dist(flat_obs) rnd = np.random.normal(size=means.shape) actions = ((rnd * np.exp(log_stds)) + means) return (actions, dict(mean=means, log_std=log_stds)) def get_reparam_action_sym(self, obs_var, action_var, old_dist_info_vars): '\n Given observations, old actions, and distribution of old actions, return a symbolically reparameterized\n representation of the actions in terms of the policy parameters\n :param obs_var:\n :param action_var:\n :param old_dist_info_vars:\n :return:\n ' new_dist_info_vars = self.dist_info_sym(obs_var, action_var) (new_mean_var, new_log_std_var) = (new_dist_info_vars['mean'], new_dist_info_vars['log_std']) (old_mean_var, old_log_std_var) = (old_dist_info_vars['mean'], old_dist_info_vars['log_std']) epsilon_var = ((action_var - old_mean_var) / (TT.exp(old_log_std_var) + 1e-08)) new_action_var = (new_mean_var + (epsilon_var * TT.exp(new_log_std_var))) return new_action_var def log_diagnostics(self, paths): log_stds = np.vstack([path['agent_infos']['log_std'] for path in paths]) logger.record_tabular('AveragePolicyStd', np.mean(np.exp(log_stds))) @property def distribution(self): return self._dist
class UniformControlPolicy(Policy, Serializable): def __init__(self, env_spec): Serializable.quick_init(self, locals()) super(UniformControlPolicy, self).__init__(env_spec=env_spec) @overrides def get_action(self, observation): return (self.action_space.sample(), dict()) def get_params_internal(self, **tags): return [] def get_actions(self, observations): return (self.action_space.sample_n(len(observations)), dict()) @property def vectorized(self): return True def reset(self, dones=None): pass @property def distribution(self): return Delta()
class QFunction(Parameterized): pass
class ContinuousMLPQFunction(QFunction, LasagnePowered, Serializable): def __init__(self, env_spec, hidden_sizes=(32, 32), hidden_nonlinearity=NL.rectify, hidden_W_init=lasagne.init.HeUniform(), hidden_b_init=lasagne.init.Constant(0.0), action_merge_layer=(- 2), output_nonlinearity=None, output_W_init=lasagne.init.Uniform((- 0.003), 0.003), output_b_init=lasagne.init.Uniform((- 0.003), 0.003), bn=False): Serializable.quick_init(self, locals()) l_obs = L.InputLayer(shape=(None, env_spec.observation_space.flat_dim), name='obs') l_action = L.InputLayer(shape=(None, env_spec.action_space.flat_dim), name='actions') n_layers = (len(hidden_sizes) + 1) if (n_layers > 1): action_merge_layer = (((action_merge_layer % n_layers) + n_layers) % n_layers) else: action_merge_layer = 1 l_hidden = l_obs for (idx, size) in enumerate(hidden_sizes): if bn: l_hidden = batch_norm(l_hidden) if (idx == action_merge_layer): l_hidden = L.ConcatLayer([l_hidden, l_action]) l_hidden = L.DenseLayer(l_hidden, num_units=size, W=hidden_W_init, b=hidden_b_init, nonlinearity=hidden_nonlinearity, name=('h%d' % (idx + 1))) if (action_merge_layer == n_layers): l_hidden = L.ConcatLayer([l_hidden, l_action]) l_output = L.DenseLayer(l_hidden, num_units=1, W=output_W_init, b=output_b_init, nonlinearity=output_nonlinearity, name='output') output_var = L.get_output(l_output, deterministic=True).flatten() self._f_qval = ext.compile_function([l_obs.input_var, l_action.input_var], output_var) self._output_layer = l_output self._obs_layer = l_obs self._action_layer = l_action self._output_nonlinearity = output_nonlinearity LasagnePowered.__init__(self, [l_output]) def get_qval(self, observations, actions): return self._f_qval(observations, actions) def get_qval_sym(self, obs_var, action_var, **kwargs): qvals = L.get_output(self._output_layer, {self._obs_layer: obs_var, self._action_layer: action_var}, **kwargs) return TT.reshape(qvals, ((- 1),))
class CategoricalMLPRegressor(LasagnePowered, Serializable): '\n A class for performing regression (or classification, really) by fitting a categorical distribution to the outputs.\n Assumes that the outputs will be always a one hot vector.\n ' def __init__(self, input_shape, output_dim, prob_network=None, hidden_sizes=(32, 32), hidden_nonlinearity=NL.rectify, optimizer=None, use_trust_region=True, step_size=0.01, normalize_inputs=True, name=None): '\n :param input_shape: Shape of the input data.\n :param output_dim: Dimension of output.\n :param hidden_sizes: Number of hidden units of each layer of the mean network.\n :param hidden_nonlinearity: Non-linearity used for each layer of the mean network.\n :param optimizer: Optimizer for minimizing the negative log-likelihood.\n :param use_trust_region: Whether to use trust region constraint.\n :param step_size: KL divergence constraint for each iteration\n ' Serializable.quick_init(self, locals()) if (optimizer is None): if use_trust_region: optimizer = PenaltyLbfgsOptimizer() else: optimizer = LbfgsOptimizer() self.output_dim = output_dim self._optimizer = optimizer if (prob_network is None): prob_network = MLP(input_shape=input_shape, output_dim=output_dim, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=NL.softmax) l_prob = prob_network.output_layer LasagnePowered.__init__(self, [l_prob]) xs_var = prob_network.input_layer.input_var ys_var = TT.imatrix('ys') old_prob_var = TT.matrix('old_prob') x_mean_var = theano.shared(np.zeros(((1,) + input_shape)), name='x_mean', broadcastable=((True,) + ((False,) * len(input_shape)))) x_std_var = theano.shared(np.ones(((1,) + input_shape)), name='x_std', broadcastable=((True,) + ((False,) * len(input_shape)))) normalized_xs_var = ((xs_var - x_mean_var) / x_std_var) prob_var = L.get_output(l_prob, {prob_network.input_layer: normalized_xs_var}) old_info_vars = dict(prob=old_prob_var) info_vars = dict(prob=prob_var) dist = self._dist = Categorical(output_dim) mean_kl = TT.mean(dist.kl_sym(old_info_vars, info_vars)) loss = (- TT.mean(dist.log_likelihood_sym(ys_var, info_vars))) predicted = special.to_onehot_sym(TT.argmax(prob_var, axis=1), output_dim) self._f_predict = ext.compile_function([xs_var], predicted) self._f_prob = ext.compile_function([xs_var], prob_var) self._prob_network = prob_network self._l_prob = l_prob optimizer_args = dict(loss=loss, target=self, network_outputs=[prob_var]) if use_trust_region: optimizer_args['leq_constraint'] = (mean_kl, step_size) optimizer_args['inputs'] = [xs_var, ys_var, old_prob_var] else: optimizer_args['inputs'] = [xs_var, ys_var] self._optimizer.update_opt(**optimizer_args) self._use_trust_region = use_trust_region self._name = name self._normalize_inputs = normalize_inputs self._x_mean_var = x_mean_var self._x_std_var = x_std_var def fit(self, xs, ys): if self._normalize_inputs: self._x_mean_var.set_value(np.mean(xs, axis=0, keepdims=True)) self._x_std_var.set_value((np.std(xs, axis=0, keepdims=True) + 1e-08)) if self._use_trust_region: old_prob = self._f_prob(xs) inputs = [xs, ys, old_prob] else: inputs = [xs, ys] loss_before = self._optimizer.loss(inputs) if self._name: prefix = (self._name + '_') else: prefix = '' logger.record_tabular((prefix + 'LossBefore'), loss_before) self._optimizer.optimize(inputs) loss_after = self._optimizer.loss(inputs) logger.record_tabular((prefix + 'LossAfter'), loss_after) logger.record_tabular((prefix + 'dLoss'), (loss_before - loss_after)) def predict(self, xs): return self._f_predict(np.asarray(xs)) def predict_log_likelihood(self, xs, ys): prob = self._f_prob(np.asarray(xs)) return self._dist.log_likelihood(np.asarray(ys), dict(prob=prob)) def log_likelihood_sym(self, x_var, y_var): normalized_xs_var = ((x_var - self._x_mean_var) / self._x_std_var) prob = L.get_output(self._l_prob, {self._prob_network.input_layer: normalized_xs_var}) return self._dist.log_likelihood_sym(TT.cast(y_var, 'int32'), dict(prob=prob)) def get_param_values(self, **tags): return LasagnePowered.get_param_values(self, **tags) def set_param_values(self, flattened_params, **tags): return LasagnePowered.set_param_values(self, flattened_params, **tags)
class GaussianConvRegressor(LasagnePowered, Serializable): '\n A class for performing regression by fitting a Gaussian distribution to the outputs.\n ' def __init__(self, name, input_shape, output_dim, hidden_sizes, conv_filters, conv_filter_sizes, conv_strides, conv_pads, hidden_nonlinearity=NL.rectify, mean_network=None, optimizer=None, use_trust_region=True, step_size=0.01, subsample_factor=1.0, batchsize=None, learn_std=True, init_std=1.0, adaptive_std=False, std_share_network=False, std_conv_filters=[], std_conv_filters_sizes=[], std_conv_strides=[], std_conv_pads=[], std_hidden_sizes=(32, 32), std_nonlinearity=None, normalize_inputs=True, normalize_outputs=True): '\n :param input_shape: usually for images of the form (width,height,channel)\n :param output_dim: Dimension of output.\n :param hidden_sizes: Number of hidden units of each layer of the mean network.\n :param hidden_nonlinearity: Non-linearity used for each layer of the mean network.\n :param optimizer: Optimizer for minimizing the negative log-likelihood.\n :param use_trust_region: Whether to use trust region constraint.\n :param step_size: KL divergence constraint for each iteration\n :param learn_std: Whether to learn the standard deviations. Only effective if adaptive_std is False. If\n adaptive_std is True, this parameter is ignored, and the weights for the std network are always learned.\n :param adaptive_std: Whether to make the std a function of the states.\n :param std_share_network: Whether to use the same network as the mean.\n :param std_hidden_sizes: Number of hidden units of each layer of the std network. Only used if\n `std_share_network` is False. It defaults to the same architecture as the mean.\n :param std_nonlinearity: Non-linearity used for each layer of the std network. Only used if `std_share_network`\n is False. It defaults to the same non-linearity as the mean.\n ' Serializable.quick_init(self, locals()) if (optimizer is None): if use_trust_region: optimizer = PenaltyLbfgsOptimizer('optimizer') else: optimizer = LbfgsOptimizer('optimizer') self._optimizer = optimizer self.input_shape = input_shape if (mean_network is None): mean_network = ConvNetwork(name='mean_network', input_shape=input_shape, output_dim=output_dim, conv_filters=conv_filters, conv_filter_sizes=conv_filter_sizes, conv_strides=conv_strides, conv_pads=conv_pads, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=None) l_mean = mean_network.output_layer if adaptive_std: l_log_std = ConvNetwork(name='log_std_network', input_shape=input_shape, input_var=mean_network.input_layer.input_var, output_dim=output_dim, conv_filters=std_conv_filters, conv_filter_sizes=std_conv_filter_sizes, conv_strides=std_conv_strides, conv_pads=std_conv_pads, hidden_sizes=std_hidden_sizes, hidden_nonlinearity=std_nonlinearity, output_nonlinearity=None).output_layer else: l_log_std = ParamLayer(mean_network.input_layer, num_units=output_dim, param=lasagne.init.Constant(np.log(init_std)), name='output_log_std', trainable=learn_std) LasagnePowered.__init__(self, [l_mean, l_log_std]) xs_var = mean_network.input_layer.input_var ys_var = TT.matrix('ys') old_means_var = TT.matrix('old_means') old_log_stds_var = TT.matrix('old_log_stds') x_mean_var = theano.shared(np.zeros((1, np.prod(input_shape)), dtype=theano.config.floatX), name='x_mean', broadcastable=(True, False)) x_std_var = theano.shared(np.ones((1, np.prod(input_shape)), dtype=theano.config.floatX), name='x_std', broadcastable=(True, False)) y_mean_var = theano.shared(np.zeros((1, output_dim), dtype=theano.config.floatX), name='y_mean', broadcastable=(True, False)) y_std_var = theano.shared(np.ones((1, output_dim), dtype=theano.config.floatX), name='y_std', broadcastable=(True, False)) normalized_xs_var = ((xs_var - x_mean_var) / x_std_var) normalized_ys_var = ((ys_var - y_mean_var) / y_std_var) normalized_means_var = L.get_output(l_mean, {mean_network.input_layer: normalized_xs_var}) normalized_log_stds_var = L.get_output(l_log_std, {mean_network.input_layer: normalized_xs_var}) means_var = ((normalized_means_var * y_std_var) + y_mean_var) log_stds_var = (normalized_log_stds_var + TT.log(y_std_var)) normalized_old_means_var = ((old_means_var - y_mean_var) / y_std_var) normalized_old_log_stds_var = (old_log_stds_var - TT.log(y_std_var)) dist = self._dist = DiagonalGaussian(output_dim) normalized_dist_info_vars = dict(mean=normalized_means_var, log_std=normalized_log_stds_var) mean_kl = TT.mean(dist.kl_sym(dict(mean=normalized_old_means_var, log_std=normalized_old_log_stds_var), normalized_dist_info_vars)) loss = (- TT.mean(dist.log_likelihood_sym(normalized_ys_var, normalized_dist_info_vars))) self._f_predict = compile_function([xs_var], means_var) self._f_pdists = compile_function([xs_var], [means_var, log_stds_var]) self._l_mean = l_mean self._l_log_std = l_log_std optimizer_args = dict(loss=loss, target=self, network_outputs=[normalized_means_var, normalized_log_stds_var]) if use_trust_region: optimizer_args['leq_constraint'] = (mean_kl, step_size) optimizer_args['inputs'] = [xs_var, ys_var, old_means_var, old_log_stds_var] else: optimizer_args['inputs'] = [xs_var, ys_var] self._optimizer.update_opt(**optimizer_args) self._use_trust_region = use_trust_region self._name = name self._normalize_inputs = normalize_inputs self._normalize_outputs = normalize_outputs self._mean_network = mean_network self._x_mean_var = x_mean_var self._x_std_var = x_std_var self._y_mean_var = y_mean_var self._y_std_var = y_std_var self._subsample_factor = subsample_factor self._batchsize = batchsize def fit(self, xs, ys): if (self._subsample_factor < 1): num_samples_tot = xs.shape[0] idx = np.random.randint(0, num_samples_tot, int((num_samples_tot * self._subsample_factor))) (xs, ys) = (xs[idx], ys[idx]) if self._normalize_inputs: self._x_mean_var.set_value(np.mean(xs, axis=0, keepdims=True).astype(theano.config.floatX)) self._x_std_var.set_value((np.std(xs, axis=0, keepdims=True) + 1e-08).astype(theano.config.floatX)) if self._normalize_outputs: self._y_mean_var.set_value(np.mean(ys, axis=0, keepdims=True).astype(theano.config.floatX)) self._y_std_var.set_value((np.std(ys, axis=0, keepdims=True) + 1e-08).astype(theano.config.floatX)) if self._name: prefix = (self._name + '_') else: prefix = '' (loss_before, loss_after, mean_kl, batch_count) = (0.0, 0.0, 0.0, 0) for batch in iterate_minibatches_generic(input_lst=[xs, ys], batchsize=self._batchsize, shuffle=True): batch_count += 1 (xs, ys) = batch if self._use_trust_region: (old_means, old_log_stds) = self._f_pdists(xs) inputs = [xs, ys, old_means, old_log_stds] else: inputs = [xs, ys] loss_before += self._optimizer.loss(inputs) self._optimizer.optimize(inputs) loss_after += self._optimizer.loss(inputs) if self._use_trust_region: mean_kl += self._optimizer.constraint_val(inputs) logger.record_tabular((prefix + 'LossBefore'), (loss_before / batch_count)) logger.record_tabular((prefix + 'LossAfter'), (loss_after / batch_count)) logger.record_tabular((prefix + 'dLoss'), (loss_before - (loss_after / batch_count))) if self._use_trust_region: logger.record_tabular((prefix + 'MeanKL'), (mean_kl / batch_count)) def predict(self, xs): '\n Return the maximum likelihood estimate of the predicted y.\n :param xs:\n :return:\n ' return self._f_predict(xs) def sample_predict(self, xs): '\n Sample one possible output from the prediction distribution.\n :param xs:\n :return:\n ' (means, log_stds) = self._f_pdists(xs) return self._dist.sample(dict(mean=means, log_std=log_stds)) def predict_log_likelihood(self, xs, ys): (means, log_stds) = self._f_pdists(xs) return self._dist.log_likelihood(ys, dict(mean=means, log_std=log_stds)) def log_likelihood_sym(self, x_var, y_var): normalized_xs_var = ((x_var - self._x_mean_var) / self._x_std_var) (normalized_means_var, normalized_log_stds_var) = L.get_output([self._l_mean, self._l_log_std], {self._mean_network.input_layer: normalized_xs_var}) means_var = ((normalized_means_var * self._y_std_var) + self._y_mean_var) log_stds_var = (normalized_log_stds_var + TT.log(self._y_std_var)) return self._dist.log_likelihood_sym(y_var, dict(mean=means_var, log_std=log_stds_var)) def get_param_values(self, **tags): return LasagnePowered.get_param_values(self, **tags) def set_param_values(self, flattened_params, **tags): return LasagnePowered.set_param_values(self, flattened_params, **tags)
class GaussianMLPRegressor(LasagnePowered, Serializable): '\n A class for performing regression by fitting a Gaussian distribution to the outputs.\n ' def __init__(self, input_shape, output_dim, mean_network=None, hidden_sizes=(32, 32), hidden_nonlinearity=NL.rectify, optimizer=None, use_trust_region=True, step_size=0.01, learn_std=True, init_std=1.0, adaptive_std=False, std_share_network=False, std_hidden_sizes=(32, 32), std_nonlinearity=None, normalize_inputs=True, normalize_outputs=True, name=None, batchsize=None, subsample_factor=1.0): '\n :param input_shape: Shape of the input data.\n :param output_dim: Dimension of output.\n :param hidden_sizes: Number of hidden units of each layer of the mean network.\n :param hidden_nonlinearity: Non-linearity used for each layer of the mean network.\n :param optimizer: Optimizer for minimizing the negative log-likelihood.\n :param use_trust_region: Whether to use trust region constraint.\n :param step_size: KL divergence constraint for each iteration\n :param learn_std: Whether to learn the standard deviations. Only effective if adaptive_std is False. If\n adaptive_std is True, this parameter is ignored, and the weights for the std network are always learned.\n :param adaptive_std: Whether to make the std a function of the states.\n :param std_share_network: Whether to use the same network as the mean.\n :param std_hidden_sizes: Number of hidden units of each layer of the std network. Only used if\n `std_share_network` is False. It defaults to the same architecture as the mean.\n :param std_nonlinearity: Non-linearity used for each layer of the std network. Only used if `std_share_network`\n is False. It defaults to the same non-linearity as the mean.\n ' Serializable.quick_init(self, locals()) self._batchsize = batchsize self._subsample_factor = subsample_factor if (optimizer is None): if use_trust_region: optimizer = PenaltyLbfgsOptimizer() else: optimizer = LbfgsOptimizer() self._optimizer = optimizer if (mean_network is None): mean_network = MLP(input_shape=input_shape, output_dim=output_dim, hidden_sizes=hidden_sizes, hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=None) l_mean = mean_network.output_layer if adaptive_std: l_log_std = MLP(input_shape=input_shape, input_var=mean_network.input_layer.input_var, output_dim=output_dim, hidden_sizes=std_hidden_sizes, hidden_nonlinearity=std_nonlinearity, output_nonlinearity=None).output_layer else: l_log_std = ParamLayer(mean_network.input_layer, num_units=output_dim, param=lasagne.init.Constant(np.log(init_std)), name='output_log_std', trainable=learn_std) LasagnePowered.__init__(self, [l_mean, l_log_std]) xs_var = mean_network.input_layer.input_var ys_var = TT.matrix('ys') old_means_var = TT.matrix('old_means') old_log_stds_var = TT.matrix('old_log_stds') x_mean_var = theano.shared(np.zeros(((1,) + input_shape), dtype=theano.config.floatX), name='x_mean', broadcastable=((True,) + ((False,) * len(input_shape)))) x_std_var = theano.shared(np.ones(((1,) + input_shape), dtype=theano.config.floatX), name='x_std', broadcastable=((True,) + ((False,) * len(input_shape)))) y_mean_var = theano.shared(np.zeros((1, output_dim), dtype=theano.config.floatX), name='y_mean', broadcastable=(True, False)) y_std_var = theano.shared(np.ones((1, output_dim), dtype=theano.config.floatX), name='y_std', broadcastable=(True, False)) normalized_xs_var = ((xs_var - x_mean_var) / x_std_var) normalized_ys_var = ((ys_var - y_mean_var) / y_std_var) normalized_means_var = L.get_output(l_mean, {mean_network.input_layer: normalized_xs_var}) normalized_log_stds_var = L.get_output(l_log_std, {mean_network.input_layer: normalized_xs_var}) means_var = ((normalized_means_var * y_std_var) + y_mean_var) log_stds_var = (normalized_log_stds_var + TT.log(y_std_var)) normalized_old_means_var = ((old_means_var - y_mean_var) / y_std_var) normalized_old_log_stds_var = (old_log_stds_var - TT.log(y_std_var)) dist = self._dist = DiagonalGaussian(output_dim) normalized_dist_info_vars = dict(mean=normalized_means_var, log_std=normalized_log_stds_var) mean_kl = TT.mean(dist.kl_sym(dict(mean=normalized_old_means_var, log_std=normalized_old_log_stds_var), normalized_dist_info_vars)) loss = (- TT.mean(dist.log_likelihood_sym(normalized_ys_var, normalized_dist_info_vars))) self._f_predict = compile_function([xs_var], means_var) self._f_pdists = compile_function([xs_var], [means_var, log_stds_var]) self._l_mean = l_mean self._l_log_std = l_log_std optimizer_args = dict(loss=loss, target=self, network_outputs=[normalized_means_var, normalized_log_stds_var]) if use_trust_region: optimizer_args['leq_constraint'] = (mean_kl, step_size) optimizer_args['inputs'] = [xs_var, ys_var, old_means_var, old_log_stds_var] else: optimizer_args['inputs'] = [xs_var, ys_var] self._optimizer.update_opt(**optimizer_args) self._use_trust_region = use_trust_region self._name = name self._normalize_inputs = normalize_inputs self._normalize_outputs = normalize_outputs self._mean_network = mean_network self._x_mean_var = x_mean_var self._x_std_var = x_std_var self._y_mean_var = y_mean_var self._y_std_var = y_std_var def fit(self, xs, ys, log=True): if (self._subsample_factor < 1): num_samples_tot = xs.shape[0] idx = np.random.randint(0, num_samples_tot, int((num_samples_tot * self._subsample_factor))) (xs, ys) = (xs[idx], ys[idx]) if self._normalize_inputs: self._x_mean_var.set_value(np.mean(xs, axis=0, keepdims=True).astype(theano.config.floatX)) self._x_std_var.set_value((np.std(xs, axis=0, keepdims=True) + 1e-08).astype(theano.config.floatX)) if self._normalize_outputs: self._y_mean_var.set_value(np.mean(ys, axis=0, keepdims=True).astype(theano.config.floatX)) self._y_std_var.set_value((np.std(ys, axis=0, keepdims=True) + 1e-08).astype(theano.config.floatX)) if self._name: prefix = (self._name + '_') else: prefix = '' (loss_before, loss_after, mean_kl, batch_count) = (0.0, 0.0, 0.0, 0) for batch in iterate_minibatches_generic(input_lst=[xs, ys], batchsize=self._batchsize, shuffle=True): batch_count += 1 (xs, ys) = batch if self._use_trust_region: (old_means, old_log_stds) = self._f_pdists(xs) inputs = [xs, ys, old_means, old_log_stds] else: inputs = [xs, ys] loss_before += self._optimizer.loss(inputs) self._optimizer.optimize(inputs) loss_after += self._optimizer.loss(inputs) if self._use_trust_region: mean_kl += self._optimizer.constraint_val(inputs) if log: logger.record_tabular((prefix + 'LossBefore'), (loss_before / batch_count)) logger.record_tabular((prefix + 'LossAfter'), (loss_after / batch_count)) logger.record_tabular((prefix + 'dLoss'), (loss_before - (loss_after / batch_count))) if self._use_trust_region: logger.record_tabular((prefix + 'MeanKL'), (mean_kl / batch_count)) def predict(self, xs): '\n Return the maximum likelihood estimate of the predicted y.\n :param xs:\n :return:\n ' return self._f_predict(xs) def sample_predict(self, xs): '\n Sample one possible output from the prediction distribution.\n :param xs:\n :return:\n ' (means, log_stds) = self._f_pdists(xs) return self._dist.sample(dict(mean=means, log_std=log_stds)) def predict_log_likelihood(self, xs, ys): (means, log_stds) = self._f_pdists(xs) return self._dist.log_likelihood(ys, dict(mean=means, log_std=log_stds)) def log_likelihood_sym(self, x_var, y_var): normalized_xs_var = ((x_var - self._x_mean_var) / self._x_std_var) (normalized_means_var, normalized_log_stds_var) = L.get_output([self._l_mean, self._l_log_std], {self._mean_network.input_layer: normalized_xs_var}) means_var = ((normalized_means_var * self._y_std_var) + self._y_mean_var) log_stds_var = (normalized_log_stds_var + TT.log(self._y_std_var)) return self._dist.log_likelihood_sym(y_var, dict(mean=means_var, log_std=log_stds_var)) def get_param_values(self, **tags): return LasagnePowered.get_param_values(self, **tags) def set_param_values(self, flattened_params, **tags): return LasagnePowered.set_param_values(self, flattened_params, **tags)
class ProductRegressor(Serializable): '\n A class for performing MLE regression by fitting a product distribution to the outputs. A separate regressor will\n be trained for each individual input distribution.\n ' def __init__(self, regressors): '\n :param regressors: List of individual regressors\n ' Serializable.quick_init(self, locals()) self.regressors = regressors self.output_dims = [x.output_dim for x in regressors] def _split_ys(self, ys): ys = np.asarray(ys) split_ids = np.cumsum(self.output_dims)[:(- 1)] return np.split(ys, split_ids, axis=1) def fit(self, xs, ys): for (regressor, split_ys) in zip(self.regressors, self._split_ys(ys)): regressor.fit(xs, split_ys) def predict(self, xs): return np.concatenate([regressor.predict(xs) for regressor in self.regressors], axis=1) def sample_predict(self, xs): return np.concatenate([regressor.sample_predict(xs) for regressor in self.regressors], axis=1) def predict_log_likelihood(self, xs, ys): return np.sum([regressor.predict_log_likelihood(xs, split_ys) for (regressor, split_ys) in zip(self.regressors, self._split_ys(ys))], axis=0) def get_param_values(self, **tags): return np.concatenate([regressor.get_param_values(**tags) for regressor in self.regressors]) def set_param_values(self, flattened_params, **tags): param_dims = [np.prod(regressor.get_param_shapes(**tags)) for regressor in self.regressors] split_ids = np.cumsum(param_dims)[:(- 1)] for (regressor, split_param_values) in zip(self.regressors, np.split(flattened_params, split_ids)): regressor.set_param_values(split_param_values)
def _worker_init(G, id): if (singleton_pool.n_parallel > 1): import os os.environ['THEANO_FLAGS'] = 'device=cpu' os.environ['CUDA_VISIBLE_DEVICES'] = '' G.worker_id = id
def initialize(n_parallel): singleton_pool.initialize(n_parallel) singleton_pool.run_each(_worker_init, [(id,) for id in range(singleton_pool.n_parallel)])
def _get_scoped_G(G, scope): if (scope is None): return G if (not hasattr(G, 'scopes')): G.scopes = dict() if (scope not in G.scopes): G.scopes[scope] = SharedGlobal() G.scopes[scope].worker_id = G.worker_id return G.scopes[scope]
def _worker_populate_task(G, env, policy, scope=None): G = _get_scoped_G(G, scope) G.env = pickle.loads(env) G.policy = pickle.loads(policy)
def _worker_terminate_task(G, scope=None): G = _get_scoped_G(G, scope) if getattr(G, 'env', None): G.env.terminate() G.env = None if getattr(G, 'policy', None): G.policy.terminate() G.policy = None
def populate_task(env, policy, scope=None): logger.log('Populating workers...') if (singleton_pool.n_parallel > 1): singleton_pool.run_each(_worker_populate_task, ([(pickle.dumps(env), pickle.dumps(policy), scope)] * singleton_pool.n_parallel)) else: G = _get_scoped_G(singleton_pool.G, scope) G.env = env G.policy = policy logger.log('Populated')
def terminate_task(scope=None): singleton_pool.run_each(_worker_terminate_task, ([(scope,)] * singleton_pool.n_parallel))
def _worker_set_seed(_, seed): logger.log(('Setting seed to %d' % seed)) ext.set_seed(seed)
def set_seed(seed): singleton_pool.run_each(_worker_set_seed, [((seed + i),) for i in range(singleton_pool.n_parallel)])
def _worker_set_policy_params(G, params, scope=None): G = _get_scoped_G(G, scope) G.policy.set_param_values(params)
def _worker_set_env_params(G, params, scope=None): G = _get_scoped_G(G, scope) G.env.set_param_values(params)
def _worker_collect_one_path(G, max_path_length, scope=None, reset_arg=None): G = _get_scoped_G(G, scope) path = rollout(G.env, G.policy, max_path_length, reset_arg=reset_arg) return (path, len(path['rewards']))
def sample_paths(policy_params, max_samples, max_path_length=np.inf, env_params=None, scope=None, reset_arg=None, show_prog_bar=True, multi_task=False): '\n :param policy_params: parameters for the policy. This will be updated on each worker process\n :param max_samples: desired maximum number of samples to be collected. The actual number of collected samples\n might be greater since all trajectories will be rolled out either until termination or until max_path_length is\n reached\n :param max_path_length: horizon / maximum length of a single trajectory\n :return: a list of collected paths\n ' if multi_task: assert (len(policy_params) == singleton_pool.n_parallel) all_params = [(params, scope) for params in policy_params] singleton_pool.run_each(_worker_set_policy_params, all_params) else: singleton_pool.run_each(_worker_set_policy_params, ([(policy_params, scope)] * singleton_pool.n_parallel)) if (env_params is not None): singleton_pool.run_each(_worker_set_env_params, ([(env_params, scope)] * singleton_pool.n_parallel)) if multi_task: args = [(max_path_length, scope, arg) for arg in reset_arg] return singleton_pool.run_collect(_worker_collect_one_path, threshold=max_samples, args=args, show_prog_bar=show_prog_bar, multi_task=multi_task) else: return singleton_pool.run_collect(_worker_collect_one_path, threshold=max_samples, args=(max_path_length, scope, reset_arg), show_prog_bar=show_prog_bar, multi_task=multi_task)
def truncate_paths(paths, max_samples): '\n Truncate the list of paths so that the total number of samples is exactly equal to max_samples. This is done by\n removing extra paths at the end of the list, and make the last path shorter if necessary\n :param paths: a list of paths\n :param max_samples: the absolute maximum number of samples\n :return: a list of paths, truncated so that the number of samples adds up to max-samples\n ' paths = list(paths) total_n_samples = sum((len(path['rewards']) for path in paths)) while ((len(paths) > 0) and ((total_n_samples - len(paths[(- 1)]['rewards'])) >= max_samples)): total_n_samples -= len(paths.pop((- 1))['rewards']) if (len(paths) > 0): last_path = paths.pop((- 1)) truncated_last_path = dict() truncated_len = (len(last_path['rewards']) - (total_n_samples - max_samples)) for (k, v) in last_path.items(): if (k in ['observations', 'actions', 'rewards']): truncated_last_path[k] = tensor_utils.truncate_tensor_list(v, truncated_len) elif (k in ['env_infos', 'agent_infos']): truncated_last_path[k] = tensor_utils.truncate_tensor_dict(v, truncated_len) else: raise NotImplementedError paths.append(truncated_last_path) return paths
class ProgBarCounter(object): def __init__(self, total_count): self.total_count = total_count self.max_progress = 1000000 self.cur_progress = 0 self.cur_count = 0 if (not logger.get_log_tabular_only()): self.pbar = pyprind.ProgBar(self.max_progress) else: self.pbar = None def inc(self, increment): if (not logger.get_log_tabular_only()): self.cur_count += increment new_progress = ((self.cur_count * self.max_progress) / self.total_count) if (new_progress < self.max_progress): self.pbar.update((new_progress - self.cur_progress)) self.cur_progress = new_progress def stop(self): if ((self.pbar is not None) and self.pbar.active): self.pbar.stop()
class SharedGlobal(object): pass
class StatefulPool(object): def __init__(self): self.n_parallel = 1 self.pool = None self.queue = None self.worker_queue = None self.G = SharedGlobal() def initialize(self, n_parallel): self.n_parallel = n_parallel if (self.pool is not None): print('Warning: terminating existing pool') self.pool.terminate() self.queue.close() self.worker_queue.close() self.G = SharedGlobal() if (n_parallel > 1): self.queue = mp.Queue() self.worker_queue = mp.Queue() self.pool = MemmapingPool(self.n_parallel, temp_folder='/tmp') def run_each(self, runner, args_list=None): "\n Run the method on each worker process, and collect the result of execution.\n The runner method will receive 'G' as its first argument, followed by the arguments\n in the args_list, if any\n :return:\n " if (args_list is None): args_list = ([tuple()] * self.n_parallel) assert (len(args_list) == self.n_parallel) if (self.n_parallel > 1): results = self.pool.map_async(_worker_run_each, [(runner, args) for args in args_list]) for i in range(self.n_parallel): self.worker_queue.get() for i in range(self.n_parallel): self.queue.put(None) return results.get() return [runner(self.G, *args_list[0])] def run_map(self, runner, args_list): if (self.n_parallel > 1): return self.pool.map(_worker_run_map, [(runner, args) for args in args_list]) else: ret = [] for args in args_list: ret.append(runner(self.G, *args)) return ret def run_imap_unordered(self, runner, args_list): if (self.n_parallel > 1): for x in self.pool.imap_unordered(_worker_run_map, [(runner, args) for args in args_list]): (yield x) else: for args in args_list: (yield runner(self.G, *args)) def run_collect(self, collect_once, threshold, args=None, show_prog_bar=True, multi_task=False): "\n Run the collector method using the worker pool. The collect_once method will receive 'G' as\n its first argument, followed by the provided args, if any. The method should return a pair of values.\n The first should be the object to be collected, and the second is the increment to be added.\n This will continue until the total increment reaches or exceeds the given threshold.\n\n Sample script:\n\n def collect_once(G):\n return 'a', 1\n\n stateful_pool.run_collect(collect_once, threshold=3) # => ['a', 'a', 'a']\n\n :param collector:\n :param threshold:\n :return:\n " if (args is None): args = tuple() if (self.pool and multi_task): manager = mp.Manager() counter = manager.Value('i', 0) lock = manager.RLock() inputs = [(collect_once, counter, lock, threshold, arg) for arg in args] results = self.pool.map_async(_worker_run_collect, inputs) if show_prog_bar: pbar = ProgBarCounter(threshold) last_value = 0 while True: time.sleep(0.1) with lock: if (counter.value >= threshold): if show_prog_bar: pbar.stop() break if show_prog_bar: pbar.inc((counter.value - last_value)) last_value = counter.value finished_results = results.get() return {i: finished_results[i] for i in range(len(finished_results))} elif multi_task: assert False elif self.pool: manager = mp.Manager() counter = manager.Value('i', 0) lock = manager.RLock() results = self.pool.map_async(_worker_run_collect, ([(collect_once, counter, lock, threshold, args)] * self.n_parallel)) if show_prog_bar: pbar = ProgBarCounter(threshold) last_value = 0 while True: time.sleep(0.1) with lock: if (counter.value >= threshold): if show_prog_bar: pbar.stop() break if show_prog_bar: pbar.inc((counter.value - last_value)) last_value = counter.value return sum(results.get(), []) else: count = 0 results = [] if show_prog_bar: pbar = ProgBarCounter(threshold) while (count < threshold): (result, inc) = collect_once(self.G, *args) results.append(result) count += inc if show_prog_bar: pbar.inc(inc) if show_prog_bar: pbar.stop() return results
def _worker_run_each(all_args): try: (runner, args) = all_args singleton_pool.worker_queue.put(None) singleton_pool.queue.get() return runner(singleton_pool.G, *args) except Exception: raise Exception(''.join(traceback.format_exception(*sys.exc_info())))
def _worker_run_collect(all_args): try: (collect_once, counter, lock, threshold, args) = all_args collected = [] while True: with lock: if (counter.value >= threshold): return collected (result, inc) = collect_once(singleton_pool.G, *args) collected.append(result) with lock: counter.value += inc if (counter.value >= threshold): return collected except Exception: raise Exception(''.join(traceback.format_exception(*sys.exc_info())))
def _worker_run_map(all_args): try: (runner, args) = all_args return runner(singleton_pool.G, *args) except Exception: raise Exception(''.join(traceback.format_exception(*sys.exc_info())))
def rollout(env, agent, max_path_length=np.inf, noise=None, task_idx=0, animated=False, speedup=1, save_video=False, video_filename='sim_out.mp4', reset_arg=None): observations = [] actions = [] rewards = [] agent_infos = [] env_infos = [] images = [] noises = [] task_idxs = [] o = env.reset(reset_args=reset_arg) agent.reset() path_length = 0 if animated: env.render() if (noise is None): noise = np.random.normal(0, 1, size=(agent.latent_dim,)) while (path_length < max_path_length): (a, agent_info) = agent.get_action(o, task_idx, noise) (next_o, r, d, env_info) = env.step(a) observations.append(env.observation_space.flatten(o)) rewards.append(r) actions.append(env.action_space.flatten(a)) agent_infos.append(agent_info) env_infos.append(env_info) noises.append(noise) task_idxs.append(task_idx) path_length += 1 if d: break o = next_o if animated: env.render() timestep = 0.05 time.sleep((timestep / speedup)) if save_video: from PIL import Image image = env.wrapped_env.wrapped_env.get_viewer().get_image() pil_image = Image.frombytes('RGB', (image[1], image[2]), image[0]) images.append(np.flipud(np.array(pil_image))) if animated: if (save_video and (len(images) >= max_path_length)): import moviepy.editor as mpy clip = mpy.ImageSequenceClip(images, fps=(20 * speedup)) if (video_filename[(- 3):] == 'gif'): clip.write_gif(video_filename, fps=(20 * speedup)) else: clip.write_videofile(video_filename, fps=(20 * speedup)) return dict(observations=tensor_utils.stack_tensor_list(observations), actions=tensor_utils.stack_tensor_list(actions), rewards=tensor_utils.stack_tensor_list(rewards), noises=tensor_utils.stack_tensor_list(noises), task_idxs=tensor_utils.stack_tensor_list(task_idxs), agent_infos=tensor_utils.stack_tensor_dict_list(agent_infos), env_infos=tensor_utils.stack_tensor_dict_list(env_infos))
def rollout_prior(env, agent, max_path_length=np.inf, task_idx=0, noise=None, animated=False, speedup=1, save_video=True, video_filename='sim_out.mp4', reset_arg=None): observations = [] actions = [] rewards = [] agent_infos = [] env_infos = [] images = [] noises = [] task_idxs = [] o = env.reset(reset_args=reset_arg) agent.reset() path_length = 0 if animated: env.render() if (noise is None): noise = np.random.normal(0, 1, size=(agent.latent_dim,)) sess = tf.get_default_session() while (path_length < max_path_length): a_mean = sess.run(agent.output_tensor_tosample, feed_dict={agent.input_tensor: [o], agent.zs: [noise]})[0] a_stds = sess.run(agent.all_params['std_param']) a_noise = np.random.normal(size=a_mean.shape) a = (a_mean + (np.exp(a_stds) * a_noise)) (next_o, r, d, env_info) = env.step(a) observations.append(env.observation_space.flatten(o)) rewards.append(r) actions.append(env.action_space.flatten(a)) env_infos.append(env_info) noises.append(noise) task_idxs.append(task_idx) path_length += 1 if d: break o = next_o if animated: env.render() timestep = 0.05 time.sleep((timestep / speedup)) if save_video: from PIL import Image image = env.wrapped_env.wrapped_env.get_viewer().get_image() pil_image = Image.frombytes('RGB', (image[1], image[2]), image[0]) images.append(np.flipud(np.array(pil_image))) if animated: if (save_video and (len(images) >= max_path_length)): import moviepy.editor as mpy clip = mpy.ImageSequenceClip(images, fps=(20 * speedup)) if (video_filename[(- 3):] == 'gif'): clip.write_gif(video_filename, fps=(20 * speedup)) else: clip.write_videofile(video_filename, fps=(20 * speedup)) return dict(observations=tensor_utils.stack_tensor_list(observations), actions=tensor_utils.stack_tensor_list(actions), rewards=tensor_utils.stack_tensor_list(rewards), noises=tensor_utils.stack_tensor_list(noises), task_idxs=tensor_utils.stack_tensor_list(task_idxs), env_infos=tensor_utils.stack_tensor_dict_list(env_infos))
def rollout_prior_discrete(env, agent, max_path_length=np.inf, task_idx=0, noise=None, animated=False, speedup=1, save_video=True, video_filename='sim_out.mp4', reset_arg=None): observations = [] actions = [] rewards = [] agent_infos = [] env_infos = [] images = [] noises = [] task_idxs = [] o = env.reset(reset_args=reset_arg) agent.reset() path_length = 0 if animated: env.render() if (noise is None): noise = np.random.normal(0, 1, size=(agent.latent_dim,)) sess = tf.get_default_session() while (path_length < max_path_length): prob = sess.run(agent._l_prob, feed_dict={agent._l_obs: [env.observation_space.flatten(o)], agent.zs: [noise]})[0] a = agent.action_space.weighted_sample(prob) (next_o, r, d, env_info) = env.step(a) observations.append(env.observation_space.flatten(o)) rewards.append(r) actions.append(env.action_space.flatten(a)) env_infos.append(env_info) noises.append(noise) task_idxs.append(task_idx) path_length += 1 if d: break o = next_o if animated: env.render() timestep = 0.05 time.sleep((timestep / speedup)) if save_video: from PIL import Image image = env.wrapped_env.wrapped_env.get_viewer().get_image() pil_image = Image.frombytes('RGB', (image[1], image[2]), image[0]) images.append(np.flipud(np.array(pil_image))) if animated: if (save_video and (len(images) >= max_path_length)): import moviepy.editor as mpy clip = mpy.ImageSequenceClip(images, fps=(20 * speedup)) if (video_filename[(- 3):] == 'gif'): clip.write_gif(video_filename, fps=(20 * speedup)) else: clip.write_videofile(video_filename, fps=(20 * speedup)) return dict(observations=tensor_utils.stack_tensor_list(observations), actions=tensor_utils.stack_tensor_list(actions), rewards=tensor_utils.stack_tensor_list(rewards), noises=tensor_utils.stack_tensor_list(noises), task_idxs=tensor_utils.stack_tensor_list(task_idxs), env_infos=tensor_utils.stack_tensor_dict_list(env_infos))
class Space(object): '\n Provides a classification state spaces and action spaces,\n so you can write generic code that applies to any Environment.\n E.g. to choose a random action.\n ' def sample(self, seed=0): '\n Uniformly randomly sample a random elemnt of this space\n ' raise NotImplementedError def contains(self, x): '\n Return boolean specifying if x is a valid\n member of this space\n ' raise NotImplementedError def flatten(self, x): raise NotImplementedError def unflatten(self, x): raise NotImplementedError def flatten_n(self, xs): raise NotImplementedError def unflatten_n(self, xs): raise NotImplementedError @property def flat_dim(self): '\n The dimension of the flattened vector of the tensor representation\n ' raise NotImplementedError def new_tensor_variable(self, name, extra_dims): '\n Create a Theano tensor variable given the name and extra dimensions prepended\n :param name: name of the variable\n :param extra_dims: extra dimensions in the front\n :return: the created tensor variable\n ' raise NotImplementedError