Open up DDE, click File / New, and copy in the following:
new Job({
name: "Example_1",
do_list: [
Dexter.move_all_joints([0, 0, 0, 0, 0]),
Dexter.move_all_joints([30, 0, 0, 0, 0]),
Dexter.move_all_joints([30, 30, 0, 0, 0]),
Dexter.move_all_joints([30, 30, 30, 0, 0]),
Dexter.empty_instruction_queue(),
Dexter.move_all_joints([0, 0, 0, 0, 0])
]
})
/*
To Run: If you don't actually have a Dexter robot arm, go to the Simulate
mode in the lower right corner.
Place the cursor anywhere in the Editor pane then click the 'Eval' button.
A new button is created below, this is called a 'Job button'.
Click the Job button to run the Job (this will physically move Dexter).
(Scroll down)
Notice:
The progress bar animation in Output pane while the Job is running.
Click the button again to run the Job again.
Edit the above code in order to do the following:
a. Change the name of the Job.
b. Make the progress bar say "of 10" instead of "of 6"
c. Make the Jobs bar display two Jobs
Edit the job above in DDE to meet those challenges, then save the file and upload it as your answer to this assignment.
The code in this file is an example of a Job.
A Job is the main mechanism for organizing and running Dexter Instructions.
A Job consists of Job parameters.
In this example the Job has two Job parameters:
- name
- do_list
The Job's name can be set to any string, which will be displayed on its Job
button.
If a new Job is made with the same name as an existing Job,
it will overwrite the existing Job.
A do_list is an array of Instructions.
There are a few different types of Instructions, mainly:
- Dexter
- Robot (Replaced with 'Control' in versions 3.0+)
- functions
The only way to communicate with Dexter is through Dexter Instructions.
Dexter Instructions will start with "Dexter." followed by the Instruction's
name.
Some common Dexter Instructions include:
Dexter.move_all_joints()
Dexter.move_to()
Dexter.sleep()
Dexter.empty_instruction_queue()
To see a complete set of Dexter Instructions see
Utility_Dexter_All_Instructions.dde
in the Utilities folder.
When 'Eval' is clicked (with the cursor in the Editor pane),
the code within the editor will be run.
The code shown above defines a Job but does not start it.
When a Job is defined its Job button is visible on the Jobs bar.
Jobs can be un-defined by clicking the 'Undef' button.
When the Job button is clicked the Job is started and its do_list is run.
The Job button will be a different color depending on its status.
Hover the mouse over the Job button and a tool tip will display the current
status.
The input argument to new Job() is just a javascript (JS) literal object, such as:
var my_obj = {foo: 10, bar: 20}
In DDE white space like spaces, tabs and newlines do not matter
so we can reformat it to make it easier to read:
var my_obj = {
foo: 10,
bar: 20
}
The same is done with the do_list array:
var my_obj = {
foo: 10,
bar: [1, 2, 3]
}
is the same as
var my_obj = {
foo: 10,
bar: [
1,
2,
3
]
}
It is important to keep in mind that the items within a do_list
are array elements.
Normal javascript cannot be placed directly on a do list in the same way
that
something like this would not be done:
var bar = [1, 2, var x = 3]
or
var bar = [
1,
2,
for(let i = 0; i < 3; i++){out(i)}
]
or
var bar = [
1
2
3
]
(notice the missing commas)
For how to correctly run normal javascript on a do_list see Example 3.
*/
Copyright James Wigglesworth at Haddington Dynamics, Inc, 2020 used by permission (email 2020/06/15)
Once you have your code done Start by clicking "Submit Assignment" in the upper right. It will default to "file upload" just browse and attach the file you save from DDE.
In the next section, you will follow along with Fry (an MIT professor who wrote DDE) while he explains "How to Think Like a Computer". You will probably also meet Fry during one of our video calls, if things go well.