当前位置: 首页>>代码示例>>Python>>正文


Python ConsoleApp.createView方法代码示例

本文整理汇总了Python中director.consoleapp.ConsoleApp.createView方法的典型用法代码示例。如果您正苦于以下问题:Python ConsoleApp.createView方法的具体用法?Python ConsoleApp.createView怎么用?Python ConsoleApp.createView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在director.consoleapp.ConsoleApp的用法示例。


在下文中一共展示了ConsoleApp.createView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
def main():

    app = ConsoleApp()

    view = app.createView(useGrid=False)
    imageManager = cameraview.ImageManager()
    cameraView = cameraview.CameraView(imageManager, view)

    view.show()
    app.start()
开发者ID:RobotLocomotion,项目名称:director,代码行数:12,代码来源:testCameraView.py

示例2: DebugAtlasCommandListener

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
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)
开发者ID:david-german-tri,项目名称:director,代码行数:17,代码来源:testAtlasCommand.py

示例3: PositionGoalListener

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
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)
开发者ID:david-german-tri,项目名称:director,代码行数:49,代码来源:testAtlasCommand.py

示例4: main

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
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()
开发者ID:caomw,项目名称:director,代码行数:25,代码来源:testImageView.py

示例5: Simulator

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
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"]
#.........这里部分代码省略.........
开发者ID:peteflorence,项目名称:DirectSim,代码行数:103,代码来源:CarSimulator.py

示例6: ConsoleApp

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
from director.debugVis import DebugData
from director.timercallback import TimerCallback
from director import segmentation
from director.uuidutil import newUUID
from director import geometryencoder
from director import sceneloader
import drc as lcmdrc
import os
import json
from director.utime import getUtime
app = ConsoleApp()

app.setupGlobals(globals())
app.showPythonConsole()

view = app.createView()
view.show()

robotsystem.create(view, globals())


def affordanceFromDescription(desc):
    affordanceManager.collection.updateDescription(desc)
    return affordanceManager.getAffordanceById(desc['uuid'])

def newBox():
    desc = dict(classname='BoxAffordanceItem', Name='test box', Dimensions=[0.5, 0.2, 0.1], uuid=newUUID(), pose=((0.5,0.0,1.0), (1,0,0,0)))
    return affordanceFromDescription(desc)

def newSphere():
    desc = dict(classname='SphereAffordanceItem', Name='test sphere', Radius=0.2, uuid=newUUID(), pose=((0.5,0.0,1.0), (1,0,0,0)))
开发者ID:caomw,项目名称:director,代码行数:33,代码来源:testAffordanceItems.py

示例7: ConsoleApp

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
from director import jointcontrol
from director import planplayback
from director import playbackpanel
from director import robotplanlistener
from director import robotviewbehaviors
from director import pointcloudlcm
from director import cameraview
from director import lcmUtils
from PythonQt import QtCore, QtGui
import drc as lcmdrc
import bot_core as lcmbotcore


# create the application
app = ConsoleApp()
view = app.createView()

# load robot state model
robotStateModel, robotStateJointController = roboturdf.loadRobotModel('robot model', view, colorMode='Textures')

# listen for robot state updates
robotStateJointController.addLCMUpdater('EST_ROBOT_STATE')

# reload urdf from model publisher lcm
roboturdf.startModelPublisherListener([(robotStateModel, robotStateJointController)])

# load  playback model
playbackRobotModel, playbackJointController = roboturdf.loadRobotModel('playback robot model', view, color=roboturdf.getRobotOrangeColor(), visible=False)

# initialize the playback panel
planPlayback = planplayback.PlanPlayback()
开发者ID:RobotLocomotion,项目名称:director,代码行数:33,代码来源:testDrawRobotLog.py

示例8: AtlasCommandPanel

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
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
#.........这里部分代码省略.........
开发者ID:david-german-tri,项目名称:director,代码行数:103,代码来源:testAtlasCommand.py

示例9: Simulator

# 需要导入模块: from director.consoleapp import ConsoleApp [as 别名]
# 或者: from director.consoleapp.ConsoleApp import createView [as 别名]
class Simulator(object):

    """Simulator."""

    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()

    def _initialize(self):
        """Initializes the world."""
        # Add world to view.
        om.removeFromObjectModel(om.findObjectByName("world"))
        vis.showPolyData(self._world.to_polydata(), "world")

    def _add_polydata(self, polydata, frame_name, color):
        """Adds polydata to the simulation.

        Args:
            polydata: Polydata.
            frame_name: Frame name.
            color: Color of object.

        Returns:
            Frame.
        """
        om.removeFromObjectModel(om.findObjectByName(frame_name))
        frame = vis.showPolyData(polydata, frame_name, color=color)

        vis.addChildFrame(frame)
        return frame

    def add_target(self, target):
        data = DebugData()
        center = [target[0], target[1], 1]
        axis = [0, 0, 1]  # Upright cylinder.
        data.addCylinder(center, axis, 2, 3)
        om.removeFromObjectModel(om.findObjectByName("target"))
        self._add_polydata(data.getPolyData(), "target", [0, 0.8, 0])

    def add_robot(self, robot):
        """Adds a robot to the simulation.

        Args:
            robot: Robot.
        """
        color = [0.4, 0.85098039, 0.9372549]
        frame_name = "robot{}".format(len(self._robots))
        frame = self._add_polydata(robot.to_polydata(), frame_name, color)
        self._robots.append((robot, frame))
        self._update_moving_object(robot, frame)

    def add_obstacle(self, obstacle):
        """Adds an obstacle to the simulation.

        Args:
            obstacle: Obstacle.
        """
        color = [1.0, 1.0, 1.0]
        frame_name = "obstacle{}".format(len(self._obstacles))
        frame = self._add_polydata(obstacle.to_polydata(), frame_name, color)
        self._obstacles.append((obstacle, frame))
        self._update_moving_object(obstacle, frame)

    def _update_moving_object(self, moving_object, frame):
        """Updates moving object's state.

        Args:
            moving_object: Moving object.
            frame: Corresponding frame.
        """
        t = vtk.vtkTransform()
        t.Translate(moving_object.x, moving_object.y, 0.0)
        t.RotateZ(np.degrees(moving_object.theta))
        frame.getChildFrame().copyFrame(t)

    def _update_sensor(self, sensor, frame_name):
        """Updates sensor's rays.

        Args:
            sensor: Sensor.
            frame_name: Frame name.
        """
        vis.updatePolyData(sensor.to_polydata(), frame_name,
                           colorByName="RGB255")

#.........这里部分代码省略.........
开发者ID:raptor419,项目名称:active-obstacle-avoidance,代码行数:103,代码来源:simulator.py


注:本文中的director.consoleapp.ConsoleApp.createView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。