Programming a Pi to Deter Cats: Part 4

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I have a small, but important step completed. Let’s get started!

The tutorial I’ve been following gave me a hiccup after compilation. I had a passing difficulty when the commands I was copying used A different version number for an ls command.

Other than that, I had a little drama copying some expected output as a command, and when I did get the correct version number and file name in the command, there were a mismatch witha number or two. I figured it was just because of the version.

In the end, the tutorial had me test everything by running Python in the virtual environment, import OpenCV, and have it report its version. I was so relieved when it gave something back that didn’t resemble an error.

Going forward, I think the next, big milestone needs to be turning on an external light when it sees my cat in the frame. Setting this goal opens up a slew of smaller goals: connecting an LED to the external pins; learning and implementing basic elements in the OpenCV API; setting up such a program to run from either a single command, an icon, or bootup.

After that, it I should probably set it up as a VNC server and place it in its rightful position where it can start learning the difference between naughty cat on the counter and hungry human in the kitchen.

This project feels like it’s gone on ar least ten times longer than I expected. It’s good to have a small victory for once.

Final question: How do you keep track of progress in long projects?

Programming a Pi to Deter Cats: Part 3

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am finally installing OpenCV on my Raspberry Pi. And if I have a little more time, I may even try getting a Hello World type program running with it; it’s unlikely though. Let’s Get Started!

Last time I actually made any progress, I finished with making a virtual environment, meaning anything that happens in the sandbox stays in the sandbox, and I won’t have to rebuild the whole computer if things go nuclear. I think. The tutorial LINK wasn’t very informative, but it was fairly instant while making it clear it was technically an optional step.

The next couple steps are fuzzy in my memory. I don’t remember everything in chronological order. I kept running into errors, but I was gently pushed in the direction of trying to learn about them when I was in the local workshop (I was sure to bring a keyboard and mouse that weren’t at odds with my Pi).

My first major roadblock was when I was setting up to compile. I was sent off to research ‘cmake,’ a command line program being used in that stem. I ended up on a page with a lot of text, and I’m an audio learner. I don’t remember much of what was going on, but I recognized enough to say I was only about 95% lost as to what was going on when it came down to fine details, like the options being used for each argument in the command.

For some reason, it didn’t work, and I left stressed over it. If there’s one thing that is just an infinitesimal less frustrating than something not working when everything you know says it should work, it’s something working when everything you know says it shouldn’t work, and you’re trying to reproduce the problem so you can fix it. That happened to me. I set up for compilation, and I ran it. Ten minutes into the expected hour-plus operation at home, it crashed. There was some library it couldn’t find based on the pregenerated header, but I only figured that out when I went back into the workshop for a second time.

Round two this week was more of the same, possibly leading to events jumping sessions in my mind, but the second one was felt a lot more productive. I found the cause of the source of the problem, and I also worked on another, unrelated topic I want to save for another time.

Bonus Topic: I’ve complained a few times about how Windows sometimes is like, “By the way, we are updating your computer in 10 minutes, is that okay?” I find that highly frustrating. It popped up two or three Friday nights ago (after Sabbath started, so I didn’t want to do a whole topic about it). My father and I finally found the settings to supposedly require human input to permit an update.

Final Question: How much do you usually know about the commands you use?

Programming a Pi to Deter Cats: Part 2

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am moving along towards a feline safety program for my Raspberry Pi. Let’s get started!

For starters, I was even having doubts if my Pi was even powerful enough for computer vision applications. A quick search gives plenty of harry tutorials on how to install it. I’m following one here: LINK. I’m on the Raspberry Pi 3B+, and word has it the Pi 2 was pioneering the field for its kin.

I also watched some tutorials to get an idea of how OpenCV works, and I think it should track the cabinets and counter. If it tracks something moving on the counter and there is no occlusion (nothing is blocking) of the cabinets, register a hit. On a hit, save a picture for future evaluation, and sound the alarm to get the cat off the counter if it’s a strong enough hit.

I started installing OpenCV, but I ran into some issues. First of all, I am very glad I went it to that workshop I’ve mentioned before, because the tutorial just gives me wall of text. It helps to have someone knowledgeable to take a look at things when they stop working. It also would have helped if I had seen the troubleshooting section before I went and searched for one particular error I came across and ended up on another tutorial for the same thing.

Conditions were challenging. the mouse was crazy sensitive, and if I didn’t select and copy with the mouse, I ran the risk of typos in the keyboard. In the end, I believe I got a virtual box for Python 3 to run computer vision, but I ran out of time there.

At the beginning of my post, I mentioned feline safety. It turns out, my father spotted him walking on the stove top, and I really don’t want him getting burned, let alone the health risk.

