Forked from madhephaestus/CoordinatedMotionAcrossDyIOChannels.java
Created
November 27, 2017 19:55
-
-
Save keionbis/b0397739b56e932f954722fb6275ca25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int [] vals = dyio.getAllChannelValues(); | |
//Set up the array of channels | |
ArrayList<ServoChannel> chans = new ArrayList<ServoChannel>(); | |
Log.enableDebugPrint(); | |
float time = 5; | |
for(int i=0;i<12;i++){ | |
chans.add(new ServoChannel(dyio.getChannel(i))); | |
} | |
//Set the DyIO into cached mode | |
dyio.setCachedMode(true); | |
int pos = 50; | |
for(int i=0;i<5;i++){ | |
if(pos==50){ | |
pos=200; | |
for(ServoChannel s:chans){ | |
//Store the cached value | |
s.getChannel().setCachedValue(pos); | |
} | |
//Flush all values to the DyIO | |
dyio.flushCache(time); | |
}else{ | |
pos=50; | |
for(ServoChannel s:chans){ | |
// set the servo positions individually | |
s.SetPosition(pos, time); | |
if(s.getChannel().getCachedMode()) | |
s.getChannel().flush(); | |
} | |
} | |
Thread.sleep((long) (time*1500)); | |
System.out.println("Sending "+pos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment