原点一般是程序开始时机器人的位置。所以是的,机器人的初始姿势。当我使用它时,它可以作为机器人的原始位置。通常,当使用原点时,您会创建当前位置的深层副本。
def initPose(self):
origin = copy.deepcopy(self._current)
q = [origin.orientation.x,
origin.orientation.y,
origin.orientation.z,
origin.orientation.w] # quaternion nonsense
(roll, pitch, yaw) = euler_from_quaternion(q)
return (self._current.position.x, self._current.position.y, yaw)
# self._odom_list.waitForTransform('YOUR_STRING_HERE', 'YOUR_STRING_HERE', rospy.Time(0), rospy.Duration(1.0))
但我也使用原点作为函数的原点。
def navToPose(self, goal):
# self._odom_list.waitForTransform('map', 'base_footprint', rospy.Time(0), rospy.Duration(1.0))
# transGoal = self._odom_list.transformPose('base_footprint', goal) # transform the nav goal from the global coordinate system to the robot's coordinate system
origin = copy.deepcopy(self._current)
q = [origin.orientation.x,
origin.orientation.y,
origin.orientation.z,
origin.orientation.w] # quaternion nonsense
(roll, pitch, yaw) = euler_from_quaternion(q)
qc = [self._current.orientation.x,
self._current.orientation.y,
self._current.orientation.z,
self._current.orientation.w]
(rollc, pitchc, yawc) = euler_from_quaternion(qc)
x = goal.pose.position.x
y = goal.pose.position.y
cx = origin.position.x
cy = self._current.position.y
print('current', cx, cy)
print(x, y)
theta = math.atan2(y-cy, x-cx)
print ('angle is ', theta)
self.rotate(theta)
distance = (((x - cx) ** 2) + ((y - cy) ** 2)) ** .5
print ('distance is ', distance)
self.driveStraight(0.5, distance)
所以一般来说,我更多地将它用作另一个变量。
取决于占用网格的完成方式。有时原点将指的是它在网格上的开始位置。让程序知道它是否还在地图上。这可能会产生此处显示的问题:https://answers.ros.org/question/285602/static-map-corner-at-origin-for-navigation-stack/(至少从我的经历来看)
有关导航堆栈的更多信息,请访问:http://wiki.ros.org/navigation
在这里:https://www.dis.uniroma1.it/~nardi/Didattica/CAI/matdid/robot-programming-ROS-introduction-to-navigation.pdf