error messages newbie

Hi,
I'm getting errors .
Please help
Mario

error:
Build options changed, rebuilding all
_1:3: error: uninitialized const 'servo_min' [-fpermissive]
_1:3: error: uninitialized const 'servo_max' [-fpermissive]
_1:4: error: expected initializer before 'p'
uninitialized const 'servo_min' [-fpermissive]

Code:
#include <Servo.h>
const float pi = 3.14159, theta_r = radians(48.0), theta_p = radians(23.2), theta_s[] = {-pi/3, 2pi/3, pi, 0, pi/3, -2pi/3},
RD = 2.395, PD = 3.3, L1 = 1.0, L2 = 4.72, z_home = 4.25, servo_min, servo_max, servo_mult
p[2][6] = {{PDcos(pi/6 + theta_p), PDcos(pi/6 - theta_p), PDcos(-(pi/2 - theta_p)), -PDcos(-(pi/2 - theta_p)), -PDcos(pi/6 - theta_p), -PDcos(pi/6 + theta_p)},
{PDsin(pi/6 + theta_p), PDsin(pi/6 - theta_p), PDsin(-(pi/2 - theta_p)), PDsin(-(pi/2 - theta_p)), PDsin(pi/6 - theta_p), PDsin(pi/6 + theta_p)}},
re[2][6] = {{RDcos(pi/6 + theta_r), RDcos(pi/6 - theta_r), RDcos(-(pi/2 - theta_r)), -RDcos(-(pi/2 - theta_r)), -RDcos(pi/6 - theta_r), -RDcos(pi/6 + theta_r)},
{RDsin(pi/6 + theta_r), RDsin(pi/6 - theta_r), RDsin(-(pi/2 - theta_r)), RDsin(-(pi/2 - theta_r)), RDsin(pi/6 - theta_r), RDsin(pi/6 + theta_r)}};
/*
theta_r = angle between attachment points
theta_p = angle between rotation points
theta_s = orientation of the servos
RD = distance to end effector attachment points
PD = distance to servo rotation points
L1 = servo arm length
L2 = connecting arm length
z_home = default z height with servo arms horizontal
servo_min = lower limit for servo arm angle
servo_max = upper limit for servo arm angle
servo_mult = multiplier to convert to milliseconds
p = location of servo rotation points in base frame [x/y][1-6]
re = location of attachment points in end effector frame [x/y][1-6] /
const int servo_pin[] = {9,3, 5, 11, 6, 10}, servo_zero[6] = {1710, 1280, 1700, 1300, 1680, 1300}; /

servo_pin = servo pin assignments,
servo_zero = zero angles for each servo (horizontal)
/
Servo servo[6];
/

Servos 0, 2, 4: reversed (+ = down, - = up)
Servos 1, 3, 5: normal */
void setup()
{
//Serial.begin(9600); for(int i = 0; i < 6; i++) {
(+ = up,

  • = down)
    servo.attach(servo_pin*);
    servo.writeMicroseconds(servo_zero); }
    delay(1000); }
    void loop() {
    static float pe[6] = {0,0,0,radians(0),radians(0),radians(0)}, theta_a[6], servo_pos[6],
    _q[3][6], r[3][6], dl[3][6], dl2[6]; /
    pe = location and orientation of end effector frame relative to the base frame [sway, surge, heave, pitch, roll, yaw)
    theta_a = angle of the servo arm
    servo_pos = value written to each servo
    q = position of lower mounting point of connecting link [x,y,x][1-6] r = position of upper mounting point of connecting link
    dl = difference between x,y,z coordinates of q and r
    dl2 = distance between q and r
    */_

I would strongly suggest not abusing the comma operator and putting each of those on its own line of code.

Seconded. All in favor say aye!

Welcome to the Forum. You might want to read Nick Gammon's two posts at the top of this Forum on guidelines for using the Forum, especially when posting code. Use the Ctrl-T keys to reformat your code in the IDE and the paste it into the code tags ("</>") before posting.

The two messages:

_1:3: error: uninitialized const 'servo_min' [-fpermissive]
_1:3: error: uninitialized const 'servo_max' [-fpermissive]

are telling you that, when you define a variable as a constant, you must supply an initial value for it. Otherwise, how does the compiler know what value to use for the constant?

I have no idea what this

(+ = up,

  • = down)

is supposed to do.

econjack:
I have no idea what this

(+ = up,

  • = down)

is supposed to do.

Nothing. It's a comment....

Regards,
Ray L.

thank you all, for quick and constructive response.
I will apply your suggestions and let you know the result

Mario

I followed your suggestions and I'v got new error

error:

Arduino: 1.6.4 (Mac OS X), Board: "Arduino Uno"

Instruct2:17: error: expected unqualified-id before 'const'
expected unqualified-id before 'const'

#include <Servo.h>
const float pi = 3.14159;
const float theta_r = radians(48.0);
const float theta_p = radians(23.2);
const float theta_s[] = { -pi / 3, 2 * pi / 3, pi, 0, pi / 3, -2 * pi / 3};
const float RD = 2.395;
const float PD = 3.3;
const float L1 = 1.0;
const float L2 = 4.72;
const float z_home = 4.25;
const float servo_min = 0;
const float servo_max = 32;
const float servo_mult = 6;
const float p[2][6] = {{PD * cos(pi / 6 + theta_p), PD * cos(pi / 6 - theta_p), PD * cos(-(pi / 2 - theta_p)), -PD * cos(-(pi / 2 - theta_p)), -PD * cos(pi / 6 - theta_p), -PD * cos(pi / 6 + theta_p)},
  {PD * sin(pi / 6 + theta_p), PD * sin(pi / 6 - theta_p), PD * sin(-(pi / 2 - theta_p)), PD * sin(-(pi / 2 - theta_p)), PD * sin(pi / 6 - theta_p), PD * sin(pi / 6 + theta_p)}
},
const float re[2][6] = {{RD * cos(pi / 6 + theta_r), RD * cos(pi / 6 - theta_r), RD * cos(-(pi / 2 - theta_r)), -RD * cos(-(pi / 2 - theta_r)), -RD * cos(pi / 6 - theta_r), -RD * cos(pi / 6 + theta_r)},
  {RD * sin(pi / 6 + theta_r), RD * sin(pi / 6 - theta_r), RD * sin(-(pi / 2 - theta_r)), RD * sin(-(pi / 2 - theta_r)), RD * sin(pi / 6 - theta_r), RD * sin(pi / 6 + theta_r)}
};

/*
theta_r = angle between attachment points
theta_p = angle between rotation points
theta_s = orientation of the servos
RD = distance to end effector attachment points
PD = distance to servo rotation points
L1 = servo arm length
L2 = connecting arm length
z_home = default z height with servo arms horizontal
servo_min = lower limit for servo arm angle
servo_max = upper limit for servo arm angle
servo_mult = multiplier to convert to milliseconds
p = location of servo rotation points in base frame [x/y][1-6]
re = location of attachment points in end effector frame [x/y][1-6] */
const int servo_pin[] = {9, 3, 5, 11, 6, 10}, servo_zero[6] = {1710, 1280, 1700, 1300, 1680, 1300}; /*
servo_pin = servo pin assignments,
servo_zero = zero angles for each servo (horizontal)
*/
Servo servo[6];
/*
Servos 0, 2, 4: reversed (+ = down, - = up)
Servos 1, 3, 5: normal */
void setup()
{
  //Serial.begin(9600); for(int i = 0; i < 6; i++) {
  (+ = up,
   - = down)
  servo[i].attach(servo_pin[i]);
  servo[i].writeMicroseconds(servo_zero[i]);
}
delay(1000);
}
void loop() {
  static float pe[6] = {0, 0, 0, radians(0), radians(0), radians(0)}, theta_a[6], servo_pos[6],
                       q[3][6], r[3][6], dl[3][6], dl2[6]; /*
pe = location and orientation of end effector frame relative to the base frame [sway, surge, heave, pitch, roll, yaw)
theta_a = angle of the servo arm
servo_pos = value written to each servo
q = position of lower mounting point of connecting link [x,y,x][1-6] r = position of upper mounting point of connecting link
dl = difference between x,y,z coordinates of q and r
dl2 = distance between q and r
*/

Line 17

const float p[2][6] = {{PD * cos(pi / 6 + theta_p), PD * cos(pi / 6 - theta_p), PD * cos(-(pi / 2 - theta_p)), -PD * cos(-(pi / 2 - theta_p)), -PD * cos(pi / 6 - theta_p), -PD * cos(pi / 6 + theta_p)},
  {PD * sin(pi / 6 + theta_p), PD * sin(pi / 6 - theta_p), PD * sin(-(pi / 2 - theta_p)), PD * sin(-(pi / 2 - theta_p)), PD * sin(pi / 6 - theta_p), PD * sin(pi / 6 + theta_p)}
},
const

semicolon, not comma

Awol thank you,
I followed your advise and I'v got new errors:

Arduino: 1.6.4 (Mac OS X), Board: "Arduino Uno"

Build options changed, rebuilding all
Instruct3.ino: In function 'void setup()':
Instruct3:46: error: expected primary-expression before '=' token
Instruct3:46: error: 'up' was not declared in this scope
Instruct3:47: error: expected primary-expression before '=' token
Instruct3:47: error: 'down' was not declared in this scope
Instruct3:48: error: expected ';' before 'servo'
Instruct3.ino: In function 'void loop()':
Instruct3:55: error: expected '}' at end of input
expected primary-expression before '=' token

#include <Servo.h>
const float pi = 3.14159;
const float theta_r = radians(48.0);
const float theta_p = radians(23.2);
const float theta_s[] = { -pi / 3, 2 * pi / 3, pi, 0, pi / 3, -2 * pi / 3};
const float RD = 2.395;
const float PD = 3.3;
const float L1 = 1.0;
const float L2 = 4.72;
const float z_home = 4.25;
const float servo_min = 0;
const float servo_max = 32;
const float servo_mult = 6;
const float p[2][6] = {{PD * cos(pi / 6 + theta_p), PD * cos(pi / 6 - theta_p), PD * cos(-(pi / 2 - theta_p)), -PD * cos(-(pi / 2 - theta_p)), -PD * cos(pi / 6 - theta_p), -PD * cos(pi / 6 + theta_p)},
  {PD * sin(pi / 6 + theta_p), PD * sin(pi / 6 - theta_p), PD * sin(-(pi / 2 - theta_p)), PD * sin(-(pi / 2 - theta_p)), PD * sin(pi / 6 - theta_p), PD * sin(pi / 6 + theta_p)}
};
const float re[2][6] = {{RD * cos(pi / 6 + theta_r), RD * cos(pi / 6 - theta_r), RD * cos(-(pi / 2 - theta_r)), -RD * cos(-(pi / 2 - theta_r)), -RD * cos(pi / 6 - theta_r), -RD * cos(pi / 6 + theta_r)},
  {RD * sin(pi / 6 + theta_r), RD * sin(pi / 6 - theta_r), RD * sin(-(pi / 2 - theta_r)), RD * sin(-(pi / 2 - theta_r)), RD * sin(pi / 6 - theta_r), RD * sin(pi / 6 + theta_r)}
};

/*
theta_r = angle between attachment points
theta_p = angle between rotation points
theta_s = orientation of the servos
RD = distance to end effector attachment points
PD = distance to servo rotation points
L1 = servo arm length
L2 = connecting arm length
z_home = default z height with servo arms horizontal
servo_min = lower limit for servo arm angle
servo_max = upper limit for servo arm angle
servo_mult = multiplier to convert to milliseconds
p = location of servo rotation points in base frame [x/y][1-6]
re = location of attachment points in end effector frame [x/y][1-6] */
const int servo_pin[] = {9, 3, 5, 11, 6, 10}, servo_zero[6] = {1710, 1280, 1700, 1300, 1680, 1300}; /*
servo_pin = servo pin assignments,
servo_zero = zero angles for each servo (horizontal)
*/
Servo servo[6];
/*
Servos 0, 2, 4: reversed (+ = down, - = up)
Servos 1, 3, 5: normal */
void setup()
{
  Serial.begin(9600); for(int i = 0; i < 6; i++) {
  (+ = up,
   - = down)
  servo[i].attach(servo_pin[i]);
  servo[i].writeMicroseconds(servo_zero[i]);
}
delay(1000);
}
void loop() {
  static float pe[6] = {0, 0, 0, radians(0), radians(0), radians(0)}, theta_a[6], servo_pos[6],
                       q[3][6], r[3][6], dl[3][6], dl2[6]; /*
pe = location and orientation of end effector frame relative to the base frame [sway, surge, heave, pitch, roll, yaw)
theta_a = angle of the servo arm
servo_pos = value written to each servo
q = position of lower mounting point of connecting link [x,y,x][1-6] r = position of upper mounting point of connecting link
dl = difference between x,y,z coordinates of q and r
dl2 = distance between q and r
*/

Thank you Delta_G,
you pointed me to the right direction and I'm error free for now

Mario

@Ray: It's within a comment block, but it seemed as though the idea was to uncomment later on. Evidently, that was the case. Either way, it's a crappy way to make a comment if that's the intent.

Hi,
I'v builded a smal Stewart platform using Uno and standard Servos.
my code has no errors, but servos are motionless.
Please help

#include <Servo.h>
const float pi = 3.14159,
            theta_r = radians(48.0),
            theta_p = radians(23.2),
            theta_s[] = { -pi / 3, 2 * pi / 3, pi, 0, pi / 3, -2 * pi / 3},
                        RD = 2.395,
                        PD = 3.3,
                        L1 = 1.0,
                        L2 = 4.72,
                        z_home = 4.25,
                        servo_min=radians(-80),
                        servo_max=radians(80),
                        servo_mult=400/(pi/4),
p[2][6] = {{PD * cos(pi / 6 + theta_p), PD * cos(pi / 6 - theta_p), PD * cos(-(pi / 2 - theta_p)), -PD * cos(-(pi / 2 - theta_p)), -PD * cos(pi / 6 - theta_p), -PD * cos(pi / 6 + theta_p)},
  {PD * sin(pi / 6 + theta_p), PD * sin(pi / 6 - theta_p), PD * sin(-(pi / 2 - theta_p)), PD * sin(-(pi / 2 - theta_p)), PD * sin(pi / 6 - theta_p), PD * sin(pi / 6 + theta_p)}
},
re[2][6] = {{RD * cos(pi / 6 + theta_r), RD * cos(pi / 6 - theta_r), RD * cos(-(pi / 2 - theta_r)), -RD * cos(-(pi / 2 - theta_r)), -RD * cos(pi / 6 - theta_r), -RD * cos(pi / 6 + theta_r)},
  {RD * sin(pi / 6 + theta_r), RD * sin(pi / 6 - theta_r), RD * sin(-(pi / 2 - theta_r)), RD * sin(-(pi / 2 - theta_r)), RD * sin(pi / 6 - theta_r), RD * sin(pi / 6 + theta_r)}
};

/*
theta_r = angle between attachment points
theta_p = angle between rotation points
theta_s = orientation of the servos
RD = distance to end effector attachment points
PD = distance to servo rotation points
L1 = servo arm length
L2 = connecting arm length
z_home = default z height with servo arms horizontal
servo_min = lower limit for servo arm angle
servo_max = upper limit for servo arm angle
servo_mult = multiplier to convert to milliseconds
p = location of servo rotation points in base frame [x/y][1-6]
re = location of attachment points in end effector frame [x/y][1-6] */
const int servo_pin[] = {9, 3, 5, 11, 6, 10}, 
servo_zero[6] = {1710, 1280, 1700, 1300, 1680, 1300};
/*
servo_pin = servo pin assignments,
servo_zero = zero angles for each servo (horizontal)
*/
Servo servo[6];
/*
Servos 0, 2, 4: reversed (+ = down, - = up)
Servos 1, 3, 5: normal (+ = up, - = down)
*/
void setup()
{
  //Serial.begin(9600);
  for (int i = 0; i < 6; i++)
  {

    servo[i].attach(servo_pin[i]);
    servo[i].writeMicroseconds(servo_zero[i]);
  }
  delay(1000);
}

void loop()
{
  static float pe[6] = {0, 0, 0, radians(0), radians(0), radians(0)}, theta_a[6], servo_pos[6], q[3][6], r[3][6], dl[3][6], dl2[6];

}
/*
pe = location and orientation of end effector frame relative to the base frame [sway, surge, heave, pitch, roll, yaw)
theta_a = angle of the servo arm
servo_pos = value written to each servo
q = position of lower mounting point of connecting link [x,y,x][1-6] r = position of upper mounting point of connecting link
dl = difference between x,y,z coordinates of q and r
dl2 = distance between q and r
*/

my code has no errors,

Yes, it does. You should have ONE statement per line.

You know that servos do not need to be attached to PWM pins, right?

void loop()
{
  static float pe[6] = {0, 0, 0, radians(0), radians(0), radians(0)}, theta_a[6], servo_pos[6], q[3][6], r[3][6], dl[3][6], dl2[6];

}

This is supposed to make the servos do something how?

but servos are motionless.

Well, gee, I wonder why. What do you suppose that this does?

 for (int i = 0; i < 6; i++)
  {

    servo[i].attach(servo_pin[i]);
    servo[i].writeMicroseconds(servo_zero[i]);
  }

Thank you PaulS.
I just started using Arduino, so I'm a Newbie. The code was a part of Instructables project.

what do you mean by "You know that servos do not need to be attached to PWM pins, right?"
I attached them to pins: 3,5,6,9,10,11. If I run example Servo Sweep the all work OK
Mario

The servos don't move because you haven't told them to move, it seems to me.

I attached them to pins: 3,5,6,9,10,11.

I know that. And, those pins are all PWM capable pins. You could have used 2, 3, 4, 5, 6, and 7 (if they are not being used for other things). The pins that servos are attached to do not HAVE to be capable of PWM.

AWOL:
The servos don't move because you haven't told them to move, it seems to me.

any suggestions how to change the code to move the servos

PaulS:
I know that. And, those pins are all PWM capable pins. You could have used 2, 3, 4, 5, 6, and 7 (if they are not being used for other things). The pins that servos are attached to do not HAVE to be capable of PWM.

I already attache them to pins 3,5,6,9,10,11. What would be different if I attache them to 2,3,4,5,6,7

regards
Mario

How did the Instructables tutorial move the servos?

I already attache them to pins 3,5,6,9,10,11. What would be different if I attache them to 2,3,4,5,6,7

Nothing. I'm simply pointing out that there is no need to use only PWM pins for servos. Servos are not positioned using analogWrite().

AWOL:
How did the Instructables tutorial move the servos?

I don't know. I only have the code I pasted in this topic
mario