Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Nibato

Navigation api

Recommended Posts

I wrote a simple robot navigation API/library for my own personal use, and figured someone else might be able to make use of it.

I spent a good hour documenting all the code so hopefully it isn't too hard to figure out. Unfortunately though, I'm not the best at explaining things :P

If you have any issues with it, just yell at me and I'll take a look at it.

Download
License

Link to post
Share on other sites

Thanks for the post!  I'm trying to come up with a way to map out an area with a robot using the new component.geolyzer.analyze() function so that we can give the robot a specific block name to search for and go to.  I've been looking at this code from Akuukis and now it's really helpful for me to compare it with yours, so thanks for posting!  Am I correct in reading your code that the way you plot your map to see which blocks are air and which are not is simply by trying to move there and reading the error message that comes up if the block isn't air?  The nav.lua from Akuukis uses robot.detect() to plot out the blocks around it, that's why I ask.

Link to post
Share on other sites

If you're talking about nibnav.pathfind() in particular, no. It lets you use your own callback for "plotting" the path. You basically pass it a callback function (getCost, it's documented in the code) and the callback should return a numerical weight if it's a reachable block or null if it's impassable. In other words, you provide the block data, all it does is find and return a path in said block data.

The algorithm will try to find the path with the lowest weight cost. I'd recommend reading this article if you're unfamiliar with A* pathfinding.

Now, It does check for the success of the movement functions for the purpose of changing/updating it's internal x,y,z coordinates. 

nibnav.moveY/X/Z/XZ only move in straight lines, and they're basically meant to be helper functions used in conjuction with nibnav.pathfind()

The code is pretty messy but you can look at this code to see an example of how it's used. This is my personal circular branch mining script, but it's still a heavy WIP so I don't have any documentation for it at the moment unfortunately. Look at genMap(), moveTo(), and getMoveCost(). genMap() generates a 2d bitmap of what the mine shaft will look like once it's completely dug out.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.