Skip to content

Implement Robot Values On Field #82

Description

@AlexKempen

Robots are currently drawn on the field according to a set of fixed constraints set in RobotElement in FieldElements.tsx. The robots should instead reflect the robot assigned to their associated path.

  • The robot should probably be passed to RobotElement via props from FieldElements in order to prevent issues with iinvalid props/early returns.
  • Because FieldElements handles multiple paths which could be invalid, and due to the rules of hooks, useAppSelector cannot be called within the path loop. Instead, you could implement a solution similar to AppTree's calls to getPathNode, where the dictionary is selected first and then the dictionary is accessed inside the actual loop, or you could apply logic like:
    const robots = useAppSelector(state => paths?.map(path => selectRobotByValidId(state, path.robotId));
    The ? in paths?.map handles the case where paths is undefined; if it is, .map is skipped, and the function returns undefined. FieldElements should then return null if either Paths or Robots is undefined.

Metadata

Metadata

Labels

2This issue is good for beginners and will have some slight challenges

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions