# Sample code for GAN robot?



## Osric (Jun 24, 2020)

Has anyone found documentation, sample code, or reverse engineered the protocol for the GAN Robot? I'd love to hook it up to things like Roman's OLL trainer.

Thanks in advance


----------



## cubeast (Jun 24, 2020)

I can't help you here, but FYI someone messaged me a while back asking me if I worked on Gan Robot support for Cubeast and told me he was experimenting with the Bluetooth API and actually bricked his Gan Robot, so it seems reverse engineering is risky.

As a side note I'll say that IMO using the Gan Robot for trainers is a bad idea. Gan Robot is actually not that easy to use, it takes a moment to put the cube in it, the scrambling itself is also not that quick. I don't think it's superior to manually scrambling your cube like for example in Roman's ZBLL trainer. IMO the way to improve the trainers is to use Bluetooth cubes. Just show a case on the screen and have the user solve it by looking at the screen rather than the physical cube. This way you don't have to scramble the cube at all and you could be solving a case every 5 seconds or even faster. I plan on implementing this in Cubeast for all methods, not only CFOP.


----------



## Osric (Jun 24, 2020)

cubeast said:


> As a side note I'll say that IMO using the Gan Robot for trainers is a bad idea. Gan Robot is actually not that easy to use, it takes a moment to put the cube in it, the scrambling itself is also not that quick.



Well really this argument works against the whole tech thing in cubes! For any intermediate solver who can solve in under 90s, manual scrambles and solves are fast, easy, and can be done without futzing with a cube that runs out of battery, loses its bluetooth connection occasionally, and while being fairly nice to work with is just not as good as their main cube.

I think the GAN Robot is good for two cases: beginners who are learning the algorithms for the first time and are not at all focused on speed, or for the distracted cuber who wants to be able to pick up a scrambled cube every few minutes and solve it while doing something else. FWIW on my edition of the GAN Robot a complete scramble takes 5s, so if it'd only automatically scramble as soon as you locked the cube in it would feel pretty quick to any novice. For an advanced solver who can already read and perform a scramble off of cstimer or similar in under 10s it's probably a waste of time and money.


----------



## OldManLink (Sep 24, 2021)

I have another project in mind for it, should I ever get hold of the API: I'd like to make a pipeline for making cube mosaics


----------



## Osric (Jun 18, 2022)

Necro'ing my own thread in case someone is looking for this: there is now https://github.com/rsimp/gan-scrambler by Robert Simpson and he has it hosted at https://rsimp.io/gan-scrambler/

You'll want to put the cube in the robot white face up and label which arm turns green, for reliable manual scrambles that match what you're using. For example to use with cstimer set the timer to copy the scramble on click, then paste into the manual scramble page of gan-scrambler. The scrambler does not require a bluetooth cube, just centercaps compatible with the GAN robot.


----------



## codacube (Jun 18, 2022)

As an owner of a GAN robot and a lover of technology in general, here are a few comments from a user of the robot:

Pros:

Fast scrambles - The robot even has a double cube option for almost continuous mixing.
Better than MY manual scrambles - I'm a beginner. I've found that my manual scrambles are strangely too consistent. Why am I always getting the same perms? ;-)
CubeStation - Easy to practice any algorithm over and over with time and score saved
Terrific database of algorithms
Stats - Nice to have them in one place and see improvement
Who doesn't like a robot?! It is just fun and portable. 
Cons:

Cube has to be carefully placed into robot. If I could solve a cube fast, this would be an issue
How is your Mandarin? Cube Station app on is constantly improving, but even the version with English language doesn't make sense
Stats - I don't see any way to export to something like Cubeast or CStimer
I guess this is a long way of saying that I'm delighted that someone is exploring the GAN Robot world and making it more useful. FYI- Cubeast is right! As I get faster, I can see the robot used less often.


----------



## Osric (Jun 18, 2022)

I personally can't stand the GAN software, and am a little annoyed that they make it hard to program their devices directly, so I'm glad to find example code that works.

I use my bluetooth cube with cstimer or cubeast, and their scrambles are good enough. I love the robot as a toy but don't use it much.

I still think it's a fun toy. With the open source software that controls it, I can imagine some use cases like having two cubes, one always at the ready via the robot for the next solve, or scrambling multiple cubes for a group to ensure everyone gets the same scramble.


----------



## Lucas Garron (Jun 19, 2022)

For what it's worth, cubing.js has supported the Gan robot since about a year. We have a test page at https://experiments.cubing.net/cubing.js/robot/ and you can use something like this to send it scrambles:


```
<button id="connect">Connect</button>
<button id="scramble" disabled>Scramble</button>
<twisty-player tempo-scale="5"></twisty-player>

<script type="module">
  import { randomScrambleForEvent } from "https://cdn.cubing.net/js/cubing/scramble";
  import { connectSmartRobot } from "https://cdn.cubing.net/js/cubing/bluetooth";
  import "https://cdn.cubing.net/js/cubing/twisty";

  let robot;
  document.querySelector("#connect").addEventListener("click", async () => {
    robot = await connectSmartRobot();
    document.querySelector("#scramble").disabled = false;
  });

  document.querySelector("#scramble").addEventListener("click", async () => {
    const scramble = await randomScrambleForEvent("333");
    robot.applyMoves(Array.from(scramble.units()));
    document.querySelector("twisty-player").alg = scramble;
    document.querySelector("twisty-player").play();
  });
</script>
```


----------



## Osric (Jun 19, 2022)

That's great @Lucas Garron ... I was going to do a side software project with my son to try to build a simple scramble/solve website out of cubing.js and rsimp's robot implementation, but obviously if cubing.js already has support we'll try using that instead.

PS - what github repo do you want bugs against this page logged at? It doesn't seem to handle m-slice moves on my cube correctly.


----------



## Lucas Garron (Jun 20, 2022)

Osric said:


> That's great @Lucas Garron ... I was going to do a side software project with my son to try to build a simple scramble/solve website out of cubing.js and rsimp's robot implementation, but obviously if cubing.js already has support we'll try using that instead.
> 
> PS - what github repo do you want bugs against this page logged at? It doesn't seem to handle m-slice moves on my cube correctly.



Ah, yeah, there might be a few options for M moves. If you let us know more details at https://github.com/cubing/cubing.js/issues/new/choose we can figure out options.


----------



## SnowyDay (Jul 11, 2022)

Do cubing.js & rsimp.io enable the "Algorithm practising" that the Gan Robot promised years ago? 

To be clear, could one practice any alg 20x, with the robot resetting the cube each time?


----------



## codacube (Jul 11, 2022)

Hey @SnowyDay , 
I use Cubestation and it has functions that allow you to practice a specific algo. I don't know when it was added, but it is there now. For example, in the image below it shows that my practice on Sune, and antisune. (It also shows how poorly I do them. ;-) ) The robot will put the cube into any of the desired patterns.

Cubestation also lets you select alternative algorithms for each of the OLL/PLL/etc. On the left side of the image above the word algorithm, it shows that there are 22 different options for the selected algo.


----------



## Lucas Garron (Jul 12, 2022)

SnowyDay said:


> Do cubing.js & rsimp.io enable the "Algorithm practising" that the Gan Robot promised years ago?
> 
> To be clear, could one practice any alg 20x, with the robot resetting the cube each time?


Should be easy enough, although physically loading the cube each time will probably always take a few seconds.


----------



## SnowyDay (Jul 12, 2022)

Thanks guys. I didn't realise that 3rd parties have developed enhanced Robot software. That is fantastic!


----------

