本文整理汇总了Python中naoqi.ALProxy.getRobotPosition方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.getRobotPosition方法的具体用法?Python ALProxy.getRobotPosition怎么用?Python ALProxy.getRobotPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.getRobotPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Pose Init
postureProxy.goToPosture("StandInit", 0.5)
# Example showing how to get a simplified robot position in world.
useSensorValues = False
result = motionProxy.getRobotPosition(useSensorValues)
print "Robot Position", result
# Example showing how to use this information to know the robot's diplacement.
useSensorValues = False
initRobotPosition = almath.Pose2D(motionProxy.getRobotPosition(useSensorValues))
# Make the robot move
motionProxy.moveTo(0.1, 0.0, 0.2)
endRobotPosition = almath.Pose2D(motionProxy.getRobotPosition(useSensorValues))
# Compute robot's' displacement
robotMove = almath.pose2DInverse(initRobotPosition)*endRobotPosition
print "Robot Move:", robotMove
# Go to rest position
motionProxy.rest()
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)
#####################
## Enable arms control by move algorithm
#####################
motionProxy.setMoveArmsEnabled(True, True)
#~ motionProxy.setMoveArmsEnabled(False, False)
#####################
## FOOT CONTACT PROTECTION
#####################
#~ motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION",False]])
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
#####################
## get robot position before move
#####################
initRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
X = 0.0
Y = 0.0
Theta = math.pi/2.0
motionProxy.post.moveTo(X, Y, Theta)
motionProxy.setAngles("HeadYaw", 0.6, 0.6)
# wait is useful because with post moveTo is not blocking function
motionProxy.waitUntilMoveIsFinished()
#####################
## get robot position after move
#####################
endRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
#####################
## compute and print the robot motion
#####################
robotMove = m.pose2DInverse(initRobotPosition)*endRobotPosition
# return an angle between ]-PI, PI]
robotMove.theta = m.modulo2PI(robotMove.theta)
print "Robot Move:", robotMove
# Go to rest position
motionProxy.rest()
示例3: Robot
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
class Robot(spade.Agent.Agent):
class Report(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
if self.myAgent.state == 0:
print "I'm registered."
position = str(posRelx)+" "+str(posRely)
print position
self.myAgent.sendController("inform", "RobotPos", position)
elif self.myAgent.state == 1:
print "I'm positioned"
self.myAgent.sendController("inform", "BoxPos", cajas)
elif self.myAgent.state == 2:
print "Boxes sent"
self.myAgent.state += 1
class Scheduler(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
print self.msg.getContent()
goForBoxes(self.myAgent, self.msg.getContent())
self.myAgent.sendController("inform", "End", None)
self.myAgent._kill()
def _setup(self):
template = spade.Behaviour.ACLTemplate()
template.setOntology("NaoTest")
template.setPerformative( "inform" )
template.setConversationId("Report")
mt = spade.Behaviour.MessageTemplate(template)
self.addBehaviour(self.Report(), mt)
template.setPerformative( "inform" )
template.setConversationId("Schedule")
mt = spade.Behaviour.MessageTemplate(template)
self.addBehaviour(self.Scheduler(), mt)
print nombreAgente+": I'm going to register..."
self.sendController("request", "Register", None)
self.motionProxy = ALProxy("ALMotion", robotIP, robotPort)
self.talkProxy = ALProxy("ALTextToSpeech", robotIP, robotPort)
self.locationProxy = ALProxy("ALLocalization", robotIP, robotPort)
print "Aprendiendo la posicion inicial..."
self.locationProxy.learnHome()
realPos = almath.Pose2D(self.locationProxy.getRobotPosition(False))
print "Posicion inicial:", realPos
self.pos = [0]*2
self.pos[0] = posRelx+int(round(realPos.x, 1)*10)
self.pos[1] = posRely+int(round(realPos.y, 1)*10)
self.state = 0
def sendController(self, perf, id, content):
# Creamos el mensaje
msg = spade.ACLMessage.ACLMessage()
# Lo rellenamos
msg.setOntology( "NaoTest" )
msg.setPerformative( perf )
msg.setConversationId( id )
msg.setContent( content )
gameManager = spade.AID.aid(name="[email protected]"+servidor, addresses=["xmpp://[email protected]"+servidor])
msg.addReceiver( gameManager )
self.send(msg)
示例4: seek
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
# seek(motionProxy, ball_location)
# post lets us execute commands at the same time
# without it one robot would move and afterwards the other robot would move
# motionProxy.post.moveTo(1, 0, 20)
# motionProxy2.post.moveTo(1, 0, 20)
# Main Loop
try:
while True:
#Parameters:
# useSensors - If true, use the MRE sensor values
#Returns:
# A vector containing the World Absolute Robot Position.
# (Absolute Position X, Absolute Position Y, Absolute Angle Theta (Wz)).
location = motionProxy2.getRobotPosition(False)
print location
motionProxy2.post.moveTo(1, 0, 0)
time.sleep(1)
# Exit Behaviour
except KeyboardInterrupt:
print
print "Interrupted by user, shutting down"
sys.exit(0)
示例5: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)
# first we defined the goal
goal = m.Pose2D(0.0, -0.4, 0.0)
# We get the dubins solution (control points) by
# calling an almath function
circleRadius = 0.04
# Warning : the circle use by dubins curve
# have to be 4*CircleRadius < norm(goal)
dubinsSolutionAbsolute = m.getDubinsSolutions(goal, circleRadius)
# moveTo With control Points use relative commands but
# getDubinsSolution return absolute position
# So, we compute dubinsSolution in relative way
dubinsSolutionRelative = []
dubinsSolutionRelative.append(dubinsSolutionAbsolute[0])
for i in range(len(dubinsSolutionAbsolute)-1):
dubinsSolutionRelative.append(
dubinsSolutionAbsolute[i].inverse() *
dubinsSolutionAbsolute[i+1])
# create a vector of moveTo with dubins Control Points
moveToTargets = []
for i in range(len(dubinsSolutionRelative)):
moveToTargets.append(
[dubinsSolutionRelative[i].x,
dubinsSolutionRelative[i].y,
dubinsSolutionRelative[i].theta] )
# Initialized the Move process and be sure the robot is ready to move
# without this call, the first getRobotPosition() will not refer to the position
# of the robot before the move process
motionProxy.moveInit()
# get robot position before move
robotPositionBeforeCommand = m.Pose2D(motionProxy.getRobotPosition(False))
motionProxy.moveTo( moveToTargets )
# With MoveTo control Points, it's also possible to customize the gait parameters
# motionProxy.moveTo(moveToTargets,
# [["StepHeight", 0.001],
# ["MaxStepX", 0.06],
# ["MaxStepFrequency", 1.0]])
# get robot position after move
robotPositionAfterCommand = m.Pose2D(motionProxy.getRobotPosition(False))
# compute and print the robot motion
robotMoveCommand = m.pose2DInverse(robotPositionBeforeCommand)*robotPositionAfterCommand
print "The Robot Move Command: ", robotMoveCommand
# Go to rest position
motionProxy.rest()
示例6: AgRobot
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
class AgRobot(spade.Agent.Agent):
class Reach(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
print "Descubierto"
self.myAgent.sendTo("inform", "Position", str(self.myAgent.pos[0])+" "+str(self.myAgent.pos[1]), otroAgente)
class Position(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
temp1 = self.msg.getSender().getName()
print "Mensaje de posicionamiento"
if self.myAgent.others == 1:
print "Posicionando", temp1
i = 0
while temp1 != self.myAgent.robots[i].dir: i += 1
temp2 = self.msg.getContent()
temp2 = temp2.split()
self.myAgent.robots[i].x = int(temp2[0])
self.myAgent.robots[i].y = int(temp2[1])
print temp1, int(temp2[0]), int(temp2[1])
self.myAgent.others -= 1
self.myAgent.sendTo("inform", "Ack", None, otroAgente)
else:
print "Recibidas cajas", temp1
self.msg = str(self.msg.getContent())
temp2 = self.msg.split()
for i in xrange(0, len(temp2), 2):
self.myAgent.boxes.append(Object(int(temp2[i]), int(temp2[i+1])))
X, temp = solver.branchAndBound(self.myAgent.robots, Object(10, 10), self.myAgent.boxes)
s = ""
for box in temp[1]:
s += box.toMessage()
self.myAgent.sendTo("inform", "Path", s, self.myAgent.robots[1].dir)
self.myAgent.schedule = temp[0]
class Ack(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
print "Mensaje Ack"
if not iamMaster and self.myAgent.state == 0:
self.myAgent.state += 1
print "Enviando cajas"
self.myAgent.sendTo("inform", "Position", cajas, otroAgente)
elif iamMaster and self.myAgent.state == 0:
self.myAgent.state += 4
print "Caja 0"
goForBoxes(self.myAgent, self.myAgent.schedule, 0)
print "Caja 1"
goForBoxes(self.myAgent, self.myAgent.schedule, 1)
print "Caja 2"
goForBoxes(self.myAgent, self.myAgent.schedule, 2)
self.myAgent.sendTo("inform", "Ack", None, otroAgente)
elif str(self.msg.getContent()) == "End":
for i in xrange(self.myAgent.state-1, len(self.myAgent.schedule)):
goForBoxes(self.myAgent, self.myAgent.schedule, i)
print "Trabajo finalizado, volviendo a la posicion inicial... "
realPos = almath.Pose2D(self.myAgent.locationProxy.getRobotPosition(False))
self.myAgent.motionProxy.post.moveTo(0,0,0-realPos.theta)
self.myAgent.motionProxy.waitUntilMoveIsFinished()
self.myAgent.motionProxy.post.moveTo(0-realPos.x,0-realPos.y,0)
self.myAgent.motionProxy.waitUntilMoveIsFinished()
realPos = almath.Pose2D(self.myAgent.locationProxy.getRobotPosition(False))
print realPos
print "FIN"
self.myAgent._kill()
sys.exit(0)
elif self.myAgent.state > 0:
print "Caja", self.myAgent.state-1
goForBoxes(self.myAgent, self.myAgent.schedule, self.myAgent.state-1)
self.myAgent.state += 1
print "Caja", self.myAgent.state-1
goForBoxes(self.myAgent, self.myAgent.schedule, self.myAgent.state-1)
self.myAgent.state += 1
if len(self.myAgent.schedule) == (self.myAgent.state-1)/2:
self.myAgent.sendTo("inform", "Ack", "End", otroAgente)
print "Trabajo finalizado, volviendo a la posicion inicial... "
self.myAgent.locationProxy.goToHome()
realPos = almath.Pose2D(self.myAgent.locationProxy.getRobotPosition(False))
print realPos
print "FIN"
self.myAgent._kill()
sys.exit(0)
else:
self.myAgent.sendTo("inform", "Ack", None, otroAgente)
class Path(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
print "Recibido camino", self.msg.getContent()
msg = self.msg.getContent().split()
temp = []
for pos in xrange(0, len(msg), 2):
temp.append(Object(int(msg[pos]), int(msg[pos+1])))
self.myAgent.schedule = temp
#.........这里部分代码省略.........
示例7: Tracker
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
class Tracker():
def __init__(self):
rospy.init_node('tracker_mykinect', anonymous=True)
self.myFrame = 'kinect_link'
self.r = rospy.Rate(20) #rospy.Rate(1) = 1Hz
#Skeleton Listener
self.tf = tf.TransformListener()
#Nao init and connect
self.nao_init()
self.startXPosition = 0.0;
self.startYPosition = 0.0;
self.naoXPosition = self.startXPosition
self.naoYPosition = self.startYPosition
rospy.loginfo("Start tracking for 3s...")
rospy.sleep(3.0)
rospy.loginfo("Tracking started!")
self.hoh = 0.86 #Nao Hight in meters
for i in range(1, 4):
#Get all nessecery joins. (Right side = Left side if you stand front to sensor)
try:
self.j_head = "{0}_{1}".format(rospy.get_param('~target_joint', '/head'), i)
self.j_l_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_hand'), i)
self.j_r_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_hand'), i)
self.j_l_shoul = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_shoulder'), i)
self.j_torso = "{0}_{1}".format(rospy.get_param('~target_joint', '/torso'), i)
self.j_l_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_elbow'), i)
self.j_r_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_elbow'), i)
break
except:
pass
def toRAD(self,angle):
return angle*almath.TO_RAD
def nao_init(self):
#NAO CONNECT AND INIT
# PORT AND IP NAO ROBOT
#ip = rospy.get_param('~ip', '127.0.0.1')
#port = int(rospy.get_param('~port', '51888'))
ip = rospy.get_param('~ip', '10.104.16.53')
port = int(rospy.get_param('~port', '9559'))
self.al = ALProxy("ALAutonomousLife", ip, port)
self.postureProxy = ALProxy("ALRobotPosture", ip, port)
self.tts = ALProxy("ALTextToSpeech", ip, port)
self.motionProxy = ALProxy("ALMotion", ip, port)
self.behavior = ALProxy("ALBehaviorManager",ip,port)
self.mistake = almath.Pose2D(self.motionProxy.getRobotPosition(False))
#self.audioProxy = ALProxy("ALSpeechRecognition",ip,port)
#self.audioProxy.setLanguage("English")
#vocabulary = ["go"]
#self.audioProxy.setVocabulary(vocabulary, False)
#self.al.setState("disabled")
#self.postureProxy.goToPosture("StandInit", 0.5)
#ALProxy("ALBasicAwareness", ip, port).stopAwareness()
#self.motionProxy.setFallManagerEnabled(False)
self.motionProxy.setExternalCollisionProtectionEnabled("All",False)
def nao_hello(self):
#Nao hello module
#self.postureProxy.goToPosture("StandInit",1.0)
self.behavior.stopAllBehaviors()
self.motionProxy.setAngles('RShoulderPitch',self.toRAD(-97.3),1.0)
self.motionProxy.setAngles('RShoulderRoll',self.toRAD(-39.2),1.0)
self.motionProxy.setAngles('RElbowRoll',self.toRAD(50.8),1.0)
self.motionProxy.setAngles('RElbowYaw',self.toRAD(8.5),1.0)
self.motionProxy.setAngles('RWristYaw',self.toRAD(-13.4),1.0)
self.motionProxy.openHand('RHand')
thread.start_new_thread((lambda:self.tts.say("Hello my friend")),())
for i in range(0,2):
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-12.2),0.3,True)
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(39.2),0.3,True)
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-50.4),0.3,True)
self.postureProxy.goToPosture("StandInit",1.0)
self.behavior.runBehavior('nao-14eaf5/BogdAL')
def nao_sensei(self):
#Nao hello(sensei) module
self.behavior.stopAllBehaviors()
self.postureProxy.goToPosture("StandInit",1.0)
self.motionProxy.setAngles(['RShoulderPitch','LShoulderPitch'],[self.toRAD(52.7),self.toRAD(49.1)],1.0)
self.motionProxy.setAngles(['RShoulderRoll','LShoulderRoll'],[self.toRAD(13.3),self.toRAD(-8.9)],1.0)
self.motionProxy.setAngles(['RElbowRoll','LElbowRoll'],[self.toRAD(88.3),self.toRAD(-87.6)],1.0)
self.motionProxy.setAngles(['RElbowYaw','LElbowYaw'],[self.toRAD(68.1),self.toRAD(-60.9)],1.0)
self.motionProxy.setAngles(['RWristYaw','LWristYaw'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
self.motionProxy.setAngles(['RHand','LHand'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
self.motionProxy.openHand('RHand')
self.motionProxy.openHand('LHand')
#sequence head
self.tts.say("Domo Arigato")
#self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
self.motionProxy.angleInterpolation("HeadPitch",self.toRAD(26.5),1.0,True)
self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
self.postureProxy.goToPosture("StandInit",1)
#.........这里部分代码省略.........
示例8: atan
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
return pi+atan(float(tarY-souY)/(tarX-souX))
return atan(float(tarY-souY)/(tarX-souX))
print
print
print
print "-------------------------------------"
print "Desplazamiento directo"
print "-------------------------------------"
pos1 = almath.Pose2D([0, 0, 0])
pos2 = almath.Pose2D([0, 0, 0])
if robot1: locationProxy1.learnHome()
if robot2: locationProxy2.learnHome()
if robot1: pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
if robot2: pos2 = almath.Pose2D(locationProxy2.getRobotPosition(False))
if robot1:
motionProxy1.moveTo(0.3-pos1.x, 0.5-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Caja", pos1
motionProxy1.moveTo(1.0-pos1.x, 1.0-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Contenedor", pos1
motionProxy1.moveTo(0.5-pos1.x, 1.0-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Caja", pos1
if robot2:
示例9: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getRobotPosition [as 别名]
class Motion:
# constructor
def __init__(self, ip='127.0.0.1', port=9559):
self.motionProxy = ALProxy('ALMotion', ip, port)
self.postureProxy = ALProxy('ALRobotPosture', ip, port)
self.camProxy = ALProxy('ALVideoDevice', ip, port)
self.compassProxy = ALProxy('ALVisualCompass', ip, port)
self.navi = ALProxy('ALNavigation', ip, port)
resolution = vision_definitions.kVGA
colorSpace = vision_definitions.kRGBColorSpace
self.fps = 15
self.videoClient = self.camProxy.subscribeCamera('python_client', 0, resolution, colorSpace, self.fps)
# print self.videoClient
# in case of camera subscribe overflow
assert self.videoClient is not None
# wake up nao
self.motionProxy.wakeUp()
# stand init
self.postureProxy.goToPosture("StandInit", 0.5)
# move init
self.motionProxy.moveInit()
# get the origin
self.__origin = tuple(self.motionProxy.getRobotPosition(False))
self.__origin_grid = (0, 0, 0)
self.__position_grid = list(self.__origin_grid)
# destructor
def __del__(self):
self.camProxy.unsubscribe(self.videoClient)
self.camProxy.setAllParametersToDefault(0)
# rest, set all stiffness to 0
self.motionProxy.rest()
def xiapao(self, x, y):
print self.navi.navigateTo(x, y)
# 瞎 jb 看
def __look(self):
ret = dict()
pitch = self.motionProxy.getAngles('HeadPitch', False)[0]
yaw = self.motionProxy.getAngles('HeadYaw', False)[0]
print 'taking picture'
img = self.__takePicture()
ret[HeadLoc(left=yaw, down=pitch)] = img
# 随便转转头
self.motionProxy.setAngles('HeadPitch', random.uniform(-0.1, 0.1), 0.1)
self.motionProxy.setAngles('HeadYaw', random.uniform(-0.1, 0.1), 0.1)
time.sleep(2.0)
pitch = self.motionProxy.getAngles('HeadPitch', False)[0]
yaw = self.motionProxy.getAngles('HeadYaw', False)[0]
print 'taking picture'
img = self.__takePicture()
ret[HeadLoc(left=yaw, down=pitch)] = img
self.motionProxy.setAngles('HeadPitch', 0.0, 0.1)
self.motionProxy.setAngles('HeadYaw', 0.0, 0.1)
return ret
def lookAround(self):
print 'looking around... '
ret = dict()
angle = numpy.pi / 4
ret[0.0] = self.__look()
self.turn(angle)
ret[angle] = self.__look()
self.turn(- 2 * angle)
ret[2 * numpy.pi - angle] = self.__look()
self.turn(angle)
return ret
# take a picture
def __takePicture(self):
# for debug
print "takePicture"
naoImage = self.camProxy.getImageRemote(self.videoClient)
width = naoImage[0]; height = naoImage[1]
nchanels = naoImage[2]; array = naoImage[6]
return self.__str2array(array, (height, width, nchanels))
def __str2array(self, string, shape):
assert len(string) == shape[0] * shape[1] * shape[2], len(shape) == 3
image = numpy.zeros(shape, numpy.uint8)
#.........这里部分代码省略.........