Map generation method and device, electronic equipment and computer program product
By obtaining map generation parameters and updating the grid cell state of the 2D map, the target 2D map is generated. This solves the problem of low efficiency in traditional methods, realizes efficient and diverse map generation, and improves the adaptability of navigation algorithms.
Patent Information
- Application Number
- CN202511574847.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-02-13
AI Technical Summary
Traditional simulator-based map generation methods require manually building 3D models and configuring physical parameters, rely on real-time simulation interaction, are inefficient, and cannot meet the diverse data needs of the training process.
By acquiring map generation parameters, including preset obstacle probabilities and preset number of attempts, the grid cell state in the 2D map is updated, connected components are determined and connected components with areas less than a threshold are corrected, and the target 2D map is generated, avoiding 3D models and physical simulations.
Providing diverse maps within a limited time improves the efficiency and diversity of map generation and enhances the environmental generalization ability of navigation algorithms.
Smart Images

Figure CN121521087A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of intelligent driving technology, and in particular relates to a map generation method, device, electronic device and computer program product. Background Technology
[0002] For autonomous vehicles, robots, and other devices capable of moving independently, navigation algorithms are typically trained using maps to ensure safety. Traditionally, the training maps are generated by simulators. Traditional simulator-based map generation methods require manually constructing 3D models and configuring physical parameters, relying on real-time simulation interaction, 3D model rendering, and physical simulation, resulting in low efficiency and difficulty in meeting the diverse data requirements of the training process. Summary of the Invention
[0003] This application provides a map generation method, apparatus, electronic device, and computer program product that can provide a variety of maps within a limited time.
[0004] The first aspect of this application provides a map generation method, comprising: acquiring map generation parameters, the map generation parameters including a preset obstacle probability and a preset number of times; acquiring a two-dimensional map to be processed according to the preset obstacle probability, wherein the state of each grid cell in the two-dimensional map to be processed is an obstacle state or a passable state; performing the preset number of state updates on each grid cell, wherein each state update updates the state of the corresponding grid cell according to the number of grid cells with obstacle states in the neighboring grid cells of each grid cell; for each grid cell with a passable state, determining the corresponding connected component, and correcting the state of each grid cell in the connected component with an area less than an area threshold to an obstacle state, thereby obtaining a target two-dimensional map.
[0005] In some embodiments of the first aspect, the map generation parameters further include map size; obtaining the two-dimensional map to be processed according to the preset obstacle probability includes: generating an initial two-dimensional map according to the map size, wherein each grid cell in the initial two-dimensional map is in a passable state; traversing each grid cell in the initial two-dimensional map, if the corresponding random number is less than the preset obstacle probability, updating the state of the corresponding grid cell to a passable state, thereby obtaining the two-dimensional map to be processed.
[0006] In some embodiments of the first aspect, the map generation parameters further include boundary states; after obtaining the two-dimensional map to be processed according to the preset obstacle probabilities, the method further includes: if the boundary state is in an open state, then updating the boundary grid cells of the two-dimensional map to be processed to the obstacle state.
[0007] In some embodiments of the first aspect, after obtaining the target two-dimensional map, the method further includes: if the boundary state is an open state, updating the boundary grid cells of the target two-dimensional map to an obstacle state.
[0008] In some embodiments of the first aspect, the map generation parameters include a first threshold and a second threshold; each state update includes: determining the number of obstacle state cells in the neighborhood cells of each grid cell; for a grid cell with an obstacle state, if the number of obstacle state cells in the corresponding neighborhood cells is less than the first threshold, then the state of the corresponding grid cell is updated to a passable state; for a grid cell with a passable state, if the number of obstacle state cells in the corresponding neighborhood cells is greater than the second threshold, then the state of the corresponding grid cell is updated to an obstacle state.
[0009] In some embodiments of the first aspect, the map generation parameters further include a correction state, which is used to confirm whether the grid cell needs to be corrected; after performing the preset number of state updates on each grid cell, and updating the state of the corresponding grid cell according to the number of obstacle states in the neighboring cells of each grid cell during each state update, the method further includes: if the correction state is off, then the map with the updated state is used as the target two-dimensional map.
[0010] In some embodiments of the first aspect, the map generation method further includes: training a robot navigation algorithm based on a plurality of target two-dimensional maps corresponding one-to-one with a plurality of sets of map generation parameters.
[0011] A map generation apparatus provided in a second aspect of this application includes: a parameter acquisition unit for acquiring map generation parameters, the map generation parameters including a preset obstacle probability and a preset number of times; a map generation unit for acquiring a two-dimensional map to be processed based on the preset obstacle probability, wherein the state of each grid cell in the two-dimensional map to be processed is an obstacle state or a passable state; a grid cell update unit for updating the state of each grid cell the preset number of times, wherein each state update updates the state of the corresponding grid cell based on the number of grid cells with obstacle states in their neighboring grid cells; and a correction unit for determining the corresponding connected component for each passable grid cell, and updating the state of each grid cell in the connected component with an area less than an area threshold to an obstacle state, thereby obtaining a target two-dimensional map.
[0012] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor; the processor executes the computer program to implement the steps of the map generation method described above.
[0013] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the map generation method described above.
[0014] The fifth aspect of this application provides a computer program product that, when run, causes the map generation method described above to be executed.
[0015] In the embodiments of this application, by obtaining map generation parameters and based on the preset obstacle probabilities in the map generation parameters, a two-dimensional map to be processed is obtained. Each grid cell in the two-dimensional map to be processed is updated a preset number of times. During each state update, the state of the corresponding grid cell is updated according to the number of obstacle states in the neighboring cells of each grid cell. For each grid cell with a passable state, the corresponding connected component is determined, and the state of each grid cell in the connected component with an area less than the area threshold is corrected to an obstacle state to obtain the target two-dimensional map. Thus, different two-dimensional maps can be obtained by updating the map generation parameters without the need for three-dimensional models and physical simulations, which helps to provide diverse maps within a limited time. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram illustrating the implementation process of a map generation method provided in an embodiment of this application;
[0018] Figure 2 This is a schematic diagram illustrating the specific implementation process of the map generation method provided in the embodiments of this application;
[0019] Figure 3 This is a schematic diagram of the target two-dimensional map provided in the embodiments of this application;
[0020] Figure 4 This is a schematic diagram of the structure of a map generation device provided in an embodiment of this application;
[0021] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are protected by this application.
[0023] For autonomous vehicles, robots, and other devices capable of moving independently, navigation algorithms are typically trained using maps to ensure safety. Traditionally, the training maps are generated by simulators. Traditional simulator-based map generation methods require manually constructing 3D models and configuring physical parameters, relying on real-time simulation interaction, 3D model rendering, and physical simulation, resulting in low efficiency and difficulty in meeting the diverse data requirements of the training process.
[0024] In view of this, this application proposes a map generation method that can obtain different two-dimensional maps by updating map generation parameters without the need for three-dimensional models and physical simulations, which helps to provide diverse maps within a limited time.
[0025] To illustrate the technical solution of this application, specific embodiments are described below.
[0026] Figure 1 This illustration shows a schematic diagram of the implementation process of a map generation method provided in an embodiment of this application. This method can be applied to electronic devices. The aforementioned electronic devices can refer to intelligent devices such as computers and smartphones, or devices with autonomous mobility capabilities such as unmanned vehicles and robots; this application does not impose any limitations on this.
[0027] Specifically, the above map generation method may include the following steps S101 to S104.
[0028] Step S101: Obtain map generation parameters.
[0029] In the embodiments of this application, map generation parameters characterize the parameters required during the map generation process, including a preset obstacle probability and a preset number of times. The preset obstacle probability indicates the likelihood that a certain cell in the map is occupied by an obstacle. The preset number of times indicates the number of times the map's state is updated.
[0030] Step S102: Obtain the two-dimensional map to be processed based on the preset obstacle probability.
[0031] Specifically, based on preset obstacle probabilities, the state of each grid cell within the 2D map can be determined to generate a 2D map to be processed. The 2D map to be processed is the initial map after assigning states to each grid cell. The states of each grid cell in the 2D map to be processed are either obstacle states or passable states. An obstacle state, also called an occupied state, indicates that the corresponding grid cell is impassable. A passable state indicates that the corresponding grid cell can be passed by the robot.
[0032] Step S103: Perform a preset number of state updates for each grid cell. During each state update, update the state of the corresponding grid cell based on the number of obstacle states in the neighboring cells of each grid cell.
[0033] In the embodiments of this application, a preset number of state updates can be performed on each grid cell. Specifically, each grid cell can be sequentially updated for the first time until all grid cells have completed their first update. Then, each grid cell can be sequentially updated for the second time, and so on, until the preset number of state updates for each grid cell has been completed.
[0034] During each state update, the state of the corresponding grid cell can be updated based on the number of obstacle states in its neighboring cells. The neighboring cells of each grid cell can refer to the grid cells surrounding it, for example, the 8-neighborhood. By calculating the number of obstacle states in the neighboring cells of each grid cell, the state of the corresponding grid cell can be updated. In this way, state updates can be performed on the grid cells in the 2D map being processed, resulting in diverse map formats.
[0035] Step S104: For each passable grid cell, determine the corresponding connected component, and correct the state of each grid cell in the connected component with an area less than the area threshold to the obstacle state to obtain the target two-dimensional map.
[0036] In the embodiments of this application, for each passable grid cell, adjacent passable grid cells can be connected to form a connected domain. By calculating the area of each connected domain, the state of each grid cell within a connected domain with an area less than a threshold is corrected to an obstacle state, thereby correcting grid cells within isolated connected domains to an obstacle state, resulting in a target two-dimensional map. The target two-dimensional map is a two-dimensional map generated using the map generation method provided in this application.
[0037] In the embodiments of this application, by obtaining map generation parameters and based on the preset obstacle probabilities in the map generation parameters, a two-dimensional map to be processed is obtained. Each grid cell in the two-dimensional map to be processed is updated a preset number of times. During each state update, the state of the corresponding grid cell is updated according to the number of obstacle states in the neighboring cells of each grid cell. For each grid cell with a passable state, the corresponding connected component is determined, and the state of each grid cell in the connected component with an area less than the area threshold is corrected to an obstacle state to obtain the target two-dimensional map. Thus, different two-dimensional maps can be obtained by updating the map generation parameters without the need for three-dimensional models and physical simulations, which helps to provide diverse maps within a limited time.
[0038] In some embodiments of this application, the map generation parameters may further include map size. Obtaining the two-dimensional map to be processed based on a preset obstacle probability may include: generating an initial two-dimensional map based on the map size; traversing each grid cell in the initial two-dimensional map; if the corresponding random number is less than the preset obstacle probability, updating the state of the corresponding grid cell to a passable state to obtain the two-dimensional map to be processed.
[0039] In the initial 2D map, each grid cell is in a passable state. Then, a random number is assigned to each grid cell, and this random number is compared to a preset obstacle probability. If the random number is less than the preset obstacle probability, the grid cell's state is updated from obstacle state to passable state. If the random number is greater than or equal to the preset obstacle probability, the passable state of the grid cell is maintained.
[0040] For details, please refer to Figure 2 Initialize an initial 2D map with a size of height × width, and set the state of each grid cell in the initial 2D map to 0 (indicating a passable state). Randomly set the state of some grid cells to 1 (indicating an obstacle state) according to the preset obstacle probability initial_wall_prob: Traverse each grid cell (r, c), if the random number is less than the preset obstacle probability initial_wall_prob, update it to an obstacle state, grid[r][c] = 1, otherwise keep it passable, until all grid cells have been traversed.
[0041] In some embodiments of this application, the map generation parameters may further include boundary states. After obtaining the two-dimensional map to be processed according to a preset obstacle probability, the method may further include: if the boundary state is in an open state, updating the boundary grid cells of the two-dimensional map to be processed to the obstacle state.
[0042] Specifically, if the boundary state add_outer_wall = true, it means that the boundary state is open. Then the boundary grid cells of the two-dimensional map to be processed can be updated to the obstacle state: set the upper boundary grid[0][:] = 1, the lower boundary grid[height-1][:] = 1, the left boundary grid[:][0] = 1, and the right boundary grid[:][width-1] = 1 to form a closed boundary. Thus, the boundary state add_outer_wall can be used to flexibly set whether the outer boundary of the map is an obstacle, adapting to different scenario requirements (such as indoor closed environment or open area).
[0043] Correspondingly, if the boundary state is closed, the original state of the boundary grid cells of the two-dimensional map to be processed can be maintained.
[0044] In some embodiments of this application, the map generation parameters may include a first threshold and a second threshold. The first threshold is a threshold representing the number of neighboring cells with obstacle states when a grid cell with an obstacle state needs a state update. The second threshold is a threshold representing the number of neighboring cells with obstacle states when a grid cell with a passable state needs a state update.
[0045] Each state update may include: determining the number of neighboring cells with obstacle states in each grid cell. For a grid cell with an obstacle state, if the number of neighboring cells with obstacle states is less than a first threshold, the state of the corresponding grid cell is updated to passable; for a grid cell with a passable state, if the number of neighboring cells with obstacle states is greater than a second threshold, the state of the corresponding grid cell is updated to obstacle state.
[0046] For details, please refer to Figure 2 During each iteration update, for a single grid, a new grid `new_grid` is generated. All non-boundary grid cells are traversed, and the number of grid cells with obstacle states within the 8-neighborhood of the current grid cell (r, c) (the neighborhood range is r-1 to r+1, c-1 to c+1, excluding the current grid cell) is counted. This count yields the number of obstacle-state cells in the neighborhood, `wall_count`. It should be noted that grid cell coordinates outside the boundary are considered obstacle states, which enhances the reasonableness of obstacle generation in boundary areas.
[0047] If the current grid cell is in an obstacle state (grid[r][c] = 1): when wall_count < the first threshold death_limit, the grid cell is updated to a passable state (new_grid[r][c] = 0); otherwise, the obstacle state is maintained (new_grid[r][c] = 1).
[0048] If the current grid cell is in a passable state (grid[r][c] = 0): when wall_count > the second threshold birth_limit, the state of the grid cell is updated to an obstacle state (new_grid[r][c] = 1); otherwise, it remains in a passable state (new_grid[r][c] = 0).
[0049] After the iteration is complete, the state of the new grid new_grid is assigned to the original grid, completing a single update.
[0050] Thus, the maps generated through random initialization and automatic state updates have a high degree of diversity that closely matches real-world navigation scenarios, effectively enhancing the environmental generalization ability of navigation algorithms.
[0051] In some embodiments of this application, the map generation parameters may also include a correction state, which is used to determine whether grid cells need to be corrected.
[0052] If the correction state is enabled, the state of each grid cell in the connected domain with an area smaller than the area threshold can be corrected to the obstacle state according to the aforementioned step S104, thereby obtaining the target two-dimensional map.
[0053] For details, please refer to Figure 2 If the modified state `ensure_connectivity = true`, it indicates that the modified state is enabled. A breadth-first search (BFS) algorithm can be used to traverse all walkable grid cells (grid[r][c] = 0), extracting all connected components and recording the coordinate set and size of each component. Then, the largest connected component (i.e., the largest connected region) is retained, and the state of the grid cells of other connected components is set to 1 (obstacle state). This eliminates isolated areas and ensures the navigation usability of the generated map.
[0054] In some embodiments of this application, after obtaining the target two-dimensional map, the method may further include: if the boundary state is open, updating the boundary grid cells of the target two-dimensional map to the obstacle state.
[0055] In some other embodiments of this application, a preset number of state updates are performed on each grid cell. Each time a state update is performed, the state of the corresponding grid cell is updated based on the number of obstacle states in the neighboring cells of each grid cell. The process may further include: if the corrected state is a closed state, then the updated map is used as the target two-dimensional map. That is, the map obtained in step S103 is used as the target two-dimensional map.
[0056] It should be noted that this application can train the robot navigation algorithm based on multiple target 2D maps with corresponding parameters generated from multiple sets of maps. Specifically, at least one parameter in the generation parameters of different sets of maps is different, such as different preset obstacle probabilities or different preset number of attempts, thereby generating different target 2D maps. Training the robot navigation algorithm based on different target 2D maps allows the robot navigation algorithm to adapt to different environments, improving safety.
[0057] To balance map complexity, generation efficiency, and navigation usability, the multiple sets of map generation parameters can be set within the following range:
[0058] The preset obstacle probability initial_wall_prob is 0.2-0.4 (0.3 is recommended). This can balance the ratio of grid cells in the obstacle state to grid cells in the passable state, and avoid the excessive sparseness or density of certain types of grid cells.
[0059] The first threshold, death_limit, is 3-5 (4 is recommended) to prevent the grid cells of the obstacle state from dissipating excessively due to insufficient neighboring cells of the obstacle state, thus maintaining the stability of the obstacle structure.
[0060] The second threshold, birth_limit, is 3-5 (4 is recommended) to prevent passable areas from being excessively converted into obstacles due to too many neighboring units of the obstacle state, thus preserving sufficient navigation space.
[0061] The preset number of iterations (num_steps) is 3-5 (4 is recommended), which can balance map complexity (avoiding insufficient iterations leading to a simple structure) and computational efficiency (avoiding excessive iterations increasing time consumption).
[0062] Taking a map with width=100, height=100, preset obstacle probability_wall_prob=0.5, first threshold death_limit=4, second threshold birth_limit=4, preset number of steps num_steps=4, correction state ensure_connectivity=true, and boundary state add_outer_wall=true as an example, the resulting target 2D map is as follows: Figure 3 As shown, obstacles account for approximately 45%-55% of the target 2D map, consistent with typical obstacle density in indoor navigation environments. The maximum connected component percentage is ≥90% (isolated traversable areas ≤10%), effectively reducing invalid interaction samples during training. The actual generation time is ≤1.5 seconds, an improvement of over 99% compared to traditional simulators (hours). Furthermore, the generated target 2D map can be directly used for navigation training of wheeled robots, for example... Figure 3 The curves of different colors (Trajectory1 to Trajectory20) show the different motion trajectories of the robot on the target 2D map, which meets the requirements of reinforcement learning for large-scale and diverse environments.
[0063] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because based on this application, some steps can be performed in other orders.
[0064] like Figure 4 The diagram shown is a schematic diagram of a map generation device 400 provided in an embodiment of this application. The map generation device 400 is configured on an electronic device.
[0065] Specifically, the map generation device 400 may include:
[0066] The parameter acquisition unit 401 is used to acquire map generation parameters, including preset obstacle probability and preset number of times;
[0067] The map generation unit 402 is used to obtain a two-dimensional map to be processed based on the preset obstacle probability, wherein the state of each grid cell in the two-dimensional map to be processed is an obstacle state or a passable state.
[0068] The grid cell update unit 403 is used to update the state of each grid cell a preset number of times. Each time the state is updated, the state of the corresponding grid cell is updated according to the number of obstacle states in the neighboring cells of each grid cell.
[0069] The correction unit 404 is used to determine the corresponding connected component for each passable grid cell, and update the state of each grid cell in the connected component with an area less than the area threshold to the obstacle state, so as to obtain the target two-dimensional map.
[0070] In some embodiments of this application, the map generation parameters further include map size; the map generation unit 402 can be used to: generate an initial two-dimensional map according to the map size, wherein each grid cell in the initial two-dimensional map is in a passable state; traverse each grid cell in the initial two-dimensional map, and if the corresponding random number is less than the preset obstacle probability, update the state of the corresponding grid cell to a passable state to obtain the two-dimensional map to be processed.
[0071] In some embodiments of this application, the map generation parameters also include boundary states; the map generation unit 402 can be used to update the boundary grid cells of the two-dimensional map to be processed to obstacle states if the boundary state is in an open state.
[0072] In some embodiments of this application, the correction unit 404 may also be used to: update the boundary grid cells of the target two-dimensional map to the obstacle state if the boundary state is an open state.
[0073] In some embodiments of this application, the map generation parameters include a first threshold and a second threshold; the grid cell update unit 403 can be used to: determine the number of cells with obstacle states in the neighboring cells of each grid cell; for a grid cell with an obstacle state, if the number of cells with obstacle states in the corresponding neighboring cells is less than the first threshold, then the state of the corresponding grid cell is updated to a passable state; for a grid cell with a passable state, if the number of cells with obstacle states in the corresponding neighboring cells is greater than the second threshold, then the state of the corresponding grid cell is updated to an obstacle state.
[0074] In some embodiments of this application, the grid cell update unit 403 may also be used to: if the correction state is a closed state, then use the updated map as the target two-dimensional map.
[0075] In some embodiments of this application, the map generation device 400 further includes a training unit, which can be used to train a robot navigation algorithm based on multiple target two-dimensional maps that correspond one-to-one with multiple sets of map generation parameters.
[0076] It should be noted that, for the sake of convenience and brevity, the specific working process of the map generation device 400 described above can be found in the following reference: Figures 1 to 3 The corresponding process of the method will not be described in detail here.
[0077] like Figure 5The diagram shown is a schematic representation of an electronic device provided in an embodiment of this application. Specifically, the electronic device 5 may include: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50, such as a map generation program. When the processor 50 executes the computer program 52, it implements the steps in the various map generation method embodiments described above, for example... Figure 1 Steps S101 to S104 are shown. Alternatively, when the processor 50 executes the computer program 52, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 4 The functions of the parameter acquisition unit 401, map generation unit 402, grid unit update unit 403, and correction unit 404 are shown.
[0078] The computer program can be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to complete this application. The one or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0079] For example, the computer program can be divided into: a parameter acquisition unit, a map generation unit, a grid cell update unit, and a correction unit. The specific functions of each unit are as follows: The parameter acquisition unit acquires map generation parameters, including a preset obstacle probability and a preset number of times; the map generation unit acquires a two-dimensional map to be processed based on the preset obstacle probability, wherein the state of each grid cell in the two-dimensional map to be processed is either an obstacle state or a passable state; the grid cell update unit updates the state of each grid cell the preset number of times, updating the state of the corresponding grid cell based on the number of obstacle-state cells in its neighboring cells during each update; the correction unit determines the corresponding connected component for each passable grid cell and updates the state of each grid cell within the connected component with an area less than an area threshold to an obstacle state, thus obtaining the target two-dimensional map.
[0080] The electronic device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will understand that... Figure 5 This is merely an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0081] The processor 50 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0082] The memory 51 can be an internal storage unit of the electronic device, such as a hard drive or memory. The memory 51 can also be an external storage device of the electronic device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 51 can include both internal and external storage units. The memory 51 is used to store the computer program and other programs and data required by the electronic device. The memory 51 can also be used to temporarily store data that has been output or will be output.
[0083] It should be noted that, for the sake of convenience and brevity, the structure of the above-mentioned electronic device can also be referred to the specific description of the structure in the method embodiment, which will not be repeated here.
[0084] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0085] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0086] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for various specific applications, but such implementations should not be considered beyond the scope of this application.
[0087] In the embodiments provided in this application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0088] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected based on actual needs to achieve the purpose of this embodiment.
[0089] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0090] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0091] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A map generation method, characterized in that, include: Obtain map generation parameters, including preset obstacle probabilities and preset number of attempts; Based on the preset obstacle probability, a two-dimensional map to be processed is obtained, and the state of each grid cell in the two-dimensional map to be processed is either an obstacle state or a passable state. The state of each grid cell is updated a preset number of times. During each state update, the state of the corresponding grid cell is updated according to the number of obstacle states in the neighboring cells of each grid cell. For each passable grid cell, the corresponding connected component is determined, and the state of each grid cell in the connected component with an area less than the area threshold is corrected to the obstacle state to obtain the target two-dimensional map.
2. The map generation method as described in claim 1, characterized in that, The map generation parameters also include map size; obtaining the two-dimensional map to be processed based on the preset obstacle probability includes: An initial two-dimensional map is generated based on the map dimensions, and each grid cell in the initial two-dimensional map is in a passable state. Traverse each grid cell in the initial two-dimensional map. If the corresponding random number is less than the preset obstacle probability, update the state of the corresponding grid cell to passable state to obtain the two-dimensional map to be processed.
3. The map generation method as described in claim 1, characterized in that, The map generation parameters also include boundary states; after obtaining the two-dimensional map to be processed based on the preset obstacle probabilities, the parameters further include: If the boundary state is open, the boundary grid cells of the two-dimensional map to be processed are updated to the obstacle state.
4. The map generation method as described in claim 3, characterized in that, After obtaining the target two-dimensional map, the process also includes: If the boundary state is open, the boundary grid cells of the target 2D map are updated to the obstacle state.
5. The map generation method as described in claim 1, characterized in that, The map generation parameters include a first threshold and a second threshold; Each status update includes: Determine the number of cells in the neighborhood of each grid cell that contain obstacle states; For a grid cell with an obstacle state, if the number of grid cells with obstacle states in the corresponding neighborhood cells is less than the first threshold, then the state of the corresponding grid cell is updated to passable state. For a passable grid cell, if the number of neighboring cells with obstacle states is greater than the second threshold, the state of the corresponding grid cell is updated to the obstacle state.
6. The map generation method as described in claim 1, characterized in that, The map generation parameters also include a correction status, which is used to confirm whether the grid cell needs to be corrected; The process of performing the preset number of state updates on each grid cell, and updating the state of the corresponding grid cell based on the number of obstacle states in its neighboring cells during each state update, further includes: If the correction status is off, the updated map will be used as the target 2D map.
7. The map generation method as described in claim 1, characterized in that, The map generation method further includes: The robot navigation algorithm is trained based on multiple target 2D maps that correspond one-to-one with the multiple sets of map generation parameters.
8. A map generation device, characterized in that, include: A parameter acquisition unit is used to acquire map generation parameters, including preset obstacle probabilities and preset number of times; The map generation unit is used to obtain a two-dimensional map to be processed based on the preset obstacle probability, wherein the state of each grid cell in the two-dimensional map to be processed is an obstacle state or a passable state. The grid cell update unit is used to update the state of each grid cell a preset number of times. Each time the state is updated, the state of the corresponding grid cell is updated according to the number of obstacle states in the neighboring cells of each grid cell. The correction unit is used to determine the corresponding connected component for each passable grid cell, and update the state of each grid cell in the connected component with an area less than the area threshold to the obstacle state, thereby obtaining the target two-dimensional map.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the map generation method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program, which, when run, causes the map generation method as described in any one of claims 1 to 7 to be performed.