import { TaskRegistry } from '@things-factory/integration-base'

import { checkValidPose, getPositionFromAccessor } from './util'

async function CheckCubeRegion(step, { logger, data }) {
  var {
    params: { accessor, cubeFirstPos, cubeSecondPos }
  } = step

  var position = getPositionFromAccessor('accessor', accessor, data, logger)
  checkValidPose('accessor', position)

  console.log(position)

  return {
    data: true
  }
}

CheckCubeRegion.parameterSpec = [
  {
    type: 'scenario-step-input',
    label: 'accessor',
    name: 'accessor'
  },
  {
    type: 'pose',
    label: 'cube-first-position',
    name: 'cubeFirstPos'
  },
  {
    type: 'pose',
    label: 'cube-second-position',
    name: 'cubeSecondPos'
  }
]

CheckCubeRegion.connectorFree = true
CheckCubeRegion.help = 'robotics/task/check-cube-region'

TaskRegistry.registerTaskHandler('check-cube-region', CheckCubeRegion)
