-
Notifications
You must be signed in to change notification settings - Fork 0
/
3jsbot_controls.js
43 lines (32 loc) · 1.26 KB
/
3jsbot_controls.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//////////////////////////////////////////////////
///// ROBOT DYNAMICS PLACEHOLDER
//////////////////////////////////////////////////
// CS148: add kinematics update from controls here
function robot_apply_controls() {
// apply robot controls to robot kinematics transforms and joint angles, then zero controls
// (for now) includes update of camera position based on base movement
// move camera with robot base
// CS148: do not delete this
// (need to pull this out and into 3jsbot support, at some point)
camera_controls.object.position.x += robot.control.xyz[0];
camera_controls.object.position.y += robot.control.xyz[1];
camera_controls.object.position.z += robot.control.xyz[2];
robot.origin.xyz[0] += robot.control.xyz[0];
robot.origin.xyz[1] += robot.control.xyz[1];
robot.origin.xyz[2] += robot.control.xyz[2];
robot.origin.rpy[0] += robot.control.rpy[0];
robot.origin.rpy[1] += robot.control.rpy[1];
robot.origin.rpy[2] += robot.control.rpy[2];
robot.control.xyz[0] = 0;
robot.control.xyz[1] = 0;
robot.control.xyz[2] = 0;
robot.control.rpy[0] = 0;
robot.control.rpy[1] = 0;
robot.control.rpy[2] = 0;
var x;
for( x in robot.joints )
{
robot.joints[x].angle += robot.joints[x].control;
robot.joints[x].control = 0;
}
}