-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain_sphere.py
More file actions
52 lines (34 loc) · 1.53 KB
/
main_sphere.py
File metadata and controls
52 lines (34 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import sys
import argparse
import numpy as np
# To Add Local Files, adding the directory via sys module
# __file__ saves the current directory of this file.
sys.path.append( os.path.join( os.path.dirname(__file__), "modules" ) )
from simulation import Simulation
from controllers import SphereController, SphereControllerAdvanced
from constants import my_parser
from constants import Constants as C
from utils import rotx, roty, rotz
# Setting the numpy print options, useful for printing out data with consistent pattern.
np.set_printoptions( linewidth = np.nan, suppress = True, precision = 4 )
# Generate the parser, which is defined in utils.py
parser = my_parser( )
args, unknown = parser.parse_known_args( )
if __name__ == "__main__":
args.model_name = "simple_sphere"
# Generate an instance of our Simulation
my_sim = Simulation( args )
# For simple sphere controller
# ctrl = SphereController( my_sim, args, "example_sphere" )
# For advanced sphere controller
ctrl = SphereControllerAdvanced( my_sim, args, "advanced_sphere" )
# Define the parameters of the sphere controller.
my_sim.init( qpos = [ -.5, .7, 1.3 ], qvel = np.zeros( 3 ))
# my_sim.init( qpos = [ .5, .0, .0 ], qvel = np.zeros( 3 ))
# Rdes = np.eye( 3 )
Rdes = rotx( 1. ) @ roty( 0.4 ) @ rotz( -1. )
ctrl.set_desired_orientation( Rdes )
my_sim.add_ctrl( ctrl )
my_sim.run( )
my_sim.close( )