Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
cfry committed Apr 5, 2024
1 parent 0fdb47e commit c40ed11
Show file tree
Hide file tree
Showing 17 changed files with 1,924 additions and 59 deletions.
102 changes: 91 additions & 11 deletions core/dexter_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ Dexter.prototype.defaults_url = function(){
return "Dexter." + this.name + ":/srv/samba/share/Defaults.make_ins"
}

Dexter.prototype.defaults_alt_url = function(){
return "Dexter." + this.name + ":/srv/samba/share/make_ins/Defaults.make_ins"
}

/*Gets the Defaults.make_ins file from Dexter and
sets this.defaults_lines with an array of strings (1 string per line)
Dexter.dexter0.defaults_read()
Dexter.dexter0.defaults_lines

/*Obsolete, pre apr 4 2024 version
//Gets the Defaults.make_ins file from Dexter and
// sets this.defaults_lines with an array of strings (1 string per line)
// Dexter.dexter0.defaults_read()
// Dexter.dexter0.defaults_lines
//the callback is optional.
//when set_link_lengths called defaults_read,
//it has the callback call Dexter.prototype.start_aux
*/
Dexter.prototype.defaults_read = function(callback = null){
let the_url = this.defaults_url()
let the_dex_inst = this
let normal_defaults_read_cb = (function(err, content){
if(err) { //Often becuse Defaults.make_ins isn't on the Dexter.
if(err) { //Often because Defaults.make_ins isn't on the Dexter.
//so print a warning and use Dexter.defaults instead
//and let the Job proceed
if (typeof(err) !== "string"){
Expand All @@ -57,11 +62,11 @@ Dexter.prototype.defaults_read = function(callback = null){
if (callback) {
callback.call(the_dex_inst, null)
}
/*dde_error("Dexter." + the_dex_inst.name + ".defaults_read errored with url: " +
the_url + "<br/>and error message: " +
err.message +
"<br/>You can set a Job's robot to the idealized defaults values by<br/>passing in a Job's 'get_dexter_defaults' to true.")
*/
//dde_error("Dexter." + the_dex_inst.name + ".defaults_read errored with url: " +
// the_url + "<br/>and error message: " +
// err.message +
// "<br/>You can set a Job's robot to the idealized defaults values by<br/>passing in a Job's 'get_dexter_defaults' to true.")
}
else {
try {
Expand All @@ -84,6 +89,81 @@ Dexter.prototype.defaults_read = function(callback = null){
})
read_file_async(the_url, undefined, normal_defaults_read_cb)
}
*/

/* Apr 4, 2024 version
defaults_read: populate Dexter.defaults with the right values.
Never errors.
//Its signature is the same as pre apr 4, 2024 version
//except for the name of the arg.
Algorithm:
first try to get /s/s/s/Defaults.make_ins.
If that doesn't exist, try to get /s/s/s/make_ins/Defaults.make_ins
If that doesn't exist, use "default_defaults".
If parsing one of the Defaults.make_ins files fails,
use the default_default.
Once we finally set Dexter.defaults with the right values,
call the callback to defaults_read with args: the_dex_inst, null.
The 1 existing call to defaults_read is in robot.js line 2731 in
set_link_lengths_using_node_server
stays exactly the same: the_dexter.defaults_read(callback)
*/
Dexter.prototype.defaults_read = function(the_defaults_read_cb = null){
//the below 5 are all closed over in read_file_async_callback
out("Now attempting to read file: Defaults.make_ins for initializing Dexter.")
let make_ins_urls = [this.defaults_url(), this.defaults_alt_url()]
let orig_make_ins_urls = make_ins_urls.slice()//make a copy for warning messages
let the_dex_inst = this
let read_file_async_callback_container = [] //for closure self reference
let now_trying_make_ins_url = null

let read_file_async_callback = function(err, content) {
if(err){
warning("Failed to find: " + now_trying_make_ins_url + " due to: " + err)
if(make_ins_urls.length > 0){ //more urls to try
now_trying_make_ins_url = make_ins_urls.shift()
read_file_async(now_trying_make_ins_url, undefined, read_file_async_callback_container[0])
}
else { //no more urls to try so use default_defaults
the_dex_inst.defaults = JSON.parse(JSON.stringify(Dexter.defaults))
warning("Could not read any of: " + orig_make_ins_urls +
"<br/>so Dexter." + the_dex_inst.name +
".defaults has been set to a copy of Dexter.defaults, the 'default defaults'."
)
if (the_defaults_read_cb) {
the_defaults_read_cb.call(the_dex_inst, null)
}
}
}
else { //got good content
out("Found: " + now_trying_make_ins_url, "green")
try{
the_dex_inst.defaults_set_lines_from_string(content)
the_dex_inst.defaults_lines_to_high_level()
}
catch(err){
let defaults_copy = JSON.parse(JSON.stringify(Dexter.defaults))
the_dex_inst.defaults = defaults_copy
warning("Could not parse " + orig_make_ins_urls[0] +
" due to:<br/>" + err.message +
"<br/>so Dexter." + the_dex_inst.name +
".defaults has been set to a copy of Dexter.defaults."
)
}//end catch
if (the_defaults_read_cb) {
the_defaults_read_cb.call(the_dex_inst, null)
}
}//end else
} //end of read_file_async_callback def.

read_file_async_callback_container[0] = read_file_async_callback

//do the first call to read_file_async_callback
//the 2nd call is made within read_file_async_callback
now_trying_make_ins_url = make_ins_urls.shift()
read_file_async(now_trying_make_ins_url, undefined, read_file_async_callback)
} //end defaults_read

Dexter.prototype.defaults_write_return_string = function(){
this.defaults_high_level_to_defaults_lines()
Expand Down
9 changes: 7 additions & 2 deletions core/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
global.dde_version = "3.9.1" //require("../package.json").version
global.dde_release_date = "Mar 23, 2024" //require("../package.json").release_dat9
global.dde_version = "3.9.2" //require("../package.json").version
global.dde_release_date = "Apr 5, 2024" //require("../package.json").release_dat9
console.log("dde_version: " + global.dde_version + " dde_release_date: " + global.dde_release_date +
"\nRead electron_dde/core/job_engine_doc.txt for how to use the Job Engine.\n")

Expand Down Expand Up @@ -121,6 +121,7 @@ function run_shell_cmd(cmd_string, options={}, cb=run_shell_cmd_default_cb){
var child_process = require("child_process")
var WebSocket = require('ws')
var fs = require('fs')
var mathjs = require('mathjs')

var Socket = require("./socket.js")

Expand All @@ -141,6 +142,8 @@ var {Root} = require("./object_system.js")
var Coor = require("../math/Coor.js")
var Kin = require("../math/Kin.js")
var Vector = require("../math/Vector.js")
var DH = require("../math/DH.js")

var {sind, cosd, tand, asind, acosd, atand, atan2d} = require("../math/Trig_in_Degrees.js")
var Job = require("./job.js")

Expand Down Expand Up @@ -188,6 +191,7 @@ var {Py} = require("./py.js")
global.child_process = child_process
global.WebSocket = WebSocket
global.fs = fs
global.mathjs = mathjs
global.Socket = Socket
global.to_source_code = to_source_code
global.keep_alive_value = false
Expand Down Expand Up @@ -222,6 +226,7 @@ global.Control = Control
global.IO = IO
global.Job = Job
global.Vector = Vector
global.DH = DH
global.Kin = Kin
global.FPGA = FPGA

Expand Down
54 changes: 54 additions & 0 deletions core/instruction_dexter.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,60 @@ Instruction.Dexter.move_to = class move_to extends Instruction.Dexter{
}
}

Dexter.prototype.get_dh_last_angles = function() {
if (!this.dh_last_angles){
this.dh_last_angles = [0, 0, 90, 0, 0, 0] //the default initial angles
}
return this.dh_last_angles
}

Dexter.prototype.set_dh_last_angles = function(new_last_angles) {
this.dh_last_angles = new_last_angles
}

Instruction.Dexter.move_to_DH = class move_to_DH extends Instruction.Dexter{
constructor (xyz = [],
orientation = [
[-1, 0, 0],
[0, 0, 1],
[0, 1, 0]
],
dh_mat,
robot
){
super()
this.xyz = xyz
this.orientation = orientation
this.dh_mat = dh_mat
this.robot = robot
}
do_item (job_instance){
if(!this.robot) { this.set_instruction_robot_from_job(job_instance) }
if(!this.dh_mat){
//total hack to make my code work:
//var folder = "C:/Users/james/Documents/dde_apps/2021/Code/MoveWithForce/data_set_HDI_000047/"
//var dh_mat = DH.parse_dh_mat_file(folder + "dh_mat.out")
if(this.robot.defaults && this.robot.defaults.dh_mat) {
this.dh_mat = this.robot.defaults.dh_mat
}
else {
this.dh_mat = Dexter.defaults.dh_mat
}
}
let old_last_angles = this.robot.get_dh_last_angles()
let new_last_angles = DH.inverse_kinematics(this.xyz, this.orientation, this.dh_mat, old_last_angles) //Also kind of a hack to get the code to work
if(Vector.max(Vector.abs(new_last_angles)) > 180){
//Vector.max(Vector.abs(old_last_angles))){ //in place of 180, this returns something more than Vector.max(Vector.abs(new_last_angles)) so it cauess an error. Asj James W.
dde_error("Dexter.move_to_DH: Kinematics Failure")
}
else {
this.robot.set_dh_last_angles(new_last_angles)
//return this.robot.move_all_joints(new_last_angles)
job_instance.send(make_ins("a", ...new_last_angles), this.robot)
}
}
}

Instruction.Dexter.pid_move_to = class pid_move_to extends Instruction.Dexter{
constructor (xyz = [],
J5_direction = [0, 0, -1],
Expand Down
54 changes: 40 additions & 14 deletions core/robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2062,19 +2062,44 @@ Dexter.prototype.move_to = function(xyz = [],
j7_angle,
this)
}

//note that a workspace_pose = null, will default to the job's default workspace_pose
Dexter.move_to = function(xyz = [],
J5_direction = [0, 0, -1],
config = Dexter.RIGHT_UP_OUT,
workspace_pose = null,
j6_angle = [0],
j7_angle = [0],
robot
){
return new Instruction.Dexter.move_to(xyz, J5_direction, config, workspace_pose, j6_angle, j7_angle, robot)
J5_direction = [0, 0, -1],
config = Dexter.RIGHT_UP_OUT,
workspace_pose = null,
j6_angle = [0],
j7_angle = [0],
robot
){
return new Instruction.Dexter.move_to(xyz, J5_direction, config, workspace_pose, j6_angle, j7_angle, robot)
}


Dexter.prototype.move_to_DH = function(xyz = [],
orientation = [[-1, 0, 0],
[0, 0, 1],
[0, 1, 0]
],
dh_mat,
robot
) {
return Dexter.move_to_DH(xyz,
orientation,
dh_mat,
this)
}

Dexter.move_to_DH = function(xyz = [],
orientation = [[-1, 0, 0],
[0, 0, 1],
[0, 1, 0]
],
dh_mat,
robot
){
return new Instruction.Dexter.move_to_DH(xyz, orientation, dh_mat, robot)
}


//the same as move_to but generates a "P" oplet
Dexter.prototype.pid_move_to = function(xyz = [],
J5_direction = [0, 0, -1],
Expand Down Expand Up @@ -2619,13 +2644,14 @@ Dexter.prototype.set_link_lengths = function(job_to_start_when_done = null) {
this.set_link_lengths_using_node_server(job_to_start_when_done)
}
else {
/*replaced Apr 3, 2024 with the below 2 lines. Requested by James W to help with
his proxy server.
job_to_start_when_done.stop_for_reason("errored_from_dexter_connect",
"While attempting to set_link_lengths, " +
" can't connect to Dexter." + this.name)
//dde_error("Dexter." + this.name + "'s node server is not responding.<br/>" +
// "Set the Job's 'get_dexter_defaults' param to false to avoid looking for Defaults.makeins file and<br/>" +
// "initialize Dexter defaults to their idealized values.")
//this.set_link_lengths_using_job(job_to_start_when_done)
*/
this.defaults = Dexter.defaults
this.start_aux(job_to_start_when_done)
}
} else { //simulating, so set to idealized values
this.defaults = Dexter.defaults
Expand Down
1 change: 1 addition & 0 deletions core/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ module.exports.file_content = file_content //depricated
//and just returns the string if data happens to be a string
//for referencing a file on dexter, path example 'Dexter.dexter0:/srv/samba/share/errors
function read_file_async(path, encoding="utf8", callback){
console.log("top of read_file_async passed path of: " + path)
let dex_instance = path_to_dexter_instance(path)
if(dex_instance){
//if(node_server_supports_editor(dex_instance)) {
Expand Down
4 changes: 2 additions & 2 deletions doc/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<details class="doc_details"><summary>About</summary>
This is <a href="http://hdrobotic.com/" target="_blank">Dexter</a> Development Environment<br/>
version: <span id="dde_version_id">3.9.1</span><br/>
released: <span id="dde_release_date_id">Mar 23, 2024</span>
version: <span id="dde_version_id">3.9.2</span><br/>
released: <span id="dde_release_date_id">Apr 5, 2024</span>
<p></p>
DDE helps you create, debug, and send software to a Dexter robot.
You can use any JavaScript augmented with DDE-specific functions to help find out about,
Expand Down
1 change: 0 additions & 1 deletion doc/known_issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<ul>
<li>EZTeach_base.js, <code>Init_Run()</code> has not been updated yet as this is tricky.
It is accessible from DDE menu/Insert/ezTeach, but is now broken.</li>
<li>Defaults.make_ins processing in DDE is new and may have some bugs in it.</li>
<li>Sometimes, on Windows 10 computers, the editor pane won't accept typed in characters.
Workaround: Shrink and expand the DDE window or click outside the DDE window
then click back in it.</li>
Expand Down
37 changes: 35 additions & 2 deletions doc/ref_man.html
Original file line number Diff line number Diff line change
Expand Up @@ -6883,6 +6883,38 @@
) </code></pre>
</details> <!--end move_to -->

<details id="Dexter.move_to_DHdoc_id" class="doc_details"><summary>move_to_DH</summary>
Like <code>Dexter.move_to</code> in functionality but more acccurate since its
customized to the particular Dexter used.
<br/>
<i>Parameters</i><br/>
<b>xyz</b> An array of 3 numbers, x, y and z in meters. Required.
The numbers are floating point, can be negative or positive.
The possible range of each number depends on the other numbers.
The numbers will generally be > -1 and < 1.<br/>
<b>orientation</b> An array of length 3 whose elements are also an
array of length 3. The inner arrays contain elements that are either
-1, 0, or 1. Default:<br>
<code>[[-1, 0, 0],[0, 0, 1],[0, 1, 0]]</code><br/>
<b>dh_mat</b> An array of length 6. The elements are each arrays
of length 4 of floating point numbers. Normally this is automatically
retrieved from the Defaults.make_ins file for the specific robot.
This matrix is made during the calibration of the robot. It differs
from Dexter to Dexter because Dexters differ (very slightly) in their
link lengths and joint positions.<br/>
<i>Examples:</i>
<pre><code>
new Job({name: "my_job",
do_list: [
Dexter.move_to_DH([0.1, 0.2, 0.2])
]}) </code></pre>
<pre><code>
new Job({name: "my_job",
do_list: [
Dexter.dexter0.move_to_DH([0.1, 0.2, 0.2])
]}) </code></pre>
</details>

<details id="Dexter.move_to_relative_doc_id" class="doc_details"><summary>move_to_relative</summary>
This instruction is similar to <code>Dexter.move_to</code> except that the passed in
xyz array values (in meters) that are ADDED to Dexter's
Expand Down Expand Up @@ -8827,8 +8859,9 @@

<details id="servo_doc_id" class="doc_details"><summary>Servo</summary>
Dexter's, as of March 2024, typically have 7 joints, each with its own motor.
Joints 6 and 7 are different than the others. The Servo class helps
control the fine points of these motors.<br/>
Joints 6 and 7 are different than the others. They use Dynamixel servos whereas
the other joints use stepper motors paired with Haddongton's own optical encorders.
The Servo class helps control the fine points of Dynamixel servos.<br/>
For more typical control via Job instructions, see
<a href="#" onclick="open_doc(end_effector_instructions_doc_id)">End Effector Instructions</a>
<!-- Here's an article comparing the two:
Expand Down
Loading

0 comments on commit c40ed11

Please sign in to comment.