本文整理汇总了Python中director.consoleapp.ConsoleApp类的典型用法代码示例。如果您正苦于以下问题:Python ConsoleApp类的具体用法?Python ConsoleApp怎么用?Python ConsoleApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsoleApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
app = ConsoleApp()
camVis = CameraVisualizer()
camVis.createUI()
camVis.showUI()
app.start()
示例2: main
def main():
app = ConsoleApp()
view = app.createView(useGrid=False)
imageManager = cameraview.ImageManager()
cameraView = cameraview.CameraView(imageManager, view)
view.show()
app.start()
示例3: __init__
def __init__(
self,
percentObsDensity=20,
endTime=40,
nonRandomWorld=False,
circleRadius=0.7,
worldScale=1.0,
autoInitialize=True,
verbose=True,
):
self.verbose = verbose
self.startSimTime = time.time()
self.collisionThreshold = 0.4
self.randomSeed = 5
self.Sensor_rayLength = 8
self.percentObsDensity = percentObsDensity
self.defaultControllerTime = 1000
self.nonRandomWorld = nonRandomWorld
self.circleRadius = circleRadius
self.worldScale = worldScale
# create the visualizer object
self.app = ConsoleApp()
self.view = self.app.createView(useGrid=False)
self.initializeOptions()
self.initializeColorMap()
if autoInitialize:
self.initialize()
self.XVelocity_drawing = 0.0
self.YVelocity_drawing = 0.0
示例4: __init__
def __init__(self):
self.app = ConsoleApp()
self.view = self.app.createView()
self.robotSystem = robotsystem.create(self.view)
self.config = drcargs.getDirectorConfig()
jointGroups = self.config['teleopJointGroups']
self.jointTeleopPanel = JointTeleopPanel(self.robotSystem, jointGroups)
self.jointCommandPanel = JointCommandPanel(self.robotSystem)
self.jointCommandPanel.ui.speedSpinBox.setEnabled(False)
self.jointCommandPanel.ui.mirrorArmsCheck.setChecked(self.jointTeleopPanel.mirrorArms)
self.jointCommandPanel.ui.mirrorLegsCheck.setChecked(self.jointTeleopPanel.mirrorLegs)
self.jointCommandPanel.ui.resetButton.connect('clicked()', self.resetJointTeleopSliders)
self.jointCommandPanel.ui.mirrorArmsCheck.connect('clicked()', self.mirrorJointsChanged)
self.jointCommandPanel.ui.mirrorLegsCheck.connect('clicked()', self.mirrorJointsChanged)
self.widget = QtGui.QWidget()
gl = QtGui.QGridLayout(self.widget)
gl.addWidget(self.app.showObjectModel(), 0, 0, 4, 1) # row, col, rowspan, colspan
gl.addWidget(self.view, 0, 1, 1, 1)
gl.addWidget(self.jointCommandPanel.widget, 1, 1, 1, 1)
gl.addWidget(self.jointTeleopPanel.widget, 0, 2, -1, 1)
gl.setRowStretch(0,1)
gl.setColumnStretch(1,1)
#self.sub = lcmUtils.addSubscriber('COMMITTED_ROBOT_PLAN', lcmdrc.robot_plan_t, self.onRobotPlan)
lcmUtils.addSubscriber('STEERING_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
lcmUtils.addSubscriber('THROTTLE_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
示例5: robotMain
def robotMain(useDrivingGains=False, useController=False):
print 'waiting for robot state...'
commandStream.waitForRobotState()
print 'starting.'
commandStream.timer.targetFps = 1000
if useController==True:
commandStream.useController()
else:
commandStream.publishChannel = 'ROBOT_COMMAND'
if useDrivingGains:
commandStream.applyDrivingDefaults()
commandStream.startStreaming()
positionListener = PositionGoalListener()
planListener = CommittedRobotPlanListener()
ConsoleApp.start()
示例6: main
def main():
app = ConsoleApp()
view = app.createView(useGrid=False)
view.orientationMarkerWidget().Off()
view.backgroundRenderer().SetBackground([0,0,0])
view.backgroundRenderer().SetBackground2([0,0,0])
cameraChannel = parseChannelArgument()
imageManager = cameraview.ImageManager()
imageManager.queue.addCameraStream(cameraChannel)
imageManager.addImage(cameraChannel)
cameraView = cameraview.CameraImageView(imageManager, cameraChannel, view=view)
cameraView.eventFilterEnabled = False
view.renderWindow().GetInteractor().SetInteractorStyle(vtk.vtkInteractorStyleImage())
view.show()
app.start()
示例7: DebugAtlasCommandListener
class DebugAtlasCommandListener(object):
def __init__(self):
self.app = ConsoleApp()
self.view = self.app.createView()
self.robotModel, self.jointController = roboturdf.loadRobotModel('robot model', self.view)
self.jointController.setZeroPose()
self.view.show()
self.sub = lcmUtils.addSubscriber('ATLAS_COMMAND', lcmbotcore.atlas_command_t, self.onAtlasCommand)
self.sub.setSpeedLimit(60)
def onAtlasCommand(self, msg):
pose = atlasCommandToDrakePose(msg)
self.jointController.setPose('ATLAS_COMMAND', pose)
示例8: PositionGoalListener
class PositionGoalListener(object):
def __init__(self):
self.sub = lcmUtils.addSubscriber('JOINT_POSITION_GOAL', lcmbotcore.robot_state_t, self.onJointPositionGoal)
self.sub = lcmUtils.addSubscriber('SINGLE_JOINT_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
lcmUtils.addSubscriber('COMMITTED_PLAN_PAUSE', lcmdrc.plan_control_t, self.onPause)
self.debug = False
if self.debug:
self.app = ConsoleApp()
self.view = self.app.createView()
self.robotModel, self.jointController = roboturdf.loadRobotModel('robot model', self.view)
self.jointController.setPose('ATLAS_COMMAND', commandStream._currentCommandedPose)
self.view.show()
self.timer = TimerCallback(targetFps=30)
self.timer.callback = self.onDebug
def onPause(self, msg):
commandStream.stopStreaming()
def onJointPositionGoal(self, msg):
#lcmUtils.publish('ATLAS_COMMAND', msg)
commandStream.startStreaming()
pose = robotstate.convertStateMessageToDrakePose(msg)
self.setGoalPose(pose)
def setGoalPose(self, pose):
commandStream.setGoalPose(pose)
def onDebug(self):
self.jointController.setPose('ATLAS_COMMAND', commandStream._currentCommandedPose)
def onSingleJointPositionGoal(self, msg):
jointPositionGoal = msg.joint_position
jointName = msg.joint_name
allowedJointNames = ['l_leg_aky','l_arm_lwy']
if not (jointName in allowedJointNames):
print 'Position goals are not allowed for this joint'
print 'ignoring this position goal'
print 'use the sliders instead'
return
commandStream.setIndividualJointGoalPose(jointPositionGoal, jointName)
示例9: __init__
def __init__(self, world):
"""Constructs the simulator.
Args:
world: World.
"""
self._robots = []
self._obstacles = []
self._world = world
self._app = ConsoleApp()
self._view = self._app.createView(useGrid=False)
# performance tracker
self._num_targets = 0
self._num_crashes = 0
self._run_ticks = 0
self._initialize()
示例10: ConsoleApp
from director.consoleapp import ConsoleApp
from director import robotsystem
app = ConsoleApp()
app.setupGlobals(globals())
if app.getTestingInteractiveEnabled():
app.showPythonConsole()
view = app.createView()
view.show()
robotsystem.create(view, globals())
app.start()
示例11: Simulator
class Simulator(object):
def __init__(
self,
percentObsDensity=20,
endTime=40,
nonRandomWorld=False,
circleRadius=0.7,
worldScale=1.0,
autoInitialize=True,
verbose=True,
):
self.verbose = verbose
self.startSimTime = time.time()
self.collisionThreshold = 0.4
self.randomSeed = 5
self.Sensor_rayLength = 8
self.percentObsDensity = percentObsDensity
self.defaultControllerTime = 1000
self.nonRandomWorld = nonRandomWorld
self.circleRadius = circleRadius
self.worldScale = worldScale
# create the visualizer object
self.app = ConsoleApp()
self.view = self.app.createView(useGrid=False)
self.initializeOptions()
self.initializeColorMap()
if autoInitialize:
self.initialize()
self.XVelocity_drawing = 0.0
self.YVelocity_drawing = 0.0
def initializeOptions(self):
self.options = dict()
self.options["World"] = dict()
self.options["World"]["obstaclesInnerFraction"] = 0.98
self.options["World"]["randomSeed"] = 40
self.options["World"]["percentObsDensity"] = 0.0
self.options["World"]["nonRandomWorld"] = True
self.options["World"]["circleRadius"] = 1.0
self.options["World"]["scale"] = 1
self.options["Sensor"] = dict()
self.options["Sensor"]["rayLength"] = 10
self.options["Sensor"]["numRays"] = 50
self.options["Car"] = dict()
self.options["Car"]["velocity"] = 4.0
self.options["dt"] = 0.05
self.options["runTime"] = dict()
self.options["runTime"]["defaultControllerTime"] = 100
def setDefaultOptions(self):
defaultOptions = dict()
defaultOptions["World"] = dict()
defaultOptions["World"]["obstaclesInnerFraction"] = 0.98
defaultOptions["World"]["randomSeed"] = 40
defaultOptions["World"]["percentObsDensity"] = 30
defaultOptions["World"]["nonRandomWorld"] = True
defaultOptions["World"]["circleRadius"] = 1.75
defaultOptions["World"]["scale"] = 2.5
defaultOptions["Sensor"] = dict()
defaultOptions["Sensor"]["rayLength"] = 10
defaultOptions["Sensor"]["numRays"] = 51
defaultOptions["Car"] = dict()
defaultOptions["Car"]["velocity"] = 20
defaultOptions["dt"] = 0.05
defaultOptions["runTime"] = dict()
defaultOptions["runTime"]["defaultControllerTime"] = 100
for k in defaultOptions:
self.options.setdefault(k, defaultOptions[k])
for k in defaultOptions:
if not isinstance(defaultOptions[k], dict):
continue
for j in defaultOptions[k]:
self.options[k].setdefault(j, defaultOptions[k][j])
def initializeColorMap(self):
self.colorMap = dict()
self.colorMap["default"] = [0, 1, 0]
def initialize(self):
self.dt = self.options["dt"]
#.........这里部分代码省略.........
示例12: onMousePress
d.addSphere(pickedPoint, radius=0.01)
d.addLine(pickedPoint, np.array(pickedPoint) + 0.1 * np.array(normal), radius=0.005)
obj = vis.updatePolyData(d.getPolyData(), 'link selection', color=[0,1,0])
obj.actor.SetPickable(False)
self.linkName = linkName
self.pickedPoint = pickedPoint
def onMousePress(self, displayPoint, modifiers=None):
print self.linkName, self.pickedPoint
###########################
app = ConsoleApp()
app.setupGlobals(globals())
view = app.createView()
view.show()
view.resize(1080, 768)
robotModel, jointController = roboturdf.loadRobotModel('robot model', view, parent='scene', color=roboturdf.getRobotGrayColor(), visible=True)
robotModel.addToView(view)
widget = LinkWidget(view, robotModel)
widget.start()
app.viewOptions.setProperty('Gradient background', False)
app.viewOptions.setProperty('Background color', [1,1,1])
app.viewOptions.setProperty('Orientation widget', False)
示例13: ConsoleApp
timeNow = time.time()
elapsed = timeNow - startTime
if elapsed > 1.0:
view.forceRender()
print '%d samples/sec' % (sampleCount / elapsed), '%d total samples' % totalSampleCount
startTime = timeNow
sampleCount = 0
if app.getTestingEnabled():
assert badSampleCount == 0
app.quit()
app = ConsoleApp()
app.setupGlobals(globals())
view = app.createView()
view.show()
robotSystem = robotsystem.create(view, planningOnly=True)
view.resetCamera()
if robotSystem.ikPlanner.planningMode == 'pydrake':
robotSystem.ikPlanner.plannerPub._setupLocalServer()
runTest()
elif robotSystem.ikPlanner.planningMode == 'matlabdrake':
robotSystem.ikServer.connectStartupCompleted(onMatlabStartup)
robotSystem.startIkServer()
示例14: ConsoleApp
from director.consoleapp import ConsoleApp
app = ConsoleApp()
view = app.createView()
view.showMaximized()
app.start()
示例15: AtlasCommandPanel
class AtlasCommandPanel(object):
def __init__(self):
self.app = ConsoleApp()
self.view = self.app.createView()
self.robotSystem = robotsystem.create(self.view)
self.config = drcargs.getDirectorConfig()
jointGroups = self.config['teleopJointGroups']
self.jointTeleopPanel = JointTeleopPanel(self.robotSystem, jointGroups)
self.jointCommandPanel = JointCommandPanel(self.robotSystem)
self.jointCommandPanel.ui.speedSpinBox.setEnabled(False)
self.jointCommandPanel.ui.mirrorArmsCheck.setChecked(self.jointTeleopPanel.mirrorArms)
self.jointCommandPanel.ui.mirrorLegsCheck.setChecked(self.jointTeleopPanel.mirrorLegs)
self.jointCommandPanel.ui.resetButton.connect('clicked()', self.resetJointTeleopSliders)
self.jointCommandPanel.ui.mirrorArmsCheck.connect('clicked()', self.mirrorJointsChanged)
self.jointCommandPanel.ui.mirrorLegsCheck.connect('clicked()', self.mirrorJointsChanged)
self.widget = QtGui.QWidget()
gl = QtGui.QGridLayout(self.widget)
gl.addWidget(self.app.showObjectModel(), 0, 0, 4, 1) # row, col, rowspan, colspan
gl.addWidget(self.view, 0, 1, 1, 1)
gl.addWidget(self.jointCommandPanel.widget, 1, 1, 1, 1)
gl.addWidget(self.jointTeleopPanel.widget, 0, 2, -1, 1)
gl.setRowStretch(0,1)
gl.setColumnStretch(1,1)
#self.sub = lcmUtils.addSubscriber('COMMITTED_ROBOT_PLAN', lcmdrc.robot_plan_t, self.onRobotPlan)
lcmUtils.addSubscriber('STEERING_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
lcmUtils.addSubscriber('THROTTLE_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
def onSingleJointPositionGoal(self, msg):
jointPositionGoal = msg.joint_position
jointName = msg.joint_name
allowedJointNames = ['l_leg_aky','l_arm_lwy']
if not (jointName in allowedJointNames):
print 'Position goals are not allowed for this joint'
print 'ignoring this position goal'
print 'use the sliders instead'
return
if (jointName == 'l_arm_lwy') and (not self.jointCommandPanel.steeringControlEnabled):
print 'Steering control not enabled'
print 'ignoring steering command'
return
if (jointName == 'l_leg_aky') and (not self.jointCommandPanel.throttleControlEnabled):
print 'Throttle control not enabled'
print 'ignoring throttle command'
return
jointIdx = self.jointTeleopPanel.toJointIndex(joint_name)
self.jointTeleopPanel.endPose[jointIdx] = jointPositionGoal
self.jointTeleopPanel.updateSliders()
self.jointTeleopPanel.sliderChanged(jointName)
def onRobotPlan(self, msg):
playback = planplayback.PlanPlayback()
playback.interpolationMethod = 'pchip'
poseTimes, poses = playback.getPlanPoses(msg)
f = playback.getPoseInterpolator(poseTimes, poses)
jointController = self.robotSystem.teleopJointController
timer = simpletimer.SimpleTimer()
def setPose(pose):
jointController.setPose('plan_playback', pose)
self.jointTeleopPanel.endPose = pose
self.jointTeleopPanel.updateSliders()
commandStream.setGoalPose(pose)
def updateAnimation():
tNow = timer.elapsed()
if tNow > poseTimes[-1]:
pose = poses[-1]
setPose(pose)
return False
pose = f(tNow)
setPose(pose)
self.animationTimer = TimerCallback()
self.animationTimer.targetFps = 60
self.animationTimer.callback = updateAnimation
self.animationTimer.start()
def mirrorJointsChanged(self):
self.jointTeleopPanel.mirrorLegs = self.jointCommandPanel.ui.mirrorLegsCheck.checked
#.........这里部分代码省略.........