#robotics Logs

Jul 12 2017

#robotics Calendar

12:23 AM mrdata: oh 4.0 microcurie of americium 241
12:26 AM mrdata: you could build a smoke detector maybe?
12:28 AM mrdata: and here i was thinking microcoulomb until i scrolled back, which confused me
12:28 AM mrdata: rue_shop3, you probably know the story of the radioactive boyscout?
12:28 AM mrdata: btw, he's dead
01:29 AM Luminax-Work is now known as LuminaxWk
01:29 AM Sol is now known as Guest31235
03:42 AM rue_shop3: :)
07:25 AM eldritch2 is now known as eldritch
01:35 PM rue_shop3: it trump pushing thru sopa or something?
02:05 PM rue_house: is anyone awake?
02:05 PM rue_house: d = v*t
02:05 PM rue_house: v = a*t
02:05 PM rue_house: d a t
02:05 PM rue_house: d = a*t^2
02:06 PM rue_house: but were decellerating
02:06 PM rue_house: vf = v1 + (a*t)
02:06 PM rue_house: vf = vi + (a*t)
02:07 PM rue_house: d = ... yea, this is a problem
02:07 PM rue_house: ok I got it
02:07 PM rue_house: this is a de-accel to zero
02:08 PM rue_house: this is the same as the acceleration from zero, but backwards
02:10 PM veverak: yup
02:10 PM veverak: :)
02:18 PM rue_shop3: |\
02:18 PM rue_shop3: __
02:18 PM rue_shop3: where vert axis is V and horiz is t
02:18 PM rue_shop3: I know v0
02:18 PM rue_shop3: I know x
02:19 PM rue_shop3: I need t
02:19 PM rue_shop3: so there is a triangular region and a square region
02:19 PM rue_shop3: if I know the difference between v0 and v at x, which I dont...
02:19 PM rue_shop3: hum
02:41 PM rue_house: oh thank god the brain is kicking in
02:43 PM rue_house: triangle, vert axis is velocity, horiz is time
02:43 PM rue_house: area is x
02:43 PM rue_house: x = (Vtop*t)/2
02:43 PM rue_house: so t=2x/v
02:45 PM rue_house: the de-accel will be a twist, cause the slope is the other way
02:46 PM rue_house: no wait I think I blew this
02:46 PM rue_house: I need to know v at x
02:47 PM rue_house: WHY THE HELL IS NOBODY EVER AWAKE AROUND HERE
02:47 PM rue_house: v(t) =
02:47 PM rue_house: a*t
02:51 PM * veverak is here
02:51 PM veverak: but I still do not understand what you are doing
02:51 PM veverak: :)
02:55 PM rue_house: trapazoidal velocity profile
02:55 PM rue_house: a function pre-calculates the bends in the velocity curve
02:56 PM rue_house: is knows the time, and x position of each of the two points (which could be the same point if its a triangular profile)
02:56 PM rue_house: and it knows the peak velocity
02:56 PM rue_house: given that, a function is passed an X position,
02:56 PM rue_house: solve for what time that position occurs
02:58 PM veverak: I see
02:58 PM veverak: so it can be either in accel phase, constant speed phase or deaccel phase
02:58 PM rue_house: yea
02:59 PM rue_house: I'm having issues wrapping my head around any math right now
03:00 PM veverak: so, t0 = v_max/accel
03:01 PM veverak: t0 - time at which it arrives at max speed
03:01 PM rue_house: we can start from the beggining
03:01 PM veverak: go on
03:01 PM rue_house: t0: V0 = 0, X = 0
03:01 PM rue_house: a = a
03:01 PM rue_house: so it just accelerates
03:02 PM rue_house: http://ruemohr.org/~ircjunk/images/haha-markx.svg
03:02 PM veverak: yep, at t1 = Vmax/a it reaches max speed
03:02 PM rue_house: thats the X chart
03:02 PM veverak: wow, that's nontrivial accel :)
03:03 PM rue_house: hmm, good point
03:03 PM veverak: s1 = a*t1^2 is distance when it reaches max speed
03:03 PM veverak: so if f(x) -> x < s1, 'x' is in accel time
03:03 PM rue_house: youc an use x
03:04 PM rue_house: this->x1 = (accel * this->t1 * this->t1)/2;
03:04 PM rue_house: some thing looks wrong with my x2 calc tho
03:04 PM rue_house: this->x2 = (this->vTop * t2) + ( this->accel * this->t1 * this->t1 )/2;
03:05 PM rue_house: -- rewind maybe --
03:05 PM rue_house: InitMotion(trapMotion_t *this, float start, float end, float accel, float topSpeed)
03:05 PM veverak: why /2 for x1 ?
03:05 PM rue_house: this->vTop = Min(sqrt(accel * ((end - start) / 2.0)), topSpeed);
03:05 PM veverak: wow wow
03:05 PM veverak: what's the primary goal here?
03:06 PM rue_house: I need to take the existing code and work out, for any given x, what t is
03:07 PM rue_house: the vtop calc, it says that at half way there, we need the velocity to either be the top speed or the speed we hit at that time
03:07 PM rue_house: trying to give you background on all the numbers have I
03:07 PM rue_house: that tells us what the actual max velocity is
03:07 PM rue_house: from that
03:07 PM rue_house: this->t1 = this->vTop / accel;
03:08 PM rue_house: that is the time we hit the peak velocity
03:08 PM rue_house: thank god its equal accel/decel times!
03:09 PM rue_house: the I do some geometry to get t2, which might be the same as t1
03:09 PM rue_house: this->t2 = this->t1 + ((end - start) - (accel * this->t1 * this->t1))/ this->vTop;
03:09 PM rue_house: so, the accel and decel times are known, any gap in the middle is constant accel
03:09 PM rue_house: er
03:09 PM rue_house: constant velocity
03:10 PM rue_house: then I work out the two x locations for those times
03:10 PM rue_house: this->x1 = (accel * this->t1 * this->t1)/2;
03:10 PM rue_house: thats all fine and happy
03:10 PM rue_house: but then it looks like I made an error
03:10 PM rue_house: this->x2 = (this->vTop * t2) + ( this->accel * this->t1 * this->t1 )/2;
03:11 PM rue_house: this dosn't seem to account for the acceleration
03:11 PM rue_house: so it should have a +x1 on it
03:11 PM veverak: this->t2 does not makes sense to me
03:11 PM rue_house: this is a C structure
03:11 PM rue_house: t2 is a variable in that struct
03:12 PM veverak: no, the formula for it
03:12 PM veverak: :)
03:12 PM rue_house: it took me like 8 hours to work out last time
03:13 PM veverak: (distance - distance_spent_accelereating_to_max_speed)/max_velocity + time_to_accelerate_to_max_speed
03:13 PM rue_house: it measures backwards from the end of the motion, to get the time
03:13 PM veverak: is what I understand from it
03:13 PM rue_house: er its not tho is it, its taking the difference in the distance traveled and working out any gap
03:14 PM rue_house: then adding that gap to the first time to come up with the second
03:14 PM veverak: I mean
03:14 PM veverak: it's definetly not nice code
03:14 PM veverak: you know, splitting into functions and all
03:15 PM rue_house: hu?
03:15 PM Guest31235 is now known as Solgriffin
03:15 PM rue_house: they are just equations
03:15 PM veverak: which are hard to decypher
03:15 PM veverak: you could still split them into functions
03:15 PM rue_house: t = t + ( dX - a*t^2)/Vmax
03:16 PM rue_house: that would be bad for microcontrollers
03:16 PM rue_house: besides, each one would only be used once
03:16 PM veverak: compiler should be able to clean it up...
03:16 PM veverak: anyway
03:17 PM veverak: t2 should be time when it start to deaccelerate
03:17 PM rue_house: yup
03:17 PM rue_house: thats right
03:18 PM veverak: this->x2 = (this->vTop * (t2-this->t1)) + ( this->accel * this->t1 * this->t1 )/2;
03:18 PM veverak: than this is correct version no?
03:18 PM rue_house: I think its wrong
03:18 PM veverak: right sight is distance traveled accelerating
03:18 PM rue_house: its doing the constant vel and the de-accel
03:18 PM veverak: left side is distance traveled constant velocity
03:18 PM rue_house: but
03:18 PM rue_house: oooh right
03:19 PM rue_house: thats accel, not decel
03:19 PM * rue_house re-accanges
03:19 PM veverak: :)
03:19 PM rue_house: this->x2 = (( this->accel * this->t1 * this->t1 )/2) + (this->vTop * t2);
03:19 PM veverak: still
03:20 PM veverak: this->vTop*t2 is distance traveled if it would be on 'constant velocity' entire time until 't2'
03:20 PM veverak: that seems wrong
03:20 PM veverak: you definetly want vTop*(t2-t1)
03:20 PM veverak: which is distance traveled when it's on constant velocity (which is only between t2 and t1)
03:21 PM veverak: detach, need to go afk
03:21 PM rue_house: yea.....
03:22 PM rue_house: must ahve not testted it with a triangle
03:38 PM rue_house: this is intersting
03:38 PM rue_house: at t=0 x!=0
03:39 PM rue_house: @#%$#???
03:39 PM rue_house: for (t = 0; ...
03:39 PM rue_house: getPos(&motion, &offset, t);
03:39 PM rue_house: void getPos(trapMotion_t *this, float * offset, float t)
03:39 PM rue_house: if(t < this->t1) {
03:39 PM rue_house: dt = t - 0.00;
03:39 PM rue_house: *offset = (this->accel * dt * dt)/2;
03:42 PM rue_house: damn this stuff is getting harder for me to do
03:55 PM rue_house: ARG, I muffed the definition of start
03:59 PM rue_house: *offset = (this->accel * dt * dt)/2.0;
04:00 PM rue_house: x = (a*t^2)/2
04:01 PM rue_house: ok
04:01 PM rue_house: just revese the code for part 1, easy
04:02 PM rue_house: *offset = (this->vTop * dt) + this->x1;
04:03 PM rue_house: x = Vtop*t + x0
04:05 PM rue_house: t = x-x0)/vtop
04:05 PM rue_house: that makes sense
04:08 PM rue_house: *offset = this->x1 + (this->vTop * (this->t2 - this->t1)) + (this->vTop*dt) + (( -(this->accel) * dt * dt )/2);
04:08 PM rue_house: @#%$@$&@#%#@$%!!!!!!
04:08 PM rue_house: x =
04:08 PM rue_house: *sigh*
04:23 PM rue_house: x = v*dt + v*dt + -a*dt*t*t/2
04:23 PM rue_house: hmm
04:24 PM rue_house: so I really just need to work out what the time is for the decel
04:25 PM rue_house: oh, it simplifies
04:25 PM rue_house: *offset = this->x2 + (this->vTop*dt) + (( -(this->accel) * dt * dt )/2);
04:28 PM rue_house: x = v*t + ((-a*t^2)/2)
04:29 PM rue_house: wolfram points out to NOT let a=0
04:33 PM veverak: makes sense
04:33 PM rue_house: I think I can cheat ya know
04:33 PM rue_house: because the accel and decel times are the same, I know how long the decel will take
04:33 PM rue_house: er, no this idea wont work
04:33 PM veverak: it should
04:33 PM rue_house: oh, but
04:34 PM rue_house: if I inverse the problem itself
04:34 PM durrfaroo: then the problem becomes the solution!
04:34 PM veverak: wait, what's the problem?
04:34 PM rue_house: and I look at V on the x axis and t on the y axis
04:34 PM rue_house: the problem is that my brain isn't working
04:34 PM veverak: if you are at speed Vmax
04:34 PM veverak: and wan't to deaccelerate to 0
04:34 PM veverak: given 'a' accel
04:34 PM veverak: time to do that is t = Vmax/a
04:34 PM rue_house: I got the first two parts, I just need the decel position->time calcs
04:35 PM veverak: so let's say that t3 = Vmax/a
04:35 PM veverak: time to accelerate, t1, is also t1 = Vmax/a
04:35 PM rue_house: yea
04:35 PM rue_house: t1 = t3-t2
04:35 PM rue_house: (cause a is the same for accel and decel)
04:36 PM veverak: good
04:36 PM veverak: distance is also the same
04:36 PM rue_house: I know the x position
04:36 PM rue_house: I need to calc the time it took to get there
04:37 PM rue_house: we can consider *just* the decel phase
04:37 PM rue_house: we know we started at Vtop
04:37 PM rue_house: we know we finish at 0
04:37 PM rue_house: we know the area under the part of the triangle
04:37 PM veverak: hmm
04:37 PM rue_house: inverse the x and y
04:37 PM veverak: distance is (at^2)/2 for accel yeah?
04:37 PM rue_house: cause its a linear decel
04:38 PM rue_house: yea
04:38 PM rue_house: the area under the triangle
04:38 PM * rue_house shakes his head... this stuff should be easy for me
04:38 PM rue_house: if you flip the x and y axie
04:38 PM veverak: rue_house: wait
04:39 PM rue_house: the acel needs to be 1/a
04:39 PM veverak: so, the distance it takes for deaccel is same as for accel ?
04:39 PM rue_house: yea
04:39 PM rue_house: but .. oh
04:39 PM rue_house: just subtract the difference?
04:39 PM veverak: yep ?
04:39 PM veverak: or, you know
04:39 PM veverak: if 's' is distance for deaccle
04:39 PM veverak: claculate for x1 = s - x
04:39 PM veverak: and calculate x1 for accel
04:40 PM rue_house: trying to absorb...
04:40 PM veverak: tahn if t3 is tame it takes t odeaccel, and 't1' is result for accel
04:40 PM veverak: your result is: t = t3 - t1
04:40 PM veverak: I think
04:40 PM rue_house: *time = sqrt((x*2.0)/this->accel); <-- that is for accel
04:41 PM rue_house: so, t1-sqrt(((x1-x)*2.0)/this->accel);
04:41 PM rue_house: ?
04:41 PM veverak: nope
04:41 PM veverak: hmm
04:41 PM rue_house: I'll just jam it in and test it
04:41 PM veverak: rue_house: I think I just confused you with variables
04:41 PM veverak: {t,s}1 -> accel
04:41 PM rue_house: hole up, let me try this
04:41 PM veverak: {t,s}2 -> deaccel
04:42 PM veverak: 'x' distance traveled deaccelerating
04:43 PM veverak: define x_m, which is x_m = s2 - x; -> distance it needs to finish deaccelerating
04:43 PM rue_house: what I did there should flip left-right, the accel time
04:43 PM rue_house: and distance
04:43 PM veverak: you calculate how long it would take to travel that distance if you would accelerate from '0'
04:44 PM veverak: let's call that result t_m
04:44 PM veverak: now, time for 'x' should be (t2 - t_m)
04:44 PM veverak: because t_m should be time how long it needs to fully deaccelerate
04:45 PM veverak: so t2 - t_m is time it spent deaccelerating
04:45 PM veverak: :)
04:50 PM rue_house: ARG, I have an arbitatry start position in this code that is being a PAIN IN THE ASS
04:51 PM veverak: :)
04:52 PM rue_house: I should have wrapped it in a layer
05:13 PM anniepoo: 8cD
05:14 PM anniepoo: there is no problem that can't be solved by another layer of abstraction,
05:14 PM anniepoo: except the problem of too many layers of abstraction
05:14 PM rue_house: got it
05:14 PM rue_house: *time = this->t2 + (this->t1) - sqrt(( ( (this->x1 ) - ( x - (this->x2)) ) *2.0)/this->accel);
05:14 PM rue_house: the time it took to start decel +
05:14 PM rue_house: the difference of
05:14 PM rue_house: the time it took to accel
05:15 PM rue_house: and the time of the remaining distance that we didn't cover in the decel
05:15 PM rue_house: ?
05:15 PM rue_house: (it works)
05:17 PM rue_house: veverak,
05:17 PM Tom_itx: you should look at linuxcnc's new trajectory planner code
05:17 PM rue_house: http://paste.debian.net/976215/
05:17 PM rue_house: no cause it'll have a horrid mess of stuff thats not relivent to me and obfiscates it too much to read
05:18 PM rue_house: veverak, ^^ see the getTime(
05:18 PM Tom_itx: time in what?
05:18 PM rue_house: units
05:18 PM Tom_itx: machine units per second or what
05:18 PM rue_house: dosn't matter
05:18 PM Tom_itx: i know but it does matter when you pick them
05:18 PM rue_house: I'll map it all out to real worlt later
05:19 PM Tom_itx: decel is important too
05:19 PM Tom_itx: for gouge avoidance in corners etc
05:19 PM rue_house: I did
05:20 PM Tom_itx: and a look ahead buffer
05:20 PM rue_house: the one fixed thing I'm uneasy about is that the accel and decel is the same
05:20 PM Tom_itx: to know where it's supposed to go next
05:20 PM rue_house: yea, velocity bridging,
05:20 PM rue_house: I'm not makeing a cnc controller tho
05:20 PM Tom_itx: but you could
05:21 PM rue_house: I just, right now, need to ramp a motor up and down
05:21 PM Tom_itx: you still need decel to be right or you will overshoot the target no matter what it is
05:21 PM rue_house: its all good tom, that program calculates the whole velocity profile
05:21 PM rue_house: ... ugh
05:21 PM Tom_itx: just makin sure you did your homework right :D
05:21 PM rue_house: it just dosn't go backwards
05:22 PM rue_house: oh my for loop might be at fault
05:24 PM rue_house: nope, bugger
05:24 PM rue_house: Tom_itx, it would take me MUCH longer to adapt someone elses code to my own use than for me to write something from scratch
05:24 PM Tom_itx: i didn't say adapt it
05:24 PM Tom_itx: i said look at it
05:24 PM Tom_itx: you might get some insight
05:25 PM rue_house: they will do everything differently
05:25 PM rue_house: everyone does
05:25 PM veverak: rue_house: looks cool
05:25 PM rue_house: road, forward
05:25 PM Tom_itx: it was just redone last year
05:25 PM rue_house: Tom_itx, could you grep the source file, tell me how many #ifdef there are, I bet its more than 100
05:26 PM rue_house: even 16 can make source code completely unreadable
05:26 PM Tom_itx: no, i don't have a copy of it currently
05:26 PM rue_house: :/ I'm pissed cause mine dosn't go backwards properly
05:26 PM Tom_itx: guess you got some homework
05:27 PM rue_house: I did ti all mathmatically
05:27 PM rue_house: others wont, they will use a use case optimization
05:27 PM rue_house: which I'v done before, and makes code that cant be used for things it wasn't invisioned for later
05:28 PM rue_house: I have an idea on what to do
05:28 PM rue_house: I think I'll break it up more into the 3 regions
05:28 PM rue_house: if I do it right, I should be able to unlink the accel and decel rates
05:33 PM rue_house: yea, this'll take like 2 days to rewrite
05:34 PM Tom_itx: good you got time
05:35 PM rue_shop3: I'm gonna break it all up different and re-arrange it
05:35 PM rue_shop3: but its a nice day for making wooden storage boxe
05:35 PM rue_shop3: s
05:36 PM Tom_itx: i been makin props last few days
05:47 PM rue_shop3: cool
06:25 PM veverak: https://github.com/Schpin/schpin-ros/blob/master/schpin_stg/src/tools/leg_graph_generator/physics.h this is my last try to write physics calculations
06:25 PM veverak: needs review one day
06:25 PM veverak: yeah, definetly needs review, incosistent
09:45 PM Tom_itx: 99° F, finally cooling down a bit...
09:47 PM synja: i'd be boiling alive
09:48 PM synja: much like my servers, i prefer it very cold
10:09 PM rue_shop3: ooo its cooling off something fierce
10:11 PM synja: probably b/c that calved glacier :P