Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot API: Running a program from within a program #39

Open
2 tasks
mayacakmak opened this issue Sep 24, 2020 · 0 comments
Open
2 tasks

Robot API: Running a program from within a program #39

mayacakmak opened this issue Sep 24, 2020 · 0 comments
Labels
features new features for the robot

Comments

@mayacakmak
Copy link
Owner

This feature has become necessary for the ACT/DBT study (see Issue #33). How we might be able to do it:

  • First we need a new function in the robot API, say runProgram(programName) or runProgram(programID); the API can list all available programs for a given robot (just like it lists the faces and belly screens).

  • Currently a program is run as below. The code is actually not parsed, but some function calls can be easily modified (e.g. robot.sleep). If the program itself had some lines that are robot.runProgram and that function basically went and found the program from the database, turned it into codeText and used eval() to run it, like below, would that just work? We should try this as a first idea.

async function runProgram(robotId, programId) {
  let codeText = robotPrograms[robotId][programId].program;
  codeText = codeText.replace(/robot.sleep/g, "await robot.sleep");
  eval("(async () => {" + codeText + "})();");
}
@mayacakmak mayacakmak added the features new features for the robot label Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features new features for the robot
Projects
None yet
Development

No branches or pull requests

1 participant