Submarine Drone
2 posters
RigidChips :: Rigid-Chips :: Files :: Works In Progress
Page 1 of 1
Submarine Drone
I've spent too long trying to get this working. I feel like I'm missing something glaringly obvious. I think I just need someone else to look at it and go "ya, you forgot to plug this in" or something.
Here it is:
Here it is:
- Code:
// [RCD]
Val
{
HTRM(default=0, min=-10, max=10)
PITCH(default=0, min=-3, max=3)
SPN(default=0, max=5000)
VTRM(default=0, min=-10, max=10)
YAW(default=0, min=-3, max=3)
}
Key
{
}
Body
{
Core() {
S:Chip(name=htr) {
S:Arm(angle=VTRM) { }
N:Frame(angle=-150, option=1) {
N:Wheel(angle=-120, power=SPN, brake=1000) {
N:Frame(angle=-30) {
N:Weight(angle=-30) {
E:Weight() { }
W:Weight() { }
}
N:Weight(angle=90) {
E:Weight() { }
W:Weight() { }
}
}
}
}
}
S:Trim(angle=90, name=vtr) {
N:Chip() { }
S:Arm(angle=HTRM) { }
}
}
}
Lua
{math.sgn = function (x) if x < 0 then return -1 elseif x == 0 then return 0 else return 1 end end
function starter()
vrot=0
hrot=0
end
function OnInit()
starter()
end
function OnReset()
starter()
end
function OnFrame()
SPN=_KEY(4)*5000
vrot=math.cos(_EZ(vtr))
hrot=math.cos(_EZ(htr))
PITCH=PITCH+4*(_KEY(0)-_KEY(1))-2*math.sgn(PITCH)
YAW=YAW+4*(_KEY(2)-_KEY(3))-2*math.sgn(YAW)
HTRM=vrot*YAW+hrot*PITCH
VTRM=hrot*YAW+vrot*PITCH
end}
Last edited by MrSparks on Fri Feb 17, 2012 11:11 am; edited 1 time in total (Reason for editing : Found first problem.)
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 33
Location : Michigan
Re: Submarine Drone
Does _EZ() not pay attention to what chip it's supposed to be reporting on?
I mean, that's the only thing I can think of that could explain why the 2 tail fins don't move independently.
I mean, that's the only thing I can think of that could explain why the 2 tail fins don't move independently.
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 33
Location : Michigan
Re: Submarine Drone
Everything but the Lua code is capitalized before the program is run. Normally, that means that you don't have to worry about capitalization. Unfortunately, it also means that every variable named outside of the Lua must be capitalized in the Lua.
Make sure all the variables used outside Lua are all caps.
Short version: Change vtr to VTR and htr to HTR.
Make sure all the variables used outside Lua are all caps.
Short version: Change vtr to VTR and htr to HTR.
- Code:
// [RCD]
Val
{
HTRM(default=0, min=-10, max=10)
PITCH(default=0, min=-3, max=3)
SPN(default=0, max=5000)
VTRM(default=0, min=-10, max=10)
YAW(default=0, min=-3, max=3)
}
Key
{
}
Body
{
Core() {
S:Chip(name=HTR) {
S:Arm(angle=VTRM) { }
N:Frame(angle=-150, option=1) {
N:Wheel(angle=-120, power=SPN, brake=1000) {
N:Frame(angle=-30) {
N:Weight(angle=-30) {
E:Weight() { }
W:Weight() { }
}
N:Weight(angle=90) {
E:Weight() { }
W:Weight() { }
}
}
}
}
}
S:Trim(angle=90, name=VTR) {
N:Chip() { }
S:Arm(angle=HTRM) { }
}
}
}
Lua
{math.sgn = function (x) if x < 0 then return -1 elseif x == 0 then return 0 else return 1 end end
function starter()
vrot=0
hrot=0
end
function OnInit()
starter()
end
function OnReset()
starter()
end
function OnFrame()
SPN=_KEY(4)*5000
vrot=math.cos(_EZ(VTR))
hrot=math.cos(_EZ(HTR))
PITCH=PITCH+4*(_KEY(0)-_KEY(1))-2*math.sgn(PITCH)
YAW=YAW+4*(_KEY(2)-_KEY(3))-2*math.sgn(YAW)
HTRM=vrot*YAW+hrot*PITCH
VTRM=hrot*YAW+vrot*PITCH
end}
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
Re: Submarine Drone
DanielLC wrote:Everything but the Lua code is capitalized before the program is run. Normally, that means that you don't have to worry about capitalization. Unfortunately, it also means that every variable named outside of the Lua must be capitalized in the Lua.
Make sure all the variables used outside Lua are all caps.
Short version: Change vtr to VTR and htr to HTR.
Not in your post but possibly implied: Chip names are variables?
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 33
Location : Michigan
Re: Submarine Drone
Not in your post but possibly implied: Chip names are variables?
Yes. It's the chip number. For example, 0 is the base chip.
I figured out your problem when I had it print out these numbers. It gave 'nil' for both of them.
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
RigidChips :: Rigid-Chips :: Files :: Works In Progress
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum