If the problem of "dynamic area", or even "how to avoid missing the surface and boundaries" could be translated to "where to start well-defined job" - then it sounds to me like common task, with regards to philosophy of CNC machines. (Ok, until the surface is not moving around.)
Pronterface and GRBL work in Cartesain system. GRBL does not support mesh probing. So you must think about relatively flat, plane surfaces.
In my opinion, you need to fulfill following tasks to achieve the goal:
- Define boundaries. Hard and soft boundaries of device are supported by GRBL. You should setup them for overall safety.
- Plan the job. Recognize ranges of planned plot or print.
- Secure the surface. It must be appropriately stabilized. If you want to draw, the pen mount with spring will equalize variations of the surface (hand, finger, egg). 3D printing is sensitive to roughness and obliquity, we add raft/supports to overcome these - could be of use, until it doesn't mean missing your goal? (Don't print with hot filaments on fingers.)
- Establish point of reference. You need to home your plotting or printing head somewhere in space in relation to the driving hardware. This is needed for any further actions. I envsion homing Z to the top of the frame, rather then against the target.
- Detect surface. Camera will help with horizontal borders (X,Y). You also need to measure the Z distance. The Z probe could be mechanical (then needs vertical movement) or some distance detector (like VL53L0X ?).
- Validate fitting. Ensure that the surface will accommodate ranges of planned job. This is actually the key point in my opinion. You need to know scope at the first place.
- Program. I see following options to pick and mix the final solution from them:
- G-code is generated prior to the whole procedure. You need to synchronize the starting point between the generated file and the real job range. Homing is done "manually" prior to executing the file. After surface is detected, the real starting point could be calculated and applied.
- G-code is generated after surface is detected. Job starts with homing, and first moves go from device's zero (home position) to selected starting point on the surface. All consecutive moves are planned within boundaries over the surface. So there is no risk to work outside the safe range.
- G-code is generated with relative positioning (incremental distance mode), having
G91
in preamble. Then you just travel to the starting point and then run the commands from file.
- G-code is generated with absolute positioning (absolute distance mode). To run the job, you need to change coordinate system using commands like
G10
, G54-G59
.
- For printing, if there is a needed to match some flat shape to rought surface, then you may need to dynamically generate some supports/raft below the bottom of the printed part.