|
@@ -160,10 +160,10 @@ class Robot(MqttAsync):
|
|
|
'''
|
|
|
阻塞直到导航完成
|
|
|
'''
|
|
|
- def Navigatting(self, begId, targetId):
|
|
|
+ def Navigatting(self, begId, targetId,autoDirect):
|
|
|
print("nav")
|
|
|
self.GeneratePath(begId, targetId)
|
|
|
- self.ExecPathNodes()
|
|
|
+ self.ExecPathNodes(autoDirect)
|
|
|
#self.ExecNavtask()
|
|
|
while self.IsNavigating() == True:
|
|
|
'''if self.Connected() == False:
|
|
@@ -258,17 +258,12 @@ class Robot(MqttAsync):
|
|
|
time.sleep(1)
|
|
|
print("send nav cmd completed!!!")
|
|
|
return True
|
|
|
- def ExecPathNodes(self,autoDirect=False):
|
|
|
- if self.navCmdTopic_ == None:
|
|
|
- print("Robot has not set nav cmd topic")
|
|
|
- return False
|
|
|
- if not self.ActionType()==ActType.eReady:
|
|
|
- print(" robot is navigating ,key:%s" % (self.timedNavStatu_.statu.key))
|
|
|
- return False
|
|
|
-
|
|
|
- cmd = message.NavCmd()
|
|
|
- cmd.action=6
|
|
|
+ def CreateNavPathNodesAction(self,autoDirect):
|
|
|
if self.currentNavPathNodes_ is not None and self.timedRobotStatu_.timeout() == False:
|
|
|
+ for node in self.currentNavPathNodes_:
|
|
|
+ if isinstance(node,(SpaceNode)):
|
|
|
+ print(" nodes must all street node")
|
|
|
+ return None
|
|
|
statu = self.timedRobotStatu_.statu
|
|
|
if statu is not None:
|
|
|
newAction=message.NewAction()
|
|
@@ -276,7 +271,7 @@ class Robot(MqttAsync):
|
|
|
limitRotate=message.SpeedLimit()
|
|
|
limAdjustV=message.SpeedLimit()
|
|
|
limitAdjustH=message.SpeedLimit()
|
|
|
- limitMPC_v.min=0.05
|
|
|
+ limitMPC_v.min=0.03
|
|
|
limitMPC_v.max=1.2
|
|
|
limitRotate.min=3*math.pi/180.0
|
|
|
limitRotate.max=25*math.pi/180.0
|
|
@@ -317,6 +312,7 @@ class Robot(MqttAsync):
|
|
|
accuracy.x=0.05
|
|
|
accuracy.y=0.1
|
|
|
accuracy.theta=3*math.pi/180.0
|
|
|
+ count+=1
|
|
|
|
|
|
pathNode=message.PathNode()
|
|
|
pathNode.pose.CopyFrom(pose)
|
|
@@ -329,19 +325,31 @@ class Robot(MqttAsync):
|
|
|
newAction.NodeAngularLimit.CopyFrom(limitRotate)
|
|
|
newAction.adjustVelocitylimit.CopyFrom(limAdjustV)
|
|
|
newAction.adjustHorizonLimit.CopyFrom(limitAdjustH)
|
|
|
- cmd.newActions.add().CopyFrom(newAction)
|
|
|
-
|
|
|
- count+=1
|
|
|
-
|
|
|
+ return newAction
|
|
|
else:
|
|
|
print("statu is None")
|
|
|
- return False
|
|
|
else:
|
|
|
print("current path is none")
|
|
|
+ return None
|
|
|
+ def ExecPathNodes(self,autoDirect):
|
|
|
+ if self.navCmdTopic_ == None:
|
|
|
+ print("Robot has not set nav cmd topic")
|
|
|
return False
|
|
|
- if cmd is None:
|
|
|
+ if not self.ActionType()==ActType.eReady:
|
|
|
+ print(" robot is navigating ,key:%s" % (self.timedNavStatu_.statu.key))
|
|
|
+ return False
|
|
|
+
|
|
|
+ cmd = message.NavCmd()
|
|
|
+ key = str(uuid.uuid4())
|
|
|
+ cmd.key = key
|
|
|
+ cmd.action=0
|
|
|
+
|
|
|
+ action =self.CreateNavPathNodesAction(autoDirect)
|
|
|
+ if action is None:
|
|
|
print("Nav cmd is None")
|
|
|
return False
|
|
|
+ cmd.newActions.add().CopyFrom(action)
|
|
|
+
|
|
|
print(cmd)
|
|
|
published=False
|
|
|
while self.IsNavigating() == False:
|
|
@@ -359,11 +367,16 @@ class Robot(MqttAsync):
|
|
|
print(" this agv is single can not switch mode")
|
|
|
return False
|
|
|
cmd = message.NavCmd()
|
|
|
+ key = str(uuid.uuid4())
|
|
|
+ cmd.key = key
|
|
|
+ cmd.action=0
|
|
|
+
|
|
|
+ action=message.NewAction()
|
|
|
+ action.type=8
|
|
|
+ action.changedMode = mode
|
|
|
if mode == 2:
|
|
|
- cmd.wheelbase = wheelbase
|
|
|
- cmd.action = 4
|
|
|
- if mode == 1:
|
|
|
- cmd.action = 5
|
|
|
+ action.wheelbase = wheelbase
|
|
|
+ cmd.newActions.add().CopyFrom(action)
|
|
|
loop=3
|
|
|
while loop>0:
|
|
|
if mode == 2:
|
|
@@ -415,11 +428,12 @@ class Robot(MqttAsync):
|
|
|
print("clamp closed")
|
|
|
return True
|
|
|
cmd = message.NavCmd()
|
|
|
+ cmd.action=0
|
|
|
key = str(uuid.uuid4())
|
|
|
cmd.key = (key)
|
|
|
- act = message.Action()
|
|
|
- act.type = 3
|
|
|
- cmd.actions.add().CopyFrom(act)
|
|
|
+ act = message.NewAction()
|
|
|
+ act.type = 6
|
|
|
+ cmd.newActions.add().CopyFrom(act)
|
|
|
published=False
|
|
|
while self.IsClampClosed()==False:
|
|
|
if self.ActionType()==ActType.eClampClose:
|
|
@@ -434,11 +448,12 @@ class Robot(MqttAsync):
|
|
|
print("clamp opended")
|
|
|
return True
|
|
|
cmd = message.NavCmd()
|
|
|
+ cmd.action=0
|
|
|
key = str(uuid.uuid4())
|
|
|
cmd.key = (key)
|
|
|
- act = message.Action()
|
|
|
- act.type = 4
|
|
|
- cmd.actions.add().CopyFrom(act)
|
|
|
+ act = message.NewAction()
|
|
|
+ act.type = 7
|
|
|
+ cmd.newActions.add().CopyFrom(act)
|
|
|
published=False
|
|
|
while self.IsClampOpened()==False:
|
|
|
if self.ActionType()==ActType.eClampOpen:
|
|
@@ -450,7 +465,8 @@ class Robot(MqttAsync):
|
|
|
|
|
|
def CancelNavTask(self):
|
|
|
cmd = message.NavCmd()
|
|
|
- cmd.action = 3
|
|
|
+ cmd.action=3
|
|
|
+
|
|
|
while self.IsNavigating() == True:
|
|
|
self.publish(self.navCmdTopic_, jtf.MessageToJson(cmd))
|
|
|
time.sleep(1)
|