![]() |
|
|
|
#1
|
|||
|
|||
|
The problem with this is that it makes the transitions very very very quickly if I put decimals in the list "movetime."
movetime = [.05, .25, .75, 1, 2] sequences = [] for time in movetime: MoveRoom = vizact.sequence(vizact.move(0,0,(0.12/time),time), vizact.move(0,0,(-0.12/time),time), (30/time)) sequences.append(MoveRoom) sequences.append( vizact.call( WriteFlag ) ) MovingRoom = vizact.sequence(sequences, 1) If I make the code: MoveRoom = vizact.sequence(vizact.move(0,0,(0.5/time),time), vizact.move(0,0,(-0.5/time),time), (30/time)) and I make movetime [1, 2, 3, 4, etc] then it'll move .5 m/s for 1 second and then .25 m/s for 2 seconds...etc....all of the movements will result in moving .5 meters for a total of 1 minute. But when I have the above (if I want it to move .12 meters in .05 seconds or .25 seconds, etc.) it moves really fast for a second and then moves on to the next number in the list. It doesn't perform what I want it to and it doesn't do it for 1 minute either. Is there some problem with decimals? Am I making a wrong conversion? I tried changing the end (instead of 30/time to 600/time but that didn't change anything--if anything it made it transition faster. Am I missing something? |
|
#2
|
|||
|
|||
|
Then don't put decimals in your movetime list. Keep in mind that dividing two integers in Python will yield another integer that is the floor of the division. Example:
Code:
print 1 / 2 #prints 0 print 1 / 2.0 #prints 0.5 |
|
#3
|
|||
|
|||
|
what's a floating point value?
Like if I want it to move .12 meters in .5 seconds how would I code that? I'm not familiar with floating point values. Even if I make it 1/20.0 instead of .05 it doesn't work. It still moves really fast and transitions WAY before a minute has passed. Last edited by Elittdogg; 11-26-2007 at 01:01 PM. |
|
#4
|
|||
|
|||
|
Also, even if I make it 1/2.0 it goes really fast and doesn't last one minute. Maybe I'm just confusing myself?
|
|
#5
|
|||
|
|||
|
In most programming languages, non-fractional numbers are referred to as integers and fractional numbers are referred to as floats or floating point values. For example the following are integers:
Code:
1 2 3 4 Code:
1.0 2.1 3.89 4.43509876 |
|
#6
|
|||
|
|||
|
So 0.5 should be a floating point if I'm understanding correctly. And my desired distance is already "0.12" which would also be a floating point. Yet it is still not working for me. Am I missing something?
|
|
#7
|
|||
|
|||
|
What exactly is not working? According to your example code, the longest move action will last 2 seconds. None of the values in the movetime list are specifying anything close to a minute.
|
|
#8
|
|||
|
|||
|
Ok. So what I originally had was:
movetime = [1,2,3,4,5,6] sequences = [] for time in movetime: MoveRoom = vizact.sequence(vizact.move(0,0,(0.5/time),time), vizact.move(0,0,(-0.5/time),time), (30/time)) sequences.append(MoveRoom) sequences.append( vizact.call( WriteFlag ) ) MovingRoom = vizact.sequence(sequences, 1) This made it so that the picture moved .5m/s forward for 1 second and .5m/s backward for 1 second (it did that a total of 30 times which added up to 60 seconds). The second iteration it moved .25m/s (.5/2) for 2 seconds forward and backward and it did that 15 times (30/2) for a total of 60 seconds. The third iteration it moved .167m/s (.5/3) forward and backward for 3 seconds and it did this 10 times (30/3) for a total of 60 seconds. ETC ETC ETC ETC In each case it was moving a total of .5 meters forward and backward it was just doing it at a slower velocity over a longer period of time. Now I need to keep it semi-proportional to that. Namely, I need it to move .12m forward for .05 seconds and .12m backward for .05 seconds and to do that for a minute. (Just like above I need it to move a total of .12 meters (in this case) forward and backward and do it at a faster velocity over a shorter period of time. So I need my movetime list to be like: movetime = [.05, .25, .75, 1, 2]. So it should start off moving very fast over a short distance and then gradually move slower over that same short distance. And each "iteration" needs to be a minute long. I know I'm missing something/my formula/equation is off/wrong, but I can't figure it out. If I'm dividing 30 by .05 that equals 600. So it should do that iteration 600 times which would end up being 60 seconds long. But it doesn't. It only does it a couple of times (which ends up being 2.4 seconds long). Does that make sense? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|