Montecarlo Visual Loc Fixes
Montecarlo Visual Loc Fixes
This week I solved some issues with the Montecarlo Visual Loc exercise I updated the last 2 weeks as well as adding another function for the user.
First issue
The first issue was that the frontend from the exercide didn’t load correctly, on the terminal, it printed a bunch of errors in regards to loading the frontend components of the exercise. To solve this, I had to update the template of the exercise in the Robotics Academy repository, in exercises/templates/exercises. The only changes needed was changing the name of the exercise directory here, so it matches the name in exercises/static/exercises (from montecarlo_visual_loc_newmanager to montecarlo_visual_loc) and deleting an old montecarlo_visual_loc directory here with an outdated file that wasn’t being used.
Second issue
The second issue was that the function GUI.showImage() didn’t work properly, when used in the exercise, it didn’t show any image in the frontend. To solve this I had to add an extra line when adding the image to the payload that will be sent to the frontend.
1
self.payload["image"] = json.dumps(payload_image)
Specifically the json.dumps() part, before this, it was just self.payload["image"] = payload_image
so the image wasn’t being sent properly. After this I had to remake the frontend of the exercise (the files in exercises/static/exercises/montecarlo_visual_loc/react-components) to update some of the functionality (like having a roomba image to show your position on the map) and add an extra window next to the map where the image from the robot will be shown when GUI.showImage() is used. I followed the structure of the react-components in montecarlo_laser_loc since these two are very similar plus adding the show image functionality following the structure of other exercises with similar methods.
After that I implemented the showPosition function in the GUI.py file of the exercise since it could be useful for the user. This function was also already implemented in the Montecarlo Laser Loc exercise.
Later, one of my peers also added in the frontend part an extra functionality to show the weight of the particles when using the showParticles function, which means the user have to add a weight argument to their particles when using this function.