[Dprglist] Need help with getting a map of the house using RPLidarwith RPi
Thalanayar Muthukumar
tnkumar at gmail.com
Sun Nov 21 11:17:47 PST 2021
Thanks Chris for sharing your experiences.
https://www.youtube.com/watch?v=qT5PWlmwydc (~30 secs) - RPLidar mounted on
my robot
It is ready to move around the house
"you need to take the robot’s actual current pose (x, y, theta) into
account" - need to figure out how to do this
On Sun, Nov 21, 2021 at 12:52 PM Chris N <netterchris at gmail.com> wrote:
> Kumar,
>
>
>
> What you are looking for is called an “occupancy grid map”. There are
> other types of maps, but the occupancy grid map is conceptually the easiest
> one to understand and work with I believe.
>
>
>
> Conceptually, its straight forward how it is created. This type of map is
> really no different from an image – every pixel corresponds to, for
> example, one square inch of space, and the pixel values correspond to
> definitely empty (black), definitely something there (white), unsure
> (grey).
>
>
>
> In a way, it is just an extension of the real-time display code that you
> have running. The key differences between real-time display of lidar data
> and using this data to build a map are:
>
>
>
> 1. For map making, you need to take the robot’s actual current pose
> (x, y, theta) into account. (For real-time display, you essentially
> pretend your robot is always at x,y=0,0 and orientation= 0 degrees)
> 2. For map making, you remember the point that is drawn into the map,
> instead of starting with a clean canvas every cycle
> 3. For map making, the size of your map needs to be larger than the
> range of your Lidar, otherwise it won’t be of much use.
>
>
>
> You have 3 options:
>
>
>
> 1. Create the algorithm more or less completely from scratch or adapt
> some sample code that seems to be easy enough to work with. I’m sure
> such sample code for python and C++ is out there…. Quick google search
> found this python code for example: An occupancy grid mapping example
> · GitHub
> <https://gist.github.com/superjax/33151f018407244cb61402e094099c1d>.
> It says “# This is an implementation of Occupancy Grid Mapping as
> Presented in Chapter 9 of "Probabilistic Robotics" By Sebastian Thrun et
> al. In particular, this is an implementation of Table 9.1 and 9.2”
>
> 2. Find a library that contains the necessary building blocks. Maybe
> all you need is a ready to use grid map data structure along with an API
> for putting things into that grid map. Or maybe the library also provides
> functions that take care of all the processing of the laser scan data.
> Etc, etc. Then figure out how to use this library. MRPT comes to
> mind but there are probably others. MRPT – Empowering C++
> development in robotics <https://www.mrpt.org/>. OpenSLAM.org
> (openslam-org.github.io) <https://openslam-org.github.io/> is also a
> possible resource.
>
> 3. Use ROS and pick one of the mapping algorithms that are available,
> such as
> 1. Gmapping
> 2. Google cartographer
> 3. etc
>
>
>
>
>
> I have gone down road # 1 and road # 2 some 5+ years ago, but I did not
> reach my destination ☹ I probably didn’t try hard enough…..
>
>
>
> I have also started going down road #3 on more than one occasion, but find
> my self often going in circles and not getting anywhere ☹
>
>
>
> I find that no matter which road you take, it requires a substantial time
> commitment to fully master the underlying technologies. I find that
> unless I’m at it every day, I start to forget things I’ve learned….
>
>
>
>
>
> Chris.
>
>
>
>
>
>
>
> *From: *Thalanayar Muthukumar via DPRGlist <dprglist at lists.dprg.org>
> *Sent: *Sunday, November 21, 2021 12:36 PM
> *To: *DPRG <dprglist at lists.dprg.org>
> *Subject: *[Dprglist] Need help with getting a map of the house using
> RPLidarwith RPi
>
>
>
> https://learn.adafruit.com/slamtec-rplidar-on-pi/cpython-on-raspberry-pi - The
> relevant code is below
>
> def process_data(data):
>
> global max_distance
>
> lcd.fill((0,0,0))
>
> for angle in range(360):
>
> distance = data[angle]
>
> if distance > 0: # ignore initially ungathered data points
>
> max_distance = max([min([5000, distance]), max_distance])
>
> radians = angle * pi / 180.0
>
> x = distance * cos(radians)
>
> y = distance * sin(radians)
>
> point = (160 + int(x / max_distance * 119), 120 + int(y / max_distance * 119))
>
> lcd.set_at(point, pygame.Color(255, 255, 255))
>
> pygame.display.update()
>
> This code is used to update the TFT display and is working for me.
> Instantaneously, the RPLidar's surroundings are displayed on the TFT
> display. I would like to adapt this to move the RPLidar through the rooms
> of the house to create a map. @Chris - Any suggestions or pointers? I do
> not have ROS installed. Regards. - Kumar
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20211121/a06bc363/attachment.html>
More information about the DPRGlist
mailing list