Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
cfry committed Jan 21, 2020
1 parent 92a2513 commit 2b6720e
Show file tree
Hide file tree
Showing 26 changed files with 7,261 additions and 320 deletions.
5,905 changes: 5,905 additions & 0 deletions DexRun.c

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions core/dextersim.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ DexterSim = class DexterSim{
"<br/>from the queue. They will never be run.")
this.instruction_queue = []
}
else { this.instruction_queue.push(instruction_array) }
else {
this.instruction_queue.push(instruction_array)
//if(instruction_array[4] == "a"){ out("sim J2: " + instruction_array[6] / 3600 + "<br/>_____________")} //debugging statement only
}
}

//hardware side methods below
Expand Down Expand Up @@ -223,8 +226,6 @@ DexterSim = class DexterSim{
}
}



process_next_instruction(){
let dur = 10 // in ms
this.now_processing_instruction = this.instruction_queue.shift() //pop off next inst from front of the list
Expand Down Expand Up @@ -343,7 +344,7 @@ DexterSim = class DexterSim{
if (job_instance){
let job_name = "Job." + job_instance.name
let rob_name = "Dexter." + this.robot_name
if(window["sim_graphics_pane_id"]) { //window.platform == "dde") //even if we're inn dde, unless the sim pane is up, don't attempt to render
if(window["sim_graphics_pane_id"]) { //window.platform == "dde") //even if we're in dde, unless the sim pane is up, don't attempt to render
//SimUtils.render_once(robot_status, job_name, rob_name) //renders after dur, ie when the dexter move is completed.
SimUtils.render_multi(robot_status, job_name, rob_name, undefined, dur)
}
Expand All @@ -369,9 +370,11 @@ DexterSim = class DexterSim{
let j3 = robot_status[Dexter.J3_MEASURED_ANGLE]
let j4 = robot_status[Dexter.J4_MEASURED_ANGLE]
let j5 = robot_status[Dexter.J5_MEASURED_ANGLE]
let j6 = robot_status[Dexter.J6_MEASURED_ANGLE]
let j7 = robot_status[Dexter.J7_MEASURED_ANGLE]
j1 = j1 * -1 //fix for j1 wrong sign
j5 = j5 * -1 //fix for j5 wrong sign
out("DexterSim " + job_name + " " + robot_name + " J1: " + j1 + ", J2: " + j2 + ", J3: " + j3 + ", J4: " + j4 + ", J5: " + j5,
out("DexterSim " + job_name + " " + robot_name + " J1: " + j1 + ", J2: " + j2 + ", J3: " + j3 + ", J4: " + j4 + ", J5: " + j5 + ", J6: " + j6 + ", J7: " + j7,
"#95444a", //brown,
true) //temp output
}
Expand Down Expand Up @@ -521,5 +524,4 @@ var {shouldnt} = require("./utils.js")
var {make_folder, make_full_path} = require("./storage")

var Kin = require("../math/Kin.js")
var Vector = require("../math/Vector.js")

var Vector = require("../math/Vector.js")
9 changes: 8 additions & 1 deletion core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ var {sind, cosd, tand, asind, acosd, atand, atan2d} = require("../math/Trig_in_D
var Job = require("./job.js")

var {Robot, Brain, Dexter, Human, Serial} = require("./robot.js")
var {RobotStatus} = require("./robot_status.js")
var {Instruction, make_ins, human_task_handler, human_enter_choice_handler,
human_enter_filepath_handler, human_enter_number_handler, human_enter_position_handler,
human_enter_instruction_handler,
human_enter_text_handler, human_show_window_handler} = require("./instruction.js")
human_enter_text_handler,
human_notify_handler,
human_show_window_handler,
} = require("./instruction.js")
var {Control} = require("./instruction_control.js")
var {IO} = require("./instruction_io.js")
require("./je_and_browser_code.js") // must be before loading out.js as it defines SW used by out.js
Expand All @@ -139,6 +143,7 @@ global.Brain = Brain
global.Dexter = Dexter
global.Human = Human
global.Robot = Robot
global.RobotStatus = RobotStatus

global.make_ins = Dexter.make_ins
global.speak = speak
Expand All @@ -154,6 +159,8 @@ global.human_enter_number_handler = human_enter_number_handler
global.human_enter_position_handler = human_enter_position_handler
global.human_enter_instruction_handler = human_enter_instruction_handler
global.human_enter_text_handler = human_enter_text_handler
global.human_notify_handler = human_notify_handler

global.human_show_window_handler = human_show_window_handler

global.Control = Control
Expand Down
271 changes: 168 additions & 103 deletions core/instruction.js

Large diffs are not rendered by default.

283 changes: 250 additions & 33 deletions core/je_and_browser_code.js

Large diffs are not rendered by default.

135 changes: 81 additions & 54 deletions core/job.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions core/out.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,22 @@ function show_window({content = `<input type="submit" value="Done"/>`,
//if(arguments[0]) {the_instruction_id = arguments[0].the_instruction_id}
//Warning: do not put newlines in the html for show_window as that will result in <br/> tags that
//replace the newlines and thus screw up the html for the show_window.
if(SW.window_index === null) { SW.window_index = 0 }
else { SW.window_index += 1 }
let the_sw_elt_id = 'show_window_' + SW.window_index + '_id'
content = '<div class="show_window_content" contentEditable="false" draggable="false" style="font-size:15px; padding:5px;">' +
'<input name="window_callback_string" type="hidden" value="' + callback + '"/>' +
'<input name="trim_strings" type="hidden" value="' + trim_strings + '"/>' +
'<input name="job_name" type="hidden" value="' + job_name + '"/>' +
'<input name="show_window_elt_id" type="hidden" value="' + the_sw_elt_id + '"/>' +
content +
'</div>' //to allow selection and copying of window content

if(SW.window_index === null) { SW.window_index = 0 }
else { SW.window_index += 1 }

var show_window_html =
'<dialog class="show_window"' +
' data-window_index="' + SW.window_index +
'" id="' + 'show_window_' + SW.window_index + '_id' +
'" id="' + the_sw_elt_id +
//'" data-show_window_title="' + title +
// '" ondragstart="sw_dragstart(event)' +
'" style="padding:0px; right:none; margin:0px; position:fixed; z-index:100;' +
Expand All @@ -266,9 +269,10 @@ function show_window({content = `<input type="submit" value="Done"/>`,
sw_make_title_html(title, show_close_button, show_collapse_button) +
'<div draggable="false" style="overflow:auto; background-color:' + background_color + ';">' + content + '</div>' +
'</dialog>'

//onsole.log("show_window produced html: " + show_window_html)
let props = {job_name: job_name, kind: "show_window", html: show_window_html, draggable: draggable,
is_modal: is_modal, init_elt_id: init_elt_id, window_index: SW.window_index, close_same_titled_windows: close_same_titled_windows}
is_modal: is_modal, init_elt_id: init_elt_id, window_index: SW.window_index,
close_same_titled_windows: close_same_titled_windows}
//Warning: evaling the below will cause 2 copies of the the show_window code to go to the browser.
//then we get TWO such elements in the browser (one invisible) but that screws up
//getting the right one and breaks dropping a dragged show_window dialog. Yikes!
Expand Down
49 changes: 29 additions & 20 deletions core/robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,17 @@ var Robot = class Robot {
content="webcam", //"webcam" or file_path
title=undefined,
x=200, y=40, width=320, height=240,
play=true}={}) {
play=true,
visible=true}={}) {
return new Instruction.show_video({video_id: video_id, //string of a video_id or video dom elt
content: content, //mat or file_path
title: title,
x: x,
y: y,
width: width,
height: height,
play: true})
play: play,
visible: visible})
}
static take_picture({video_id="video_id", //string of a video_id or video dom elt
camera_id=undefined,
Expand Down Expand Up @@ -390,7 +392,9 @@ var Human = class Human extends Brain { /*no associated hardware */


static task({task = "", dependent_job_names=[],
title, x=200, y=200, width=400, height=400, background_color = "rgb(238, 238, 238)"} = {}){
title, x=200, y=200, width=400, height=400,
background_color = "rgb(238, 238, 238)",
add_stop_button=true} = {}){
return new Instruction.human_task(arguments[0])
}

Expand Down Expand Up @@ -420,6 +424,7 @@ var Human = class Human extends Brain { /*no associated hardware */
static enter_instruction({task = "Enter a next instruction for this Job.",
instruction_type = "Dexter.move_all_joints",
instruction_args = "5000, 5000, 5000, 5000, 5000",
add_stop_button=true,
dependent_job_names = [],
title, x=200, y=200, width=400, height=400, background_color = "rgb(238, 238, 238)"}={}){
return new Instruction.human_enter_instruction(arguments[0])
Expand Down Expand Up @@ -463,6 +468,8 @@ var Human = class Human extends Brain { /*no associated hardware */
output_pane=true,
beep_count=0,
speak=false,
add_stop_button=true,
dependent_job_names=[],
title, x=200, y=200, width=400, height=400, background_color = "rgb(238, 238, 238)"
}={}){
return new Instruction.human_notify(arguments[0])
Expand All @@ -475,8 +482,10 @@ var Human = class Human extends Brain { /*no associated hardware */
show_close_button = true,
show_collapse_button = true,
trim_strings = true,
add_stop_button=true,
callback = window.show_window_values,
user_data_variable_name="show_window_vals"
user_data_variable_name="show_window_vals",
dependent_job_names=[]
}={}){
return new Instruction.human_show_window({
content: content,
Expand All @@ -487,8 +496,10 @@ var Human = class Human extends Brain { /*no associated hardware */
show_close_button: show_close_button,
show_collapse_button: show_collapse_button,
trim_strings: trim_strings,
add_stop_button: add_stop_button,
callback: callback,
user_data_variable_name: user_data_variable_name
user_data_variable_name: user_data_variable_name,
dependent_job_names: dependent_job_names
})
}
}
Expand Down Expand Up @@ -746,21 +757,6 @@ Serial = class Serial extends Robot {
}
rob.perform_instruction_callback(job_instance) //job_instance.set_up_next_do()
}
/* just for dexter
else if (ins_id == -1) { //this is the get_robot_status always called at the very beginning
if (job_instance.status_code === "starting") {
job_instance.status_code = "running"
// if(rob.enable_heartbeat && (rob.heartbeat_timeout_obj == null)) { //enabled but not already running
//beware multiple jobs could be using this robot, and we only want at most 1 heartbeat going
// rob.run_heartbeat()
// }
}
//before setting it should be "starting"
if (job_instance.status_code === "running") {
rob.perform_instruction_callback(job_instance) //job_instance.set_up_next_do() //initial pc value is -1. this is the first call to
//set_up_next_do (and do_next_item) in this job's life.
}
} */
else { //the normal, no error, not initial case
if (job_instance.wait_until_instruction_id_has_run == ins_id){ //we've done it!
job_instance.wait_until_instruction_id_has_run = null
Expand Down Expand Up @@ -2206,6 +2202,14 @@ Dexter.LINK4 = 0.050801 //meters 2 inches
Dexter.LINK5 = 0.082551 //meters 3.25 inches // from pivot point to tip of the end-effector
//Dexter.LINKS = [0, Dexter.LINK1, Dexter.LINK2, Dexter.LINK3, Dexter.LINK4, Dexter.LINK5]

/*These are the HDI Link Lengths as of Jan 1, 2020:
Dexter.LINK1 = 0.2352
Dexter.LINK2 = 0.339092
Dexter.LINK3 = 0.3075
Dexter.LINK4 = 0.0595
Dexter.LINK5 = 0.08244
*/

Dexter.LINK1_v1 = Dexter.LINK1 * 1000000 //in microns
Dexter.LINK2_v1 = Dexter.LINK2 * 1000000 //in microns
Dexter.LINK3_v1 = Dexter.LINK3 * 1000000 //in microns
Expand Down Expand Up @@ -2284,12 +2288,16 @@ Dexter.prototype.set_link_lengths = function(job_to_start_when_done = null){
the_robot.J3_angle_min = Dexter.J3_ANGLE_MIN
the_robot.J4_angle_min = Dexter.J4_ANGLE_MIN
the_robot.J5_angle_min = Dexter.J5_ANGLE_MIN
the_robot.J6_angle_min = Dexter.J6_ANGLE_MIN
the_robot.J7_angle_min = Dexter.J7_ANGLE_MIN

the_robot.J1_angle_max = Dexter.J1_ANGLE_MAX
the_robot.J2_angle_max = Dexter.J2_ANGLE_MAX
the_robot.J3_angle_max = Dexter.J3_ANGLE_MAX
the_robot.J4_angle_max = Dexter.J4_ANGLE_MAX
the_robot.J5_angle_max = Dexter.J5_ANGLE_MAX
the_robot.J6_angle_min = Dexter.J6_ANGLE_MAX
the_robot.J7_angle_min = Dexter.J7_ANGLE_MAX
}
the_robot.link_lengths_set_from_dde_computer = true
the_robot.start_aux(job_to_start)
Expand Down Expand Up @@ -2904,6 +2912,7 @@ module.exports.Dexter = Dexter
module.exports.Human = Human
module.exports.Serial = Serial

var {RobotStatus} = require("./robot_status")
var Job = require("./job.js")
var {Instruction, make_ins} = require("./instruction.js")
Dexter.make_ins = make_ins
Expand Down
11 changes: 4 additions & 7 deletions robot_status.js → core/robot_status.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*issues
measured_angles now returns array of 5. But might we want array of 6 or 7?
proposal takes 1 arg, # of angles to return. Default=5, but could be 6 or 7 (or 1 thru 4)
*/

//Robot Status Class (as distinguished from the robot_status 1D array of 60 elts.
var RobotStatus = class RobotStatus{
constructor({robot_status="required"}){
Expand All @@ -25,7 +20,6 @@ var RobotStatus = class RobotStatus{
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else {
inspect(this.robot_status)
dde_error("RobotStatus.angle passed joint_number: " + joint_number +
"<br/> but the value of that is: " + result +
"<br/> when it should be a number." +
Expand Down Expand Up @@ -153,4 +147,7 @@ var RobotStatus = class RobotStatus{
}
return result
}
}
}

module.exports.RobotStatus = RobotStatus
var {Dexter} = require('./robot.js')
5 changes: 4 additions & 1 deletion core/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ var Socket = class Socket{
else if (i == 6) { //J7
converted_val = Math.round(arg_val / Socket.DEGREES_PER_DYNAMIXEL_UNIT) //convert degrees to dynamixel units to get dynamixel integer from 0 through 1023 going from 0 to 296 degrees
}
else { converted_val = Math.round(arg_val * 3600) } //still might be a NaN
else {//J1 thru J5 for J1, i == 0
converted_val = Math.round(arg_val * 3600) //still might be a NaN
//if(i == 1) { out("soc J2: " + arg_val + " arcsec: " + converted_val) } //degugging statement only
}
instruction_array_copy[index] = converted_val
}
return instruction_array_copy
Expand Down
26 changes: 14 additions & 12 deletions core/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function write_file(path, content, encoding="utf8"){
path)
}
else {
dde_error("Error writing file: " + path)
dde_error("Error writing file: " + path + "<br/>" + err.message)
}
}
}
Expand Down Expand Up @@ -444,17 +444,19 @@ function make_folder(path){
let path_array = path.split(folder_separator())
let path_being_built = ""
for(let path_part of path_array){
path_being_built += (folder_separator() + path_part)
path_being_built = adjust_path_to_os(path_being_built)

if(!file_exists(path_being_built)){
try{
fs.mkdirSync(path_being_built)
}
catch(err){
dde_error("In make_folder, could not make: " + path_being_built + "<br/>" +
err.message)
}
if(path_part != ""){ //often the first and last path_part will be ""
path_being_built += (folder_separator() + path_part)
path_being_built = adjust_path_to_os(path_being_built)

if(!file_exists(path_being_built)){
try{
fs.mkdirSync(path_being_built)
}
catch(err){
dde_error("In make_folder, could not make: " + path_being_built + "<br/>" +
err.message)
}
}
}
}
return true
Expand Down
Loading

0 comments on commit 2b6720e

Please sign in to comment.