Beispiel #1
0
    def _addHandle(self,
                   jointName,
                   componentIndex,
                   handleInfo=None,
                   type='circular',
                   reverseOppositeJoint=False,
                   minValue=-10000,
                   maxValue=10000):
        """
        Adds a handle to the model.
        handleInfo can be the name of an joint where the handle should be located
        
        """
        oppositeJointName = jointName.replace("STANCE_", "TEMP_").replace(
            "SWING_", "STANCE_").replace("TEMP_", "SWING_")
        try:
            handleJointName = handleInfo.replace("STANCE_",
                                                 "l").replace("SWING_", "r")
            posInChild = self._character.getJointByName(
                handleJointName).getParentJointPosition()
        except AttributeError:
            posInChild = Point3d(0, 0, 0)

        handle = Handle(self._controller, jointName, componentIndex, type,
                        posInChild, oppositeJointName, reverseOppositeJoint,
                        minValue, maxValue)
        self._handles.append(handle)
        return handle
Beispiel #2
0
 def __init__(self, loop, socket, peeraddr):
     self.loop_ = loop
     self.socket_ = Socket(socket)
     self.peeraddr_ = peeraddr
     self.events_ = Events(self.socket_.getSocketFd(), kEevntRead)
     self.handle_ = Handle(self.events_)
     self.recvBuffer_ = ''
     self.writeBuffer_ = ''
     self.messageCb_ = defMessageCallback
Beispiel #3
0
 def __init__(self, loop):
     self.loop_ = loop
     self.serversd_ = Socket()
     self.serversd_.bind()
     self.serversd_.listen(100)
     self.conns_ = {}
     self.events_ = Events(self.serversd_.getSocketFd(), kEevntRead)
     self.handle_ = Handle(self.events_, self.serverReadCb)
     self.loop_.addHandle(self.handle_)
     self.messageCb_ = defMessageCallback
Beispiel #4
0
        self.optimizer.zero_grad()
        loss.backward()
        self.optimizer.step()

    def save(self):
        torch.save(self.target_net, './model/model_gpu.check')

    def load(self):
        self.eval_net = torch.load('./model/model_gpu.check')
        self.target_net = torch.load('./model/model_gpu.check')
        print('load model succes...')


dqn = DeepQN()
Op = Handle()

print('\n collecting experience...')

if os.path.exists('./model/model_gpu.check'):
    dqn.load()

