<commit_before>import os
import sys
import vtkAll as vtk
from ddapp import botpy
import math
import time
import types
import functools
import random
import numpy as np

from ddapp import transformUtils
from ddapp import lcmUtils
from ddapp.timercallback import TimerCallback
from ddapp import objectmodel as om
from ddapp import visualization as vis
from ddapp import applogic as app
from ddapp.debugVis import DebugData
from ddapp import ioUtils
from ddapp.simpletimer import SimpleTimer
from ddapp.utime import getUtime
from ddapp import robotstate
from ddapp import planplayback
from ddapp import segmentation
from ddapp import drcargs

from ddapp import ik
from ddapp.ikparameters import IkParameters
from ddapp import ikconstraintencoder

import drc as lcmdrc
import json

import PythonQt
from PythonQt import QtCore, QtGui

copyFrame = transformUtils.copyFrame

def getIkOptions():
    return om.findObjectByName('IK Planner Options').properties


class ConstraintSet(object):

    def __init__(self, ikPlanner, constraints, endPoseName, startPoseName):
        self.ikPlanner = ikPlanner
        self.ikParameters = IkParameters()
        self.constraints = constraints
        self.endPoseName = endPoseName
        self.startPoseName = startPoseName
        self.endPose = None
        self.seedPoseName = None
        self.nominalPoseName = None

    def runIk(self):
        seedPoseName = self.seedPoseName
        if not seedPoseName:
            seedPoseName = getIkOptions().getPropertyEnumValue('Seed pose')
        if seedPoseName == 'q_start':
            seedPoseName = self.startPoseName

        nominalPoseName = self.nominalPoseName
        if not nominalPoseName:
            nominalPoseName = getIkOptions().getPropertyEnumValue('Nominal pose')
        if nominalPoseName == 'q_start':
            nominalPoseName = self.startPoseName

        if (self.ikPlanner.pushToMatlab is False):
            self.endPose, self.info = self.ikPlanner.plannerPub.processIK(self.constraints, nominalPoseName=nominalPoseName, seedPoseName=seedPoseName)
            return self.endPose, self.info
        else:
            ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)

            self.endPose, self.info = self.ikPlanner.ikServer.runIk(self.constraints, ikParameters, nominalPostureName=nominalPoseName, seedPostureName=seedPoseName)
            print 'info:', self.info
            return self.endPose, self.info

    def runIkTraj(self):
        assert self.endPose is not None
        self.ikPlanner.addPose(self.endPose, self.endPoseName)

        nominalPoseName = self.nominalPoseName
        if not nominalPoseName:
            nominalPoseName = getIkOptions().getPropertyEnumValue('Nominal pose')
        if nominalPoseName == 'q_start':
            nominalPoseName = self.startPoseName

        if (self.ikPlanner.pushToMatlab is False):
            # TODO: Implement IK Server Request over LCM here
            print "push to lcm runIkTraj"
            self.plan =[]
        else:
            ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)
            self.plan = self.ikPlanner.runIkTraj(self.constraints, self.startPoseName, self.endPoseName, nominalPoseName, ikParameters=ikParameters)

        return self.plan

    def planEndPoseGoal(self, feetOnGround = True):
        assert self.endPose is not None
        self.ikPlanner.addPose(self.endPose, self.endPoseName)
        ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)
        self.plan = self.ikPlanner.computePostureGoal(self.startPoseName, self.endPoseName, feetOnGround, ikParameters=ikParameters)
        return self.plan<commit_msg>leap-forward-fix: fix ConstraintSet.runIkTraj for EXOTica<commit_after>import os
import sys
import vtkAll as vtk
from ddapp import botpy
import math
import time
import types
import functools
import random
import numpy as np

from ddapp import transformUtils
from ddapp import lcmUtils
from ddapp.timercallback import TimerCallback
from ddapp import objectmodel as om
from ddapp import visualization as vis
from ddapp import applogic as app
from ddapp.debugVis import DebugData
from ddapp import ioUtils
from ddapp.simpletimer import SimpleTimer
from ddapp.utime import getUtime
from ddapp import robotstate
from ddapp import planplayback
from ddapp import segmentation
from ddapp import drcargs

from ddapp import ik
from ddapp.ikparameters import IkParameters
from ddapp import ikconstraintencoder

import drc as lcmdrc
import json

import PythonQt
from PythonQt import QtCore, QtGui

copyFrame = transformUtils.copyFrame

def getIkOptions():
    return om.findObjectByName('IK Planner Options').properties


class ConstraintSet(object):

    def __init__(self, ikPlanner, constraints, endPoseName, startPoseName):
        self.ikPlanner = ikPlanner
        self.ikParameters = IkParameters()
        self.constraints = constraints
        self.endPoseName = endPoseName
        self.startPoseName = startPoseName
        self.endPose = None
        self.seedPoseName = None
        self.nominalPoseName = None

    def runIk(self):
        seedPoseName = self.seedPoseName
        if not seedPoseName:
            seedPoseName = getIkOptions().getPropertyEnumValue('Seed pose')
        if seedPoseName == 'q_start':
            seedPoseName = self.startPoseName

        nominalPoseName = self.nominalPoseName
        if not nominalPoseName:
            nominalPoseName = getIkOptions().getPropertyEnumValue('Nominal pose')
        if nominalPoseName == 'q_start':
            nominalPoseName = self.startPoseName

        if (self.ikPlanner.pushToMatlab is False):
            self.endPose, self.info = self.ikPlanner.plannerPub.processIK(self.constraints, nominalPoseName=nominalPoseName, seedPoseName=seedPoseName)
            return self.endPose, self.info
        else:
            ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)

            self.endPose, self.info = self.ikPlanner.ikServer.runIk(self.constraints, ikParameters, nominalPostureName=nominalPoseName, seedPostureName=seedPoseName)
            print 'info:', self.info
            return self.endPose, self.info

    def runIkTraj(self):
        assert self.endPose is not None
        self.ikPlanner.addPose(self.endPose, self.endPoseName)

        nominalPoseName = self.nominalPoseName
        if not nominalPoseName:
            nominalPoseName = getIkOptions().getPropertyEnumValue('Nominal pose')
        if nominalPoseName == 'q_start':
            nominalPoseName = self.startPoseName

        ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)
        self.plan = self.ikPlanner.runIkTraj(self.constraints, self.startPoseName, self.endPoseName, nominalPoseName, ikParameters=ikParameters)

        return self.plan

    def planEndPoseGoal(self, feetOnGround = True):
        assert self.endPose is not None
        self.ikPlanner.addPose(self.endPose, self.endPoseName)
        ikParameters = self.ikPlanner.mergeWithDefaultIkParameters(self.ikParameters)
        self.plan = self.ikPlanner.computePostureGoal(self.startPoseName, self.endPoseName, feetOnGround, ikParameters=ikParameters)
        return self.plan
{'fraction_non_alphanumeric': 0.06333471017485888, 'fraction_numerical': 0.0, 'mean_word_length': 3.450980392156863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4713503', 'n_tokens_mistral': 2225, 'n_tokens_neox': 2121, 'n_words': 526}