compas-dev / compas_fab

Robotic fabrication package for the COMPAS Framework.
https://compas.dev/compas_fab/
MIT License
108 stars 32 forks source link

Introduce Action and SceneState #390

Open yck011522 opened 7 months ago

yck011522 commented 7 months ago

This pull request is to introduce the Action and State Classes for modeling a robotic fabrication process. The concept of Actions and States is based on this paper https://dl.acm.org/doi/abs/10.1145/3485114.3485122. Actions and SceneStates are related tightly because an Action is conceptually the object that would change the current state to a new state.

There is generally a distinction between robotic actions vs non-robotic actions. The difference is that the robotic ones require motion planning, which is fulfilled by the motion planning backend of compas_fab. The distinction is implemented by inheriting from the RoboticAction class. A number of common Actions are provided in the compas_fab library, but users are free to implement their own actions according to the needs of their process and the function of their tools.

In any robotic process, the initial state is described with SceneState object. It contains the state of all the mutable properties of objects in the planning scene. The objects include RobotState, ToolState (multiple), and WorkpieceState (multiple). The default implementation of these objects contains a minimal set of properties. For example, WorkpieceState contains the location (Frame) of the workpiece. Users can inherit these as base classes and add more properties if needed. In addition, the SceneState contains information describing tool attachment (to Robot) and workpiece attachment (to Tool). See API of SceneState for more details.

As actions are performed (or applied in simulation), they influence the state of the scene, resulting in a new scene state. The new scene state can be used to describe the beginning of the next action and so on. This function to modify a starting state to create an ending state is encoded using the function Action.apply_to(self, scene_state,). This function allows automatic parsing of all intermediate states once the (1) initial state and (2) action list are created. This allows the user to visualize the scene, where object locations and attachment relationships can be examined. This visualization can happen even before motion planning and can help identify incorrect modeling that may cause motion planning failure.

During motion planning, the planner is preloaded with all the object models. The input to plan a single RoboticAction is the starting scene state and the RoboticAction object. In special cases where non-sequential planning is required, the SceneState at the beginning of any action can be computed automatically, allowing a single Action to be planned out of sequence. See Tutorial: Non-Sequential Planning (not yet written) for more details.

After motion planning, the planned trajectory will be stored in the same Action object. Which can be used for visualization and execution.

What type of change is this?

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

yck011522 commented 7 months ago

Link to https://github.com/compas-dev/compas/pull/1209 for potential synergy.

yck011522 commented 7 months ago

@gonzalocasas @chenkasirer Will you have time to take a look at this?

yck011522 commented 3 months ago

Lets hold on to resolve the Targets #409 before going back to this one.