Loading files
11201b573This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
11201b573This file is pinned to the selected release. Download the original to open it in your design tool.
import { Request } from "http"
import { Target } from 'robot'
function onRobotCreated(robot) {
const target = new Target(0.6, 0, 0)
let characterCount = 0;
let request = new Request({ host: "192.168.7.126", path: "/func/result", method: "POST" });
request.callback = function (message, value, etc) {
if (Request.responseFragment === message) {
let text = this.read(String);
characterCount += text.length;
let str = text.split('|')[0]
let data
try {
data = JSON.parse(str)
} catch (e) {
trace('parse fail \n')
return
}
let faces = data.face
if (faces != null && faces.length == 0) {
trace('no face detected \n')
return
}
let face = faces[0]
let centerX = face.x + face.w / 2
let centerY = face.y + face.h / 2
target.y = (320 - centerX) / 320
target.z = -centerY / 480
}
if (Request.responseComplete == message)
trace(`\n\nTransfer complete. ${characterCount} characters.\n`);
}
robot.follow(target)
}
export default {
onRobotCreated,
autoLoop: false
}