ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

better localization update with amcl or odom

asked 2020-10-13 03:11:07 -0500

bfdmetu gravatar image

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
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-10-13 03:57:31 -0500

Rayman gravatar image

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.

image description

See also: http://wiki.ros.org/amcl

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-10-13 03:11:07 -0500

Seen: 325 times

Last updated: Oct 13 '20