|
@@ -243,14 +243,10 @@ class Robot(MqttAsync):
|
|
|
return ActType.eReady
|
|
|
|
|
|
@staticmethod
|
|
|
- def generateProtoNode(node, accuracy):
|
|
|
- [dx, dy, dyaw] = accuracy
|
|
|
+ def generateProtoNode(node):
|
|
|
protoNode = message.PathNode()
|
|
|
protoNode.x = node.x_
|
|
|
protoNode.y = node.y_
|
|
|
- protoNode.l = dx
|
|
|
- protoNode.w = dy
|
|
|
- protoNode.theta = dyaw
|
|
|
return protoNode
|
|
|
|
|
|
def ExecNavtask(self, autoDirect):
|
|
@@ -259,61 +255,30 @@ class Robot(MqttAsync):
|
|
|
cmd.key = key
|
|
|
cmd.action = 0
|
|
|
|
|
|
- limitMPC_v = message.SpeedLimit()
|
|
|
- limitRotate = message.SpeedLimit()
|
|
|
- limAdjustV = message.SpeedLimit()
|
|
|
- limitAdjustH = message.SpeedLimit()
|
|
|
- limitInOutV = message.SpeedLimit()
|
|
|
- limitMPC_v.min = 0.03
|
|
|
- limitMPC_v.max = 1.2
|
|
|
- limitRotate.min = 3 * math.pi / 180.0
|
|
|
- limitRotate.max = 25 * math.pi / 180.0
|
|
|
- limAdjustV.min = 0.03
|
|
|
- limAdjustV.max = 0.5
|
|
|
- limitAdjustH.min = 0.03
|
|
|
- limitAdjustH.max = 0.3
|
|
|
- limitInOutV.min = 0.03
|
|
|
- limitInOutV.max = 0.8
|
|
|
-
|
|
|
- # if task_type == "DoubleAGV":
|
|
|
- # print("AdjustPath------------------")
|
|
|
- # if self.IsMainModeStatu() is False:
|
|
|
- # print("原始路径:")
|
|
|
- # for node in self.currentNavPathNodes_:
|
|
|
- # print(node.id_, node.y_)
|
|
|
- # self.currentNavPathNodes_ = self.AdjustPath(self.currentNavPathNodes_)
|
|
|
- # print("修改路径:")
|
|
|
- # for node in self.currentNavPathNodes_:
|
|
|
- # print(node.id_, node.y_)
|
|
|
-
|
|
|
actions = self.SplitPath(self.currentNavPathNodes_)
|
|
|
for action in actions:
|
|
|
[type, nodes] = action
|
|
|
if type == "input":
|
|
|
[street, space] = nodes
|
|
|
- protoSpace = self.generateProtoNode(space, [0.05, 0.05, 0.7 * math.pi / 180.0])
|
|
|
- protoStreet = self.generateProtoNode(street, [0.05, 0.05, 1 * math.pi / 180.0])
|
|
|
+ protoSpace = self.generateProtoNode(space)
|
|
|
+ protoStreet = self.generateProtoNode(street)
|
|
|
act = message.NewAction()
|
|
|
act.type = 1
|
|
|
+ act.wheelbase=2.78
|
|
|
act.spaceNode.CopyFrom(protoSpace)
|
|
|
act.streetNode.CopyFrom(protoStreet)
|
|
|
- act.NodeAngularLimit.CopyFrom(limitRotate)
|
|
|
- act.InOutVLimit.CopyFrom(limitInOutV)
|
|
|
- act.adjustVelocitylimit.CopyFrom(limAdjustV)
|
|
|
- act.adjustHorizonLimit.CopyFrom(limitAdjustH)
|
|
|
+
|
|
|
cmd.newActions.add().CopyFrom(act)
|
|
|
if type == "output":
|
|
|
[space, street] = nodes
|
|
|
- protoSpace = self.generateProtoNode(space, [0.05, 0.05, 0.7 * math.pi / 180.0])
|
|
|
- protoStreet = self.generateProtoNode(street, [0.05, 0.05, 1 * math.pi / 180.0])
|
|
|
+ protoSpace = self.generateProtoNode(space)
|
|
|
+ protoStreet = self.generateProtoNode(street)
|
|
|
act = message.NewAction()
|
|
|
act.type = 2
|
|
|
+ act.wheelbase=2.78
|
|
|
act.spaceNode.CopyFrom(protoSpace)
|
|
|
act.streetNode.CopyFrom(protoStreet)
|
|
|
- act.InOutVLimit.CopyFrom(limitInOutV)
|
|
|
- act.NodeAngularLimit.CopyFrom(limitRotate)
|
|
|
- act.adjustVelocitylimit.CopyFrom(limAdjustV)
|
|
|
- act.adjustHorizonLimit.CopyFrom(limitAdjustH)
|
|
|
+
|
|
|
cmd.newActions.add().CopyFrom(act)
|
|
|
if type == "nav":
|
|
|
action = self.CreateNavPathNodesAction(nodes, autoDirect)
|
|
@@ -344,62 +309,18 @@ class Robot(MqttAsync):
|
|
|
statu = self.timedRobotStatu_.statu
|
|
|
if statu is not None:
|
|
|
newAction = message.NewAction()
|
|
|
- limitMPC_v = message.SpeedLimit()
|
|
|
- limitRotate = message.SpeedLimit()
|
|
|
- limAdjustV = message.SpeedLimit()
|
|
|
- limitAdjustH = message.SpeedLimit()
|
|
|
- limitMPC_v.min = 0.03
|
|
|
- limitMPC_v.max = 1.5
|
|
|
- limitRotate.min = 3 * math.pi / 180.0
|
|
|
- limitRotate.max = 25 * math.pi / 180.0
|
|
|
- limAdjustV.min = 0.03
|
|
|
- limAdjustV.max = 0.3
|
|
|
- limitAdjustH.min = 0.03
|
|
|
- limitAdjustH.max = 0.3
|
|
|
-
|
|
|
- count = 0
|
|
|
size = len(path)
|
|
|
for i in range(size):
|
|
|
node = path[i]
|
|
|
pathNode = message.PathNode()
|
|
|
pathNode.x = node.x_
|
|
|
pathNode.y = node.y_
|
|
|
- distance = 0
|
|
|
- if i + 1 < size:
|
|
|
- next = path[i + 1]
|
|
|
- vector = [next.x_ - node.x_, next.y_ - node.y_]
|
|
|
- dx = vector[0]
|
|
|
- dy = vector[1]
|
|
|
- distance = math.sqrt(dx * dx + dy * dy)
|
|
|
- yaw = math.asin(dy / math.sqrt(dx * dx + dy * dy))
|
|
|
- if yaw >= 0:
|
|
|
- if dx < 0:
|
|
|
- yaw = math.pi - yaw
|
|
|
- if yaw < 0:
|
|
|
- if dx < 0:
|
|
|
- yaw = -math.pi - yaw
|
|
|
- pathNode.theta = -yaw
|
|
|
- else:
|
|
|
- pathNode.theta = 0
|
|
|
-
|
|
|
-
|
|
|
- if self.IsMainModeStatu():
|
|
|
- pathNode.l = 0.15
|
|
|
- pathNode.w = 0.05
|
|
|
- else:
|
|
|
- pathNode.l = 0.3
|
|
|
- pathNode.w = 0.1
|
|
|
-
|
|
|
- count += 1
|
|
|
|
|
|
newAction.type = 4
|
|
|
if autoDirect:
|
|
|
newAction.type = 3
|
|
|
newAction.pathNodes.add().CopyFrom(pathNode)
|
|
|
- newAction.NodeVelocityLimit.CopyFrom(limitMPC_v)
|
|
|
- newAction.NodeAngularLimit.CopyFrom(limitRotate)
|
|
|
- newAction.adjustVelocitylimit.CopyFrom(limAdjustV)
|
|
|
- newAction.adjustHorizonLimit.CopyFrom(limitAdjustH)
|
|
|
+
|
|
|
return newAction
|
|
|
else:
|
|
|
print("statu is None")
|