Final Question: Have you ever used automated deterrents on animals?

Programming a Pi to Deter Cats: Part 1

Good Morning from my Robotics Lab! This is Shadow_8472, and today, and likely for the next couple weeks, I am studying up on how computer vision software works so I can get started on the software to convey a message to my feline friend about venturing in places he isn’t welcome. Let’s get Started!

I decided a long time ago that I wanted to explore the free and open source option OpenCV for this project. From what I can tell, I will need to play around with OpenCV on my desktop first to get a feel of how to use it.

As of the time of writing, I believe my workflow will start with getting OpenCV onto a Linux desktop. After I’m comfortable with how it works, I can try running it on the Pi. Depending on how well the Pi takes it, I will develop the actual program on either my PacMan Ghost case, Blinkie Pie, or my Ubuntu server tower, Derpy Chips. A period of testing will involve Blinkie watching the forbidden area and logging suspicious activity: basically anything that moves, and narrow that down to naughty cat behavior. While that’s happening, I need to develop an audio turret.

My mother actually found a dog training device that emits high frequencies, and the cats aren’t too fond of it either. I’ve already tried taking it apart, and it’s so cheap, getting into the case for tinkering will mean a new case. My goal for this phase is to get the Blinkie to turn the nasty sounds on from a remote desktop.

Once I have my cat identification program working reliably, I can connect it to the frequency generator and set it loose. For the first few days and weeks, I’ll want to monitor it and evaluate its results by looking at pictures from suspect incidents. I’m looking forward to obedient cats.

Final Question: Have you worked with Neural Nets on Computer Vision problems before?

Ice Boat Challenge Port Revamp Part 2

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am covering the finer details of my port of one of my favorite minigames in Minecraft. Let’s get started.

Many times over this project, I’ve tun into bugs. There is no way I’d remember them all, but I did pick up a few tips along the way, mostly from Grifter. If things are going wrong with relative coordinates, try aligning yourself with the source block and teleporting to the relative coordinates. Another approach is to set a particle in a repeat command block or a chain command block downstream of one. More often than not, one of these will literally get you where you want to go. I recommend the barrier particle for its lack of movement and occupation of a full block space.

Another bug I had to deal with a lot early on was invalid functions. If you try loading a datapack with an invalid function, Minecraft just throws a compilation-time-like error in the console then ignores it. Fortunately, the error report, once I read it under Grifter’s instruction, told me where the function, line, and column of each error was. It also didn’t help that Minecraft functions can’t have a comment start part way through a line.

The most recent bug I had to deal with was one that royally goofed it during some stress testing my parents, Annie_8472 and Leo_8472, kindly provided. Sometimes, a level wouldn’t load if you didn’t make it onto the pressure plates far enough. I tried fixing that by using align xyz command segments, but I only made it worse. I never did figure it out because I reverted the change and extended the search range to include a bit more of the alcove. For those keeping score, the bug was with the IBC game and not the MGC core.

At present, the project is almost done; I don’t think I’ll have enough for a whole new post next week, but I still need to debug the Lost & Found. Jamcdonald, the one who showed me the super hoppers last time, did a quick test for me and made note of the bug. He also pointed me in the direction of a place to get signs to do some fancy stuff the original credits signs do.

Final Question: I’m open to further development after things launch. What kind of levels do you want to see in this datapack?

Ice Boat Challenge Port Re-revamp

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am going over the “boat race” I ported to Minecraft 1.13 vanilla. Let’s get started.

At the beginning of the week, GrifterMage, an admin on the Minecraft server I play on, showed interest in getting the boat race up and running again sometime soon. I had already changed its host server over to a “Paper” server, like the server the project is being built for. Everything worked for a little while, but one day, the datapacks I tried sending weren’t working. I restarted my server, and my “original” copy was broken.

I decided to rebuild the backbone of the project from the ground up. While Grifter recommended I reuse as much as possible, I knew there was a certain amount of spaghetti logic at the end. I figured it would take less time to take the lessons I learned last time and make a version 2.1.

Grifter said he was okay with work-in-progress “untested” datapacks, so I made provisions as I set up my workspace. With Derpy set up as a VNC machine, I experimented with different arrangements of windows on both Derpy and my home Windows machine until I ended up with something that works.

My creative server with the secret boat race development laboratory in an Ice Spikes biome served to manufacture the structure files. From there, I would switch over to Derpy, where I would copy them into the “original” datapack along with the “originals” of the functions to run the whole setup. The datapack was stored in a special file on the desktop beside another file called Nightly Backups. This file did not live up to its name. I saved between two to four zip files per day there; whenever I felt I needed to make a progress report to Grifter I would open a terminal and run a command to zip the datapack for both storage and transmission.

