JamesNewton / AdvancedRoboticsWithJavascript

A course in Robotics programming using Javascript in the Dexter Development Environment
The Unlicense
7 stars 8 forks source link

using Math.random() #16

Open faithokamoto opened 5 years ago

faithokamoto commented 5 years ago
var bend_over = function() {
    let angle = Math.random() * 360
    return Dexter.move_all_joints([angle, [45]])
}

var celebrate = function() {
    let cmds = []
    cmds.push(Dexter.move_all_joints([NaN, NaN, NaN, [30], [30]]))
    cmds.push(Dexter.move_all_joints([NaN, NaN, NaN, [-30], [-30]]))
    return cmds
}

var whee = function(times) {
    let cmds = []
    for (var i = 0; i < times; i++) {
        cmds.push(bend_over())
        cmds.push(celebrate())
        cmds.push(Dexter.move_all_joints(Dexter.HOME_ANGLES))
    }
    return cmds
}

new Job({name: "random_wave", do_list: [whee(10)]})
cfry commented 5 years ago

See the doc on move_all_joints. the max angle for J1 is the value of Dexter.J1_ANGLE_MAX

On Mon, Jul 1, 2019 at 4:09 PM b0bb1e notifications@github.com wrote:

var bend_over = function() { let angle = Math.random() * 360 return Dexter.move_all_joints([angle, [45]]) }

var celebrate = function() { let cmds = [] cmds.push(Dexter.move_all_joints([NaN, NaN, NaN, [30], [30]])) cmds.push(Dexter.move_all_joints([NaN, NaN, NaN, [-30], [-30]])) return cmds }

var whee = function(times) { let cmds = [] for (var i = 0; i < times; i++) { cmds.push(bend_over()) cmds.push(celebrate()) cmds.push(Dexter.move_all_joints(Dexter.HOME_ANGLES)) } return cmds }

new Job({name: "random_wave", do_list: [whee(10)]})

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JamesNewton/AdvancedRoboticsWithJavascript/issues/16?email_source=notifications&email_token=AAJBG7MO2O24JNID3AD64FTP5JP6NA5CNFSM4H4VSUL2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4XEDLQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJBG7LKMKGQQQ6QHDWT5HLP5JP6NANCNFSM4H4VSULQ .

faithokamoto commented 5 years ago

I know that the max angle is 360