GMod - What are you working on? October 2016 (#62)

Highlights from the previous thread

Not bad

A friend of mine wanted a kind of prize entity for halloween.

https://share.metamist.xyz/HJsjc90p.mp4

So I knew (theoretically) that the hacking device would work with all user-defined ATMs. But I never tested them out until just now

Not only do the ATMs get hacked, but the surrounding environment as well.

Well, I have a tutorial here to show you how to use it:

God speed ahead !

why are you showing us a propane tank for 4 minutes

Your observational skills are worse than a wallnut

Well, every person has his preferences. I guess he does not like the propane tank. I knew I had to use the good an’ old washing machine :smiley:

I believe the main complaint is that the audio is so low he couldn’t tell it was there. I didn’t either at first.

If you turn up your volume a bit more, you can see a propane tank

I’m working on a PID controller. Right now the only part I’ve implemented is the P (“proportional”) part of the algorithm, but it seems to work pretty well with just that.

[video]https://youtu.be/HWLS1AWqDKU[/video]

Finishing up my GLua Discord libary currently. It takes inspiration from discord.js, here is some working example code.



bot = discord:CreateClient()
bot:Login(<token>)

bot:on("ready", function()
    print("Ready")
end)

bot:on("message", function(msg, self)
    if msg.author.id == self.id then return end
    msg:Reply(msg.content)
end)


Makes your discord bot that basicly does this:

Still need to finish/polish some things, like adding api’s for guilds, roles and textchannels.

I am planning to release it under MIT as soon as I feel it’s somewhat done/stable.

I wrote a PID controller for my drone using WireCPU ZASM. What I discovered was that in some cases you don’t need the integral component and in other cases you don’t need the derivative.

Not finished yet

Well I think that your speakers have this rounded cylindrical knob called “Volume”. Try adjusting it a little ( To the side where the sound becomes louder that is. ) :smiley:

[editline]4th October 2016[/editline]

[quote=“raubana, post:11, topic:229449”]

I’m working on a PID controller. Right now the only part I’ve implemented is the P (“proportional”) part of the algorithm, but it seems to work pretty well with just that.

[QUOTE]

Tell me if you need help with the PID :wink:

The audio of the video was so low that I thought it was completely silent.

I did figure it out eventually (otherwise I wouldn’t have posted that) but seriously, it was really low.

[editline]4th October 2016[/editline]

PID is awesome! The same generic PID algorithm works for a whooole bunch of different problems. I first used it in high school, in a robotics competition.

I humbly suggest that you don’t bother recreating this algorithm by yourself, unless you really enjoy that challenge. It’d be much easier and probably better to find an existing PID algorithm in Lua, and just pump your values into that.

Buuut if you do end up making it, it would be really nice if you make it standalone and not tied up to your car. That way it can be used for other stuff in the future. :smile:

By the way, the video you linked was the best explanation of PID I’ve seen so far, I’ve gotta bookmark it :happy:

Edit: and yes, a lot of the time just P can be very stable.

Does such a system already exist for lua??

[editline]4th October 2016[/editline]

I’ve updated the PID system to look ahead. This helps the vehicle know when it can speed up or when it should slow down.

I also added some code that tells the system to reverse when a turn is too tight. I don’t even fully understand it myself, to be honest; I was doing guess and check. I normally would avoid that kind of thing because I can’t know how to fix my code if I don’t even know how it works…but here we are. :s:

Anyways, this makes the vehicle traverse the path more quickly *and *more accuretly as well.

[video]https://youtu.be/c_cPzPF7UNk[/video]

Detouring lua_newstate() from menu state binary module, grabbing newly created client and server lua_State pointers and running arbitrary Lua shit using them. This shit crashed my game like 30 times before I got it working :frowning:

Looks great!

I’m working on a self-balancing Arduino robot and am using GMod to prototype the PID controller algorithm. I can’t record a video of how it works, but I’ll upload the code some time later. Right now it’s not much; it just stands upright and sometimes drifts from side to side. I’ll add user input while I’m waiting for parts to arrive.

I finally implimented the PID code. To be honest, the fact that the wheels turn so slowly kind of makes using this PID controller pointless, but at least I’ve managed to make it work pretty efficiently.

[video]https://youtu.be/0YFuthBOgp0[/video]

I’ve never been very good at calculus, so I suspect I may have done this wrong, heuhghgh…



PID = PID or {}
PID.__index = PID


function PID:create(Kp, Ki, Kd, start_error)
	local pid = {}
	setmetatable(pid,PID)
	
	pid.Kp = Kp
	pid.Ki = Ki
	pid.Kd = Kd
	
	pid.prev_error = start_error or 0
	pid.prev_update_time = CurTime()
	
	pid.output = 0
	
	return pid
end


function PID:Update(new_error)
	local curtime = CurTime()
	if curtime != self.prev_update_time then
		local time_dif = curtime - self.prev_update_time
		
		local slope = (new_error - self.prev_error) / time_dif
		local area = ((new_error + self.prev_error)/2.0) * time_dif
		
		local P = (self.Kp * new_error)
		local I = (self.Ki * area)
		local D = (self.Kd * slope)
		
		self.output = P + I + D
		
		self.prev_error = new_error
		self.prev_update_time = curtime
	end
end


function PID:GetOutput()
	return self.output
end