r_hip_shape = Sphere(color='black', radius = 0.1) r_ankle_shape = Sphere(color='black', radius = 0.1) l_ankle_viz_frame = VisualizationFrame(inertial_frame, l_ankle, l_ankle_shape) l_hip_viz_frame = VisualizationFrame(inertial_frame, l_hip, l_hip_shape) r_hip_viz_frame = VisualizationFrame(inertial_frame, r_hip, r_hip_shape) r_ankle_viz_frame = VisualizationFrame(inertial_frame, r_leg_mass_center, r_ankle_shape) constants_dict = dict(zip(constants, numerical_constants)) l_leg_shape = Cylinder(radius = 0.08, length = constants_dict[l_leg_length], color = 'blue') l_leg_viz_frame = VisualizationFrame('Left Leg', l_leg_frame, l_leg_mass_center, l_leg_shape) body_shape = Cylinder(radius = 0.08, length = constants_dict[hip_width], color = 'blue') body_viz_frame = VisualizationFrame('Body', body_frame, body_mass_center, body_shape) r_leg_shape = Cylinder(radius = 0.08, length = constants_dict[l_leg_length], color = 'red') r_leg_viz_frame = VisualizationFrame('Right Leg', r_leg_frame, r_leg_mass_center, r_leg_shape) scene = Scene(inertial_frame, l_ankle) scene.visualization_frames = [l_ankle_viz_frame,l_hip_viz_frame, r_hip_viz_frame, r_ankle_viz_frame, l_leg_viz_frame, body_viz_frame, r_leg_viz_frame] scene.generate_visualization_json(coordinates + speeds, constants, y, numerical_constants) scene.display()
for i, (link, particle) in enumerate(zip(links, particles)): link_shape = Cylinder(name='cylinder{}'.format(i), radius=link_radius, length=link_length, color='red') viz_frames.append(VisualizationFrame('link_frame{}'.format(i), link, link_shape)) particle_shape = Sphere(name='sphere{}'.format(i), radius=particle_radius, color='blue') viz_frames.append(VisualizationFrame('particle_frame{}'.format(i), link.frame, particle, particle_shape)) # Now the visualization frames can be passed in to create a scene. scene = Scene(I, O, *viz_frames) # And the motion of the shapes is generated by providing the scene with the # state trajectories. print('Generating transform time histories.') scene.generate_visualization_json(kane._q + kane._u, param_syms, state_trajectories, param_vals) print('Done.') scene.display()
viz_frames = [] for i, (link, particle) in enumerate(zip(links, particles)): link_shape = Cylinder(name='cylinder{}'.format(i), radius=link_radius, length=link_length, color='red') viz_frames.append( VisualizationFrame('link_frame{}'.format(i), link, link_shape)) particle_shape = Sphere(name='sphere{}'.format(i), radius=particle_radius, color='blue') viz_frames.append( VisualizationFrame('particle_frame{}'.format(i), link.frame, particle, particle_shape)) # Now the visualization frames can be passed in to create a scene. scene = Scene(I, O, *viz_frames) # And the motion of the shapes is generated by providing the scene with the # state trajectories. print('Generating transform time histories.') scene.generate_visualization_json(kane._q + kane._u, param_syms, state_trajectories, param_vals) print('Done.') scene.display()
linkP_origin = O.locatenew('originP', 0.5 * l * A.x) linkP_viz_frame = VisualizationFrame('linkP', linkP_frame, linkP_origin, link) linkR_frame = B.orientnew('frameR', 'Axis', [0.5 * pi, N.z]) linkR_origin = P.locatenew('originP', 0.5 * l * B.x) linkR_viz_frame = VisualizationFrame('linkR', linkR_frame, linkR_origin, link) sphereP_viz_frame = VisualizationFrame('sphereP', N, P, sphere) sphereR_viz_frame = VisualizationFrame('sphereR', N, R, sphere) # Construct the scene # =================== # We want gravity to be directed downwards in the visualization. Gravity is in # the -x direction. By default, the visualization uses the xz plane as the # ground plane. Thus, gravity is contained in the ground plane. However, we # want gravity to point in the -y direction in the visualization. To achieve # this, we create a world frame that is rotated +90 degrees about the N frame's # z direction. world_frame = N.orientnew('world', 'Axis', [0.5 * pi, N.z]) scene = Scene(world_frame, O, linkP_viz_frame, linkR_viz_frame, sphereP_viz_frame, sphereR_viz_frame) # Create the visualization # ======================== scene.generate_visualization_json(coordinates + speeds, constants.keys(), x, constants.values()) scene.display()
lower_leg_center.set_pos(ankle, lower_leg_length / 2 * lower_leg_frame.y) upper_leg_center.set_pos(knee, upper_leg_length / 2 * upper_leg_frame.y) torso_center.set_pos(hip, torso_com_length * torso_frame.y) lower_leg_shape = Cylinder(radius=0.08, length=constants_dict[lower_leg_length], color='blue') lower_leg_viz_frame = VisualizationFrame('Lower Leg', lower_leg_frame, lower_leg_center, lower_leg_shape) upper_leg_shape = Cylinder(radius=0.08, length=constants_dict[upper_leg_length], color='green') upper_leg_viz_frame = VisualizationFrame('Upper Leg', upper_leg_frame, upper_leg_center, upper_leg_shape) torso_shape = Cylinder(radius=0.08, length=2 * constants_dict[torso_com_length], color='red') torso_viz_frame = VisualizationFrame('Torso', torso_frame, torso_center, torso_shape) scene = Scene(inertial_frame, ankle, ankle_viz_frame, knee_viz_frame, hip_viz_frame, head_viz_frame, lower_leg_viz_frame, upper_leg_viz_frame, torso_viz_frame) scene.generate_visualization_json(coordinates + speeds, constants, y, numerical_constants)