The greatest flaw I perceived in my design last time was my inability to be sure someone else could set the game up on another server, so I created a “Clean Paper Server” to test my datapacks myself where I wouldn’t need to worry about anything accidentally relying on some scoreboard objective I forgot to make sure was created. Once I was done, all I had to do was delete the old server, copy the Clean Paper Server beside itself on Derpy’s desktop, copy the datapack into Clean Paper Server (copy 1), launch the server, hop in with my client on Windows, load both halves of the arena, and install the Ice Boat Challenge game. If this were something I was planning on needing to do over the course of a month or more, I would have looked into writing a script to automate what I could on Derpy.

The design objectives of this version remain almost the same as my first attempt at porting the boat race. I want to minimize the load on the server, while making it as easy as possible to develop other games for the system. I ended up coming up with a number of standards, like a “home” block for most command blocks in the Level Slots (floors a level can be loaded into) to run their commands from, forming a sort of two-way vector between the homes of each Alcove and Level Slot.

One improvement I noted in my notes for future development was to set up something similar for navigating the alcove. When Grifter introduced the /data merge command to me so I could use the same structure block for basically anything I wanted, he hinted that Minecraft 1.14 might actually let commands pipe information stored in such structures as input to other commands. I made sure to note that in many places within the comments of my functions. /data merge also opens up the possibility of multiplayer games that hijack functionality from the alcoves, so I made provisions for that functionality in the future.

This time around, the game starts when a player steps in an alcove. The Game Center operating system checks the player’s score for what game they want to play, and loads that game’s loader into the Level Slot for that alcove using a structure block in the home coordinates. The loader checks what slot it’s in, then checks what level to load for the player in the Level Slot’s alcove. It tries to load in the first half of the level, but if it fails for any reason, it has a carefully staged self-destruct to reset the Level Slot while making sure the redstone bits don’t accidentally pop off while multiple blocks are being changed (I’m pretty sure Minecraft likes to work from low y values on up based on an experiment I did with End Gateways, and my observations here back up this hypothesis).

After the loader, a series of command blocks embedded into each level takes over. These blocks handle spawning in the boat, teleporting the player, animating the boat so it does its cool spin, and checking for if the player has won or left their boat. It is here that I fixed a bug where the last version would smash players’ faces every once in a while. I used some redstone to space out commands. One of the last major bugs I faced before I got the main show working was dealing with how I hooked up the win detector. I had two blocks on repeat calling the same function and feeding into the same conditional chain command block. I ended up moving the win condition and giving it its own, dedicated command block.

A very big thanks to Grifter for all the help he’s given me this week. He got me started and helped me build inertia until I understood things well enough to continue mostly on my own. He also provided a friendly Discord avatar for me to explain the problem to in the hopes he would have time to help fix my current bug, only for me to keep working on it and often find it on my own.

A final word: documentation. Documentation is the link between you programming now and whoever is working on your project in the future. I have a whole folder in the root directory of the datapack with what the logic behind the Game Center and the Boat Challenge game is supposed to be. It also has a list of known bugs, a list of naming conventions I found helpful, credits, and even some general notes for what to do for if someone ever rewrites the project again

Final Question: Have you ever gone back to redo a project, only to find you’ve sped up by a fairly large margin


MineCraft Boat Race Port Part 7

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am presenting my work to update the Boat Race from Titaincraft Season one’s custom dimension, The Above. Let’s get Started.

If you are here from the server and spot the “Part 7” in the title, don’t worry. I’m writing this post as a fresh introduction to the project. If you’re interested in the development of the project, feel free to go back and have a read, and if I post about further development, Part 9 and above will also be available.

The Above’s boat race was originally built by Duke and  2Cubed with testing by dminer78. In the original game, players would wander into an ice cave and get teleported to the lobby where they could pick an arena to play their personal next level in. Each of the five levels has a different maze to navigate, ending with a row of gold blocks serving as the finish line. After completing the last course, the game would award the player with a Tango head, the special currency of The Above’s prize system.

The new edition used Duke’s levels but has many technological improvements over 2Cubed’s programming. The 1.13 execute command’s overhaul means that whole blocks of commands that were running all the time are replaced with one or two commands with a smaller footprint on the server’s CPU, and they only run as often as needed. A planned time trial mode would increase the replay value (besides the Tango heads). As part of this planned feature, there would also be a way to choose what level pack you want, and whether or not to shuffle the levels among other, new level tracks. And thanks to MineCraft’s introduction of functions, I decided to rebuild the game so it could be easily expandable; not only should it be fairly easy to add even more new levels but also new games as well as time goes on. For now, I’m calling it the Modular Game Center.

