kipr / Simulator

Simulator of KIPR Demobots and code workspace.
GNU General Public License v3.0
12 stars 3 forks source link

[Semio] Challenge System #439

Closed bmcdorman closed 1 year ago

bmcdorman commented 1 year ago

Description

This PR adds challenges to the simulator. This includes:

There is currently no user interface for creating challenges through the UI.

The challenge system is contained inside an entirely separate Root UI (i.e., ChallengeRoot.tsx).

Added UI elements

Predicate Viewer

Supports, AND, OR, XOR, EVENT, and ONCE. image

Challenge tab (Side Layout)

image

Challenge widget (Overlay Layout)

image

tcorbly commented 1 year ago

Challenge 6c intersection work finished. Still needs lift and upright conditions. Test code below:

#include <stdio.h>
#include <kipr/wombat.h>

int main()
{
  printf("Hello, World!\n");
  enable_servos();
  set_servo_position(0,1900);
  set_servo_position(3,1000);
  msleep(1000);

  // Drive to green garage can
  motor(0,100);
  motor(3,100);
  msleep(2500);
  ao();

  msleep(1000);

  // Pick up can green garage can
  set_servo_position(3, 2000);
  msleep(500);

  // Pull can to circle 2
  motor(0,-100);
  motor(3,-100);
  msleep(2000);
  ao();

  msleep(1000);

  // Raise claw back up
  set_servo_position(3,1000);
  msleep(1000);
  set_servo_position(0,1000);
  msleep(1000);

  // Turn to left
  motor(0,100);
  motor(3,-100);
  msleep(850);
  ao();

  // Small drive forward
  motor(0,50);
  motor(3,50);
  msleep(2200);

  // Turn to right
  motor(0,-100);
  motor(3,100);
  msleep(810);
  ao();

  // Lower claw
  set_servo_position(0,1900);
  msleep(1000);

  // Drive to yellow garage can
  motor(0,50);
  motor(3,50);
  msleep(6500);
  ao();

  // Pick up can yellow garage can
  set_servo_position(3, 2000);
  msleep(500);

  // Drive to circle 10
  motor(0,100);
  motor(3,100);
  msleep(1000);
  ao();

  msleep(1000);

   // Raise claw back up
  set_servo_position(3,1000);
  msleep(1000);
  set_servo_position(0,1000);
  msleep(1000);

  // Turn to right
  motor(0,-100);
  motor(3,100);
  msleep(460);
  ao();

  // Lower claw
  set_servo_position(0,1900);
  msleep(1000);

  // Drive to blue garage can
  motor(0,100);
  motor(3,100);
  msleep(1000);
  ao();

  // Pick up can blue garage can
  set_servo_position(3, 2000);
  msleep(500);

  // Pull can to circle 9
  motor(0,-100);
  motor(3,-100);
  msleep(1000);
  ao();

  msleep(1000);

   // Raise claw back up
  set_servo_position(3,1000);
  msleep(1000);
  set_servo_position(0,1000);
  msleep(1000);

  return 0;
}

Additionally a few errors showed up when trying to view the challenge tab. It appears to be related to displaying the predicate. Error below:

Uncaught TypeError: root is undefined
    treeify PredicateEditor.tsx:17
    PredicateEditor PredicateEditor.tsx:118
    React 12
    unstable_runWithPriority scheduler.development.js:468
    React 6
2 PredicateEditor.tsx:17

The other bug is that if an item is made visible while running challenge it does not reset to invisible on Challenge Reset like it does in a normal scene reset.