Package: autonavsim2D
AutoNavSim2DThis project provides a 2D simulation environment designed for the development and testing of path planning algorithms. It offers a flexible and interactive platform for researchers, developers, and hobbyists to experiment with various path planning strategies in a controlled virtual space.This project is being maintained byClinton Anani.Table of ContentsInstallationUsageFeaturesDemoConfigurationRequirementsCustom PlannerContributingLicenseAcknowledgmentsContactInstallationFollow these steps to install and set up the simulation environment on your system:pipinstallautonavsim2DUsageTo use the simulation environment for basic path planning and navigation with the default Djikstra algorithm path planner, create amain.pyfile, and import the package:fromautonavsim2d.autonavsim2dimportAutoNavSim2Dnav=AutoNavSim2D(custom_planner='default',custom_motion_planner='default',window='amr')nav.run()To use the GUI, there are three steps involved to set the robot up, set a goal location, and generate obstacles:The first left-click is to place the robot in any location of your choosing. You can clickresetto clear the map.The second left-click sets your goal location. The cell you left-click on as your goal location will be green. To remove that location, right-click on the cell.And lastly, to create obstacles (colored black), left-click on anywhere on the map and drag, after setting the robot and choosing your goal location. To remove an obstacle from the map, simply right-click on it.These steps must be followed one after the other in order to set the robot, set your goal location, and create obstacles. Check out the video below for a demo:https://github.com/yendiDev/autonavsim2d/assets/57093800/6d96191d-1a85-4c3a-a542-0d29c1232b96ConfigurationAutoNavSim2D can be customized in numerous ways. To launch the simulation environment with a starting page, set thewindowparameter todefault:nav=AutoNavSim2D(custom_planner='default',custom_motion_planner='default',window='default')To launch the simulation environment in map mode where you can begin visualization, set thewindowparameter toamr:nav=AutoNavSim2D(custom_planner='default',custom_motion_planner='default',window='amr')FeaturesCurrently, AutoNavSim2D has the following features:2D path planningReactive autonomous navigationDynamic map generationSupport for custom graph-based path planning algorithms such asA*,DjiktraorD*DemoSee a video demo of the simulation environment in actionhereor check out the screenshots below:RequirementsAutoNavSim2D is designed to be lightweight and memory efficient, so no dedicated hardware is required to run it. It is built on the pygame python package. To install pygame:pipinstallpygameCustom PlannerWriting your own path planning algorithm to be used in AutoNavSim2D is really simple. First, the map (1147x872) is represented as shown below:Next the 2D matrix representation of the map, where 1 represents a free path and 0 represents an obstable is shown below. You will receive this matrix when writing your custom planner:[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],...[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]To use your custom path planner in AutoNavSim2D, write it in a function or class, return the optimal path as well as the time taken to calculate the path, and set it to thecustom_plannerparameter as seen below:fromautonavsim2dimportAutoNavSim2Ddefmy_planner(grid,matrix,start_loc,goal_loc):# your own custom path planning algorithm herepath=[]runtime=''return(path,runtime)nav=AutoNavSim2D(custom_planner=my_planner,custom_motion_planner='default',window='amr')nav.run()Also, to use your custom motion planner or waypoint generator in AutoNavSim2D, write it in a function or class, return the appropriate set of waypoints in a list, and set it to thecustom_motion_plannerparameter as seen below:fromautonavsim2dimportAutoNavSim2Dfromutils.poseimportPose,Point,Orientationfromutils.pose_stampedimportPoseStamped,Headerdefcustom_motion_planner(grid,path,start,end):# write your custom algorithm to generate waypoints hererobot_pose=Nonewaypoints=[]# 1. ROBOT POSE# Robot pose must be a PoseStamp containing the robot's current location:# start_cell = start[0]# rect_x = start_cell.x# rect_y = start_cell.y# rect_center_x = rect_x + start_cell.width // 2# rect_center_y = rect_y + start_cell.height // 2# robot_position = Point(x=rect_center_x, y=rect_center_y, z=0)# robot_orientation = Orientation(0, 0, 0, math.pi/2)# robot_pose = Pose(position=robot_position, orientation=robot_orientation)# 2. NAVIGATION WAYPOINTS# Each element inside the waypoints list must return a PoseStamp:# waypoint = PoseStamp(header=Header(...), pose=Pose(...))# Where the elements of the PoseStamp include:# Point(x, y, z=0)# Orientation(x=0, y=0, z=0, w=theta)# Pose(position=Point(...), orientation=Orientation(...))# Header(stamp='0', frame_id='')return(robot_pose,waypoints)nav=AutoNavSim2D(custom_planner='default',custom_motion_planner=custom_motion_planner,window='amr')nav.run()ContributingTo contribute, please email me atkceequan01@gmail.com. We welcome contributions from the community!LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.AcknowledgmentsAutoNavSim was built onPygame. Thank you to the Pygame community for making this available :)ContactFor inquiries or feedback, feel free to reach out:Email:kceequan01@gmail.comTwitter:https://twitter.com/oxncgenLinkedin:https://www.linkedin.com/in/clinton-anani-56a125196/