Redefining to Variable compile error

Why is this a compile time error?? I’ve added pointers to the error lines in the code. I’m using Basic Micro Studio rev #30.

[code]’
’ Program: Control Software for W.A.L.T.E.R. - the Wheeled Autonomous Learning Terrain Exploring Rover
’ Author: Dale Weber [email protected]
’ Date: 04-Jun-2010
’ Version: 2.10
’ Purpose: Original

’ Copyright © 2010 Dale Weber. Usage permitted under the BSD License

’ Processor: Basic Atom Pro on a BotBoard II
’ Hardware: Dimension Engineering Sabertooth 2X5 Motor Controller
’ GHM-04 Motors with QME-01 Shaft Encoders (2)
’ HS-485HB Servos (4 Steering, 1 Arm Pan)
’ HS-645MG Servos (2)
’ 7.2V @ 2800 mAH NiMH Battery Pack (Motors)
’ 7.2V @ 2800 mAH Battery Pack (Electronics)
’ 6.0V @ 2800 mAH Battery Pack (Servos)


’ Constants

StepsPerDegree con 133.3 ’ Counts per degree of servo movement.

TRUE con 1
FALSE con 0

’ Steering servo pins

RightFront con 0
LeftFront con 1
RightRear con 2
LeftRear con 3

’ Steering servo direction addustments

RFDir con 0
LFDir con 0
RRDir con 1
LRDir con -1

’ Steering positions in degrees

CurrRFAngle var sword
CurrLFAngle var sword
CurrRRAngle var sword
CurrLRAngle var sword
’ Actual steering servo positions
CurrRFPos var sword
CurrLFPos var sword
CurrRRPos var sword
CurrLRPos var sword

CurrSpeed var sword

’ Initialize variables

CurrRFAngle = 0
CurrLFAngle = 0
CurrRRAngle = 55
CurrLRAngle = -55

CurrSpeed = 0

enablehservo

’ Initialize

’ Tell everyone we are here
sound 9, [150\5000, 150\4400, 150\5000]
’ Calculate steering servo positions
'gosub CalculatePos [CurrRFAngle, CurrLFAngle, CurrRRAngle, CurrLRAngle]
gosub CalculatePos [0, 0, 55, -55]
’ Send servos to starting position
hservo [RightFront\CurrRFPos, LeftFront\CurrLFPos, RightRear\CurrRRPos, LeftRear\CurrLFPos]

’ Main Line

gosub Steering [CurrRFPos, CurrLFPos, CurrRRPos, CurrLRPos, 100]
goto ShutDown

'Set speed for the four motors - SaberTooth 2x5 motor controller, packet serial

speed var sword
SetSpeed [speed]
return


’ Steer the four wheels

rfangle var sword
lfangle var sword
rrangle var sword
lrangle var sword
spd var sword
Steering [rfangle, lfangle, rrangle, lrangle, spd]
gosub CalculatePos [rfangle, lfangle, rrangle, lrangle]
hservo [RightFront\rfangle * StepsPerDegree\spd, LeftFront\lfangle * StepsPerDegree\spd, RightRear\rrangle * StepsPerDegree\spd, LeftRear\lrangle * StepsPerDegree\spd]
return

’ Calculate new steering servo positions

rfangle var sword
lfangle var sword
rrangle var sword
lrangle var sword
CalculatePos
CurrRFAngle = rfangle ’ <--------------- Error
CurrLFAngle = lfangle ’ <--------------- Error
CurrRRAngle = rrangle ’ <--------------- Error
CurrLRAngle = lrangle ’ <--------------- Error

CurrRFPos = CurrRFAngle * StepsPerDegree
CurrLFPos = CurrLFAngle * StepsPerDegree
CurrRRPos = CurrRRAngle * StepsPerDegree
CurrLRPos = CurrLRAngle * StepsPerDegree
return

ShutDown
End[/code]
Error: FILE E:\DEVEL\PROJECTS\BASIC MICRO\WALTER\WALTER.BAS(LINE 105) : [TOKEN RFANGLE] : Redefining to Variable
Error: FILE E:\DEVEL\PROJECTS\BASIC MICRO\WALTER\WALTER.BAS(LINE 106) : [TOKEN LFANGLE] : Redefining to Variable
Error: FILE E:\DEVEL\PROJECTS\BASIC MICRO\WALTER\WALTER.BAS(LINE 107) : [TOKEN RRANGLE] : Redefining to Variable
Error: FILE E:\DEVEL\PROJECTS\BASIC MICRO\WALTER\WALTER.BAS(LINE 108) : [TOKEN LRANGLE] : Redefining to Variable

8-Dale

Hi Dale,

The problem is that your redefining these variables.

That is you defined them above the steering function and than again before the CalculatePos function. Unfortunately the Basic Micro basic does not have any scoping of variables (IE they are all global). So they can only be defined once…

Kurt

I see that now. I’m still in C mode, which I prefer WAY more. I need to switch to AtomPro mode. :slight_smile:

It would be really nice if we could leverage what Basic Micro has already done from the C environment also.

8-Dale