first my English language its not so much good
Pyserial sending an array contain poses for the servos and Arduino receive it just like this [510, 516, 507, 507, 513, 511, -1, 511] how can i apply this array on the servos and make the servos move ?
if name in line:
#print line
s=line
file.close()
m=s.index('[')
l=s[m:]
i=0
x=len(l)-2
while i<=x :
i=i+1
w=l[i-1]
ser.write(w)
void Playposes(){
// String r="";
int i=0;
// while (Serial.available()==0){
//}
while (Serial.available()==0){
}
while (Serial.available()>0){
do {[/quote]
while (Serial.available()==0){
}
while (Serial.available()>0){
r=Serial.read();
x= r;
arr[i]=r;
i=i+1;
Serial.print(i);
Tell us how the received data is stored in the Arduino.
If it is stored in an array then all that would be necessary is something like
for (byte n = 0; n < numServos; n++) {
servo[n].write(servoPos[n]);
}
...R
for saving the poses i using 2 programs Python and Arduino
void Recordposes(){
id = 1;
String toSend;
toSend="[";
while (id <= SERVOCOUNT){ // my arm have 8 servos
pos = ax12GetRegister(id, 36, 2); // this instruction will give me all poses of the id servos
if (id == 8){
toSend=toSend+String(pos);
}
else {
toSend=toSend+String(pos)+", ";
}
id++;//SERVOCOUNT
}
toSend=toSend+"]";
Serial.println(toSend);
MenuOptions();
}
and this one in PYthon
if inp =='5':
N = "enter name of the pose"
print (N)
name=raw_input(">> ") # enter the name of the pose you want to save it
ser.write('5')
position=ser.readline() # the position will received from Arduino by using serialbort
final=name+position
print (name)+(position)
file = open("text.txt","a") # open an txt in the pc
file.write(final) # save the poses inside it
file.close()
my problem is i want send one of saved poses to the arm and move it to the this saved pose
msh8:
please can you explain more what did you mean by this ?
I mean "it looks like you might have a case of out-of-bounds array accesses here, but I can't be sure because you didn't post the important bits of your code"
Groove:
I mean "it looks like you might have a case of out-of-bounds array accesses here, but I can't be sure because you didn't post the important bits of your code"
[510, 516, 507, 507, 513, 511, -1, 511]
this is the saved pose so i want to apply this array on the servos for example:
Servo id 1 = 510
servo id 2 = 516
msh8:
for saving the poses i using 2 programs Python and Arduino
....
my problem is i want send one of saved poses to the arm and move it to the this saved pose
I did not ask (in Reply #4) how the data is received in the Arduino but how it is stored. Are you storing the data in the String called toSend ?
I see a few issues with that.
Why is it called "toSend" when the data has just been received? - very confusing
Why is the data in a String when what you really need are numbers to be used with servo.write()
And it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.
If you study the first link I gave you in Reply #1 you will see that it uses cstrings and has a parse example that illustrates how to convert the received characters into numbers. I recommend that you create an int array with enough elements for all of your servos and save the received values into it. Then you can control the servos with the code I posted in Reply #4.
it stored by string called tosend so i convert it to int right now
and i try with bioloid.setNextPose(); if you know it and its not working also and for your code i try it
there is no problem with compiling but it doesn't do anything
Robin2:
I did not ask (in Reply #4) how the data is received in the Arduino but how it is stored. Are you storing the data in the String called toSend ?
I see a few issues with that.
Why is it called "toSend" when the data has just been received? - very confusing
Why is the data in a String when what you really need are numbers to be used with servo.write()
And it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.
first which part of the code you want its's very long
second i just want to way to apply this number 512 on servo number 1 for example but without using Servo.attach and servo.write because all of the 8 servos are connected to the Arduino by 1 cable so i can't control with the pin
in the picture you will see the pin how is connected to the servos
OK, you don't want to show your code, yet you've posed your question in the programming forum.
You've posted instead, a completely pointless 240kB document.
Does that strike you as just a little perverse?
I find some solution by using bioloid library this library coming with reactor program you can find it in test sketches (reactor)
r=st.toInt();
mo=mo+1;
bioloid.setNextPose(mo,r);
}
bioloid.readPose(); // read in current servo positions to the curPose buffer
bioloid.interpolateSetup(1000); // setup for interpolation from current->next over 1/2 a second
while(bioloid.interpolating > 0){ // do this while we have not reached our new pose
bioloid.interpolateStep(); // move servos, if necessary.
delay(3);
Groove:
OK, you don't want to show your code, yet you've posed your question in the programming forum.
You've posted instead, a completely pointless 240kB document.
Does that strike you as just a little perverse?
i tell you before the code are so long and which part you want i can paste it
anyway if you want the code i can send it i don't have any problem with this but when you want write an answer for someone write it in courteous answer because from the first i wrote my language are not good
sorry for taking your time
Mr,Robin2 the document help me so much thank you once again .