Working on this project, I learned a lot and overcame many challenges, many with the help of Jamcdonald120 and a few others. If you want to learn about a few of them, go back and read parts 1-6. As of this writing, the Modular Game Center still needs a little work once 1.13 gets a stable release and Spigot gets its update in turn.

Final Question: What game would you like to see added to the Modular Game Center?

MineCraft Boat Race Port Part 5

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am excited to announce the near completion of my project. Let’s get started.

Who would have known, not more than 24 hours after writing my last post, 12 after it went live, I would finally have the last major chunk of code working for my demo? I even made my goal of finishing before MineCraft 1.13 launched!

This week was kind to me even after my breakthrough, as I not only finished that up, but I got the other two alcove/arena combos working. Jam was helpful with getting the /tellraw commands working when he told me to just change out the old selecters.

I also worked over the end of level win condition, patching a bug where you could import a boat and cheat your way to the end. It turns out the boat would sometimes get stuck on elevators and break apart, forcing the player out of the level and resetting their progress. I made the level require the use of the original boat by setting (and checking for) an invulnerable flag on the boat. Unfortunately, I have no way of testing the invulnerable flag on glitching boats.

As it is now, I think the experience is at about 99.9% of the original. The original boats spun in air as they were summoned, and I still need to nail the /teleport commands.

I showed my work off to a few people this week. Duke, the guy who built the levels and my first guest after the workable demo, came by and helped me with a potentially embarrassing bug for when Tango (the owner of the Patreon server I play on) eventually does a blind reaction. New players need a valid score before they can enter the level for the first time. I fixed that for him and when DropDaBass, the server’s head moderator, came by.

There are still a few minor bugs. Sometimes timings don’t work out the best and you take a little damage on the way to the arena. Once in a large while, the level unloads around you without returning you to the lobby. There’s trouble with FPS (Frames Per Second) when connected over the Internet and a level unloads. There will always be something to polish.

One of my major goals for this build is the flexibility to add more games. I brought another patron over called Pendl3, who is looking to help me with my random throw away idea of a golf course. Getting the code ready for running dual games will be interesting, but I will complete the challenge.

Final Question: Simple, what games should I add? I think it would be good for me to add a few a year and they can either players or moderators swap them out with a control panel.

Open Beta

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I’m opening up my turtle program for open beta. But first, a few words about the challenges I dealt with this week. Let’s get started!

Timings. My greatest enemy this week was timings. Something might be a little off and an item slips in when a turtle is busy and the whole thing breaks. I had to put several lines of code in to print to the console just to figure out when an item made it in to glitch the system. I can only imagine how much more I’m going to have that problem when using a more sophisticated robot.

I’m declaring all my programs at version 0.9 for the purpose of beta testing. In the future, I may use a different scheme, but I will need to look into it farther first.

My notes assume you have a stable installation of ComputerCraft (specifically the Computeacube implementation.) I developed it under 1.12.2 Forge.

Link to code: https://letsbuildroboticswithshadow8472.com/?page_id=275&preview=true

Final Question: Practical question, What bugs are left in my code?

A Final Delay

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am delaying the publication of my modded MineCraft skeleton farm. Let’s get started.

For the past month or so, I’ve noticed I’m on an on-week, off-week cycle. This was an off-week. I didn’t get the project finished, despite how little there seemed to be left. When I publish, I want to make sure my code is solid and well-documented. I may have a workable prototype, but with the constant lack of concentration, I ended up with almost zero progress.

For when I do make progress, I have a few challenges in the way of making a solid program. Parallel editing between an in-game editor and an out-of-game editor often leaves me behind in either one or the other spots; I either find myself fixing the same bug over and over again in the same program each time I make a new transfer (usually the case when I have a bunch of tiny, bug fix type edits), or I have to make a new transfer to propagate extensive changes. I plan on publishing when I can transfer straight from Notepad++ to ComputerCraft.

Up until now, I’ve been working purely in survival server across the room. Maybe I should consider working in a creative, single-player. That’s it. I’ll edit my code directly from Notepad++ and run it in-game. I’ll be able to drop the version number nonsense, and my busywork will drop off dramatically. Why didn’t I think about this a month ago?! I suppose I did, but the server computer is across the room, and the station is frequently occupied. I know ComputerCraft has some PastBin feature, but I don’t want to mess with that yet/ever.

Final Question: I know this has been a short blog with a lack of time spent on it, but I feel like this week, I made more progress than any other week working on this project so far. Have you ever had a comparable moment of inspiration?