EKF - Adding multiple robots
NicoMandel opened this issue · 2 comments
Hi peter, Jesse
First of all: great job on the toolbox, it's a really useful tool for understanding problems and making quick progress through simulations!
I wanted to ask if there is an easy way to incorporate multiple robots into the EKF-SLAM simulation. I edited a few things, so in the implementation I have, I initialise the extra robots the following way:
r2 = Bicycle(covar=V_r2, x0=(1, 4, np.deg2rad(45)), animation="car")
r2.control = RandomPath(workspace=lm_map,seed=robot.control._seed+1)
r2.init()
robots = [r2]
and then add it to the class as a list property: self._robots = r2
in the run_animation function, I tried to add r._animation.update(r.x) for r in self.robots
but I do not get any robot shown.
I suspect this to be something to do with the lines 155 to 162 in Vehicle Marker Animations, see link:
def _update(self, x):
self._object.set_xdata(x[0])
self._object.set_ydata(x[1])
def _add(self, x=None, **kwargs):
if x is None:
x = (0, 0)
self._object = plt.plot(x[0], x[1], **{**self._args, **kwargs})[0]
That I am somehow unable to add it to the same plot, because the object is set differently.
Any ideas on a quick / hot fix?
I would really appreciate any recommendations and ideas how to get multiple robots into the same animation
Keep up the great work, this is already a major toolbox and use!
Kind regards
Nico
Fixed. put
r_polys = []
for r in self.robots:
r_poly = VehiclePolygon(scale=0.5, color="red")
r_poly.add()
r_polys.append(r_poly)
self.__r_polys = r_polys
into the init for the animation() function and then
for j, r in enumerate(self.robots):
self.__r_polys[j].update(r.x)
into the animate(i) function
Fixed. put
r_polys = []
for r in self.robots:
r_poly = VehiclePolygon(scale=0.5, color="red")
r_poly.add()
r_polys.append(r_poly)
self.__r_polys = r_polys
into the init for the animation() function and then
for j, r in enumerate(self.robots):
self.__r_polys[j].update(r.x)
into the animate(i) function