For a while now I've wanted to support many robots in Evil Overlord. To do this I need two things: (1) a way to select robots on the screen and (2) a context sensitive menu for each selected robot. I've had #2 for a while now. Today I got #1 working.
Multi-tool support
0800-1300 today was spent cleaning up code for menus so that each tool on the arm generates it's own sub-menu and there's the start of an attach() and detach() behavior that swaps out the sub menu.
Ray Picking vs OpenGL sampling
1300-1800 was spent building a ray picking system. Ray picking involves shooting a ray out of the camera, through the cursor, into the 3d world, and finding the nearest thing that the ray hits. Those five hours were spent checking the ray went out, stayed correct, and so on. I got that working and felt very good about myself. Mentally, I turned the page.... and realized I'd have to build code to make the ray hit every triangle in every object, figure out which one was closest, optimize the shit out of it... Aw hell no.
Surely there's a way to get the OpenGL graphics to tell me what's under the cursor to begin with, right? They're already doing all the heavy lifting. (In retrospect) it would be stupid to reinvent the wheel. As it turns out glRenderMode(GL_SELECT) is for exactly that purpose. I'm so happy it works, I don't mind the time wasted on the ray picking.
Here are two great links I found to explain how OpenGL sampling works.
- https://github.com/sgothel/jogl-demos/blob/master/src/demos/misc/Picking.java
- http://web.engr.oregonstate.edu/~mjb/cs553/Handouts/Picking/picking.pdf
End Result
Now in Evil Overlord you start with an empty world and the context sensitive menu is set to the camera controls. The "World" menu at the top has only one option: "Add Evil Minion". Click it and an Evil Minion Arm appears in the world. now any time you click on an EM the menu changes to that robot. You can connect over serial, drive it with FK and IK, and open/close the gripper.
I have tested adding multiple robots to EO at once they are independently selectable, each can be connected separately, and clicking on the background (anywhere with no robot) returns you to the camera menu.
Have your say!
Should the next step be:
- Record & playback
- Build a second Minion and drive both at once
- Finish the tool changing
- Make some 15-30 second videos of the robot doing stuff. (Suggest something.)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.