total_step = 0
for i_episode in range(1000):
    Op.getstate()
    while True:

        action = dqn.choose_action(Op.state)
        # 执行行为
        state_next, reward, terminal = Op.action(action)
    def _create(self):
        """Creates the basic model class for the simple keyframe editor. Characters are always forced to left stance."""        

        
        app = wx.GetApp()
        
        try: 
            self._controller = app.getController(0)
        except IndexError:
            return
        self._character = self._controller.getCharacter()

        handlesSide = []
        handlesFront = []
        
        self._handles = []
        handlesSide.append( self._addHandle( 'SWING_Shoulder', 2, 'SWING_Elbow', minValue = -3.14, maxValue = 3.14 ) )
        handlesSide.append( self._addHandle( 'STANCE_Shoulder', 2, 'STANCE_Elbow', minValue = -3.14, maxValue = 3.14 ) )
        handlesSide.append( self._addHandle( 'SWING_Elbow', 0, reverseOppositeJoint = True, minValue = -2.8, maxValue = 0 ) )
        handlesSide.append( self._addHandle( 'STANCE_Elbow', 0, type = 'reverseCircular', reverseOppositeJoint = True,minValue = 0, maxValue = 2.8 ) )
        handlesSide.append( self._addHandle( 'SWING_Ankle', 0, 'SWING_ToeJoint' ) )
        handlesSide.append( self._addHandle( 'STANCE_Ankle', 0, 'STANCE_ToeJoint' ) )
        handlesSide.append( self._addHandle( 'pelvis_lowerback', 2, 'lowerback_torso', minValue = -1.2, maxValue = 1.2  ) )
        handlesSide.append( self._addHandle( 'lowerback_torso', 2, 'torso_head', minValue = -1.2, maxValue = 1.2  ) )
        handlesSide.append( self._addHandle( 'torso_head', 2, minValue = -1.2, maxValue = 1.2  ) )

        handlesFront.append( self._addHandle( 'SWING_Shoulder', 1, 'SWING_Elbow', type = 'reverseCircular', reverseOppositeJoint = True, minValue = -2, maxValue = 2  ) )
        handlesFront.append( self._addHandle( 'STANCE_Shoulder', 1, 'STANCE_Elbow', type = 'reverseCircular', reverseOppositeJoint = True, minValue = -2, maxValue = 2  ) )
        handlesFront.append( self._addHandle( 'SWING_Shoulder', 0, type = 'reversePerpendicular', minValue = -3.3, maxValue = 3.3 ) )
        handlesFront.append( self._addHandle( 'STANCE_Shoulder', 0, type = 'perpendicular', minValue = -3.3, maxValue = 3.3 ) )
        handlesFront.append( self._addHandle( 'pelvis_lowerback', 1, 'lowerback_torso', reverseOppositeJoint = True, minValue = -1.2, maxValue = 1.2  ) )
        handlesFront.append( self._addHandle( 'lowerback_torso', 1, 'torso_head', reverseOppositeJoint = True, minValue = -1.2, maxValue = 1.2  ) )
        handlesFront.append( self._addHandle( 'torso_head', 1, reverseOppositeJoint = True, minValue = -1.2, maxValue = 1.2  ) )


        stanceKneeHandle = Handle( self._controller, 'STANCE_Knee', 0, minValue = 0.1, maxValue = 2.2  )
        self._handles.append( stanceKneeHandle )
        
        swingFootHandleSagittal = BaseHandle( self._controller.getSwingFootTrajectoryDeltaSagittal() )
        swingFootHandleCoronal = BaseHandle( self._controller.getSwingFootTrajectoryDeltaCoronal() )
        swingFootHandleHeight = BaseHandle( self._controller.getSwingFootTrajectoryDeltaHeight() )
        self._handles.append( swingFootHandleSagittal )
        self._handles.append( swingFootHandleCoronal )
        self._handles.append( swingFootHandleHeight )


        self._editors = []
        
        self._times = [ i / float(self._nbEditors-1) for i in range(self._nbEditors) ]

        for handle in self._handles:
            handle.forceKeyframesAt([0,1],self._times)

        for handle in self._handles:
            handle.enforceSymmetry()

        stanceFootToSwingFootTrajectory = Trajectory3dv()
        stanceFootToSwingFootTrajectory.addKnot(0,Vector3d(-0.2,0,-0.4))
        stanceFootToSwingFootTrajectory.addKnot(0.5,Vector3d(-0.2,0.125,0))
        stanceFootToSwingFootTrajectory.addKnot(1,Vector3d(-0.2,0,0.4))

        glCanvasSize = wx.GetApp().getGLCanvas().GetSize()
        minWidth = glCanvasSize.x / self._nbEditors - 50
        minHeight = glCanvasSize.y / 2

        for i, time in enumerate(self._times) :
            posableCharacter = PosableCharacter(PyUtils.copy(self._character), self._controller)
            if i == 0 or i == self._nbEditors-1:
                checkBoxVisible = False
            else :
                checkBoxVisible = True
            editor = EditorWindow( self._container, 
                                   posableCharacter = posableCharacter, 
                                   handlesSide = handlesSide, 
                                   handlesFront = handlesFront,
                                   stanceKneeHandle = stanceKneeHandle, 
                                   swingFootHandleSagittal = swingFootHandleSagittal, 
                                   swingFootHandleCoronal = swingFootHandleCoronal, 
                                   swingFootHandleHeight = swingFootHandleHeight, 
                                   time = time, 
                                   controller = self._controller, 
                                   stanceFootToSwingFootTrajectory = stanceFootToSwingFootTrajectory, 
                                   minWidth = minWidth, minHeight = minHeight, 
                                   checkBoxVisible = checkBoxVisible )
            functor = SetKeyframeVisibilityFunctor(self,i)            
            editor.addCheckBoxCallback( functor.execute )
            self._sizer.add(editor, 0, GLUtils.GLUI_EXPAND )
            self._editors.append(editor)

        self._container.getParent().layout()            
Beispiel #6
0
	def process(self, command):
		# TODO:
		#	- check/feedback behaviour for multi handles or matches
		#	- database support for remembering/tracking/learning choices
		handle_results = Handle.processHandles(self.handles, command)
		return self.executeCommand(handle_results)
Beispiel #7
0
	def __init__(self):
		# JSON stored command handles
		self.handles = Handle.load(Handle.HANDLES_FILENAME)
Beispiel #8
0
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
'''
File: myprecious.py
Author: Vanildo Souto Mangueira <*****@*****.**>
Description: Arquivo Principal
'''
import sys

from Handle import Handle
from Bootstrap import Bootstrap

boot = Bootstrap()
handle = Handle()

if (len(sys.argv) > 1):
    if sys.argv[1] == '-i' or sys.argv[1] == '--interactive':
        handle.interactive()
    handle.keyHandle(sys.argv[1])
else:
    handle.interactive()