better localization update with amcl or odom
Hi. I am running a differential robot. In my original code i use encoder information for odom update. Can i use amcl_pose to update odom information ?
I cant decide whether to use encoder information or amcl_pose for better localization.
Original Code
self.dth = self.vth * dt
self.pth += self.dth
if(self.pth >= two_pi):
self.pth-= two_pi
if(self.pth <= -two_pi):
self.pth += two_pi
self.vxx= self.vx * math.cos(self.vth)
self.vxy= (self.vx * math.sin(self.vth))
self.dx = (self.vxx * math.cos(self.pth)-self.vxy*sin(self.pth)) * dt
self.dy = (self.vxx * math.sin(self.pth)+ self.vxy*cos(self.pth)) * dt
self.px += self.dx #last position
self.py += self.dy
----------------------------------------
Update code with Amcl
I add 3 line to update position info
self.px=amcl_pose1.pose.pose.position.x
self.py=amcl_pose1.pose.pose.position.y
self.pth=amcl_pose1.pose.pose.orientation.z
self.dth = self.vth * dt
self.pth += self.dth
if(self.pth >= two_pi):
self.pth-= two_pi
if(self.pth <= -two_pi):
self.pth += two_pi
self.vxx= self.vx * math.cos(self.vth)
self.vxy= (self.vx * math.sin(self.vth))
self.dx = (self.vxx * math.cos(self.pth)-self.vxy*sin(self.pth)) * dt
self.dy = (self.vxx * math.sin(self.pth)+ self.vxy*cos(self.pth)) * dt
self.px += self.dx #last position
self.py += self.dy
Asked by bfdmetu on 2020-10-13 03:11:07 UTC
Answers
AMCL doesn't replace odom, but corrects the global error that occurs when you keep integrating your encoder output. See the figure below. Odom stays the same, but AMCL adds an transform on top (/map to /odom) which corrects for the global localization error.
See also: http://wiki.ros.org/amcl
Asked by Rayman on 2020-10-13 03:57:31 UTC
Comments