by l3v3rz » Wed Oct 17, 2012 9:13 am
by l3v3rz
Wed Oct 17, 2012 9:13 am
Its possible to achieve smooth motion with the lib. When moving between two points you need to calculate the "inbetween positions" ot tweens to get that smooth motion. So rather than a servo going from position 20 -> 40 you need it to go to 20 -> 25 -> 30 ->35 -> 40. There is a command "PlayPose" in wckMotion class that will do that for you. i.e. wckMotion.PlayPose(duration, no_steps, position_array, true); The parameters are as follows:
duration = time to take in ms i.e 1000.
no_steps = number of tweens i.e. 10 (this would make each step 100ms long (min is 25ms)
position_array = byte[] with servo positions i.e. 16 for normal robuilder
true/false = determines whether it need to read the current position of the servos first. In a sequence of moves use true for the first use and the false afterwards for speed as it remembers the last command psoition
So to take up basic pose would be as follows (roughly)
- Code: Select all
PCremote p = new PCremote("com1");
wckMotion w = new wckMotion(p);
w.PlayPose(3000, 10, new byte[] {125, 179, 199, 88, 108, 126, 72, 49, 163, 141, 51, 47, 49, 199, 205, 205 }, true);
Playpose also has variations Playfile (play moves from a csv file) and PlayMatrix that takes a matrix of moves. So you can store built in moves in a csv file and play them like stock motions - I do this in my android app.
Also the interpolation by default is linear or equal steps, but there is a variation where you can pass a type in that switches modes and allows for different types (Accel, De Accel or Accel then Deaccel). This is based on code published by
RN1A on this very forum.
I wish more poeple would share code .. ultimately its the code that makes robot
Its possible to achieve smooth motion with the lib. When moving between two points you need to calculate the "inbetween positions" ot tweens to get that smooth motion. So rather than a servo going from position 20 -> 40 you need it to go to 20 -> 25 -> 30 ->35 -> 40. There is a command "PlayPose" in wckMotion class that will do that for you. i.e. wckMotion.PlayPose(duration, no_steps, position_array, true); The parameters are as follows:
duration = time to take in ms i.e 1000.
no_steps = number of tweens i.e. 10 (this would make each step 100ms long (min is 25ms)
position_array = byte[] with servo positions i.e. 16 for normal robuilder
true/false = determines whether it need to read the current position of the servos first. In a sequence of moves use true for the first use and the false afterwards for speed as it remembers the last command psoition
So to take up basic pose would be as follows (roughly)
- Code: Select all
PCremote p = new PCremote("com1");
wckMotion w = new wckMotion(p);
w.PlayPose(3000, 10, new byte[] {125, 179, 199, 88, 108, 126, 72, 49, 163, 141, 51, 47, 49, 199, 205, 205 }, true);
Playpose also has variations Playfile (play moves from a csv file) and PlayMatrix that takes a matrix of moves. So you can store built in moves in a csv file and play them like stock motions - I do this in my android app.
Also the interpolation by default is linear or equal steps, but there is a variation where you can pass a type in that switches modes and allows for different types (Accel, De Accel or Accel then Deaccel). This is based on code published by
RN1A on this very forum.
I wish more poeple would share code .. ultimately its the code that makes robot