I think that the stand up sequence is running and then evaluating the gyro before the robot has a chance to get to a point that the gyro is in a standing position. I would add more time to the sleep command at the bottom. You might take it up to 10000 and see if that is the issue. If so, you could start reducing this down to however long it takes.
You would think that the line waiting for the auto positioner running to be false would prevent this from happening but, give it a shot. If that "Fixes" the issue, we will have a better idea of how to completely fix the issue.
Yea, I expected it to delay the standup time, but it answers that the script must be being called 2 times from somewhere. I don't have one of these sensors so I don't have a way to test. I think DJ is going to be your best help unless others have one and a JD that they can test with.
Use this code and then post the output in the little black window under the script back to this thread. Make sure to get all of it which might require that you scroll up a bit.
ControlCommand("MPU9150", Init)
sleep(100)
:loop
#Added these because $AccelX and $AccelY were not recognized
print("Start of loop")
$XAccel = $AccelX
$YAccel = $AccelY
IF ($AutoPositionStatus = true)
print("AutoPositioner already running...")
sleep(2000)
goto(loop)
ENDIF
ControlCommand("MPU9150", RunOnce)
print ("x: " + $XAccel)
print ("y: " + $YAccel)
IF ($YAccel > 8000)
print("Getting up from front")
ControlCommand("Auto Position", AutoPositionAction, "Getup")
waitfor($AutoPositionStatus = false)
$XAccel = $AccelX
$YAccel = $AccelY
print ("x: " + $XAccel)
print ("y: " + $YAccel)
ELSEIF ($YAccel < -8000)
print("Getting up from rear")
ControlCommand("Auto Position", AutoPositionAction, "stand from sit")
waitfor($AutoPositionStatus = false)
$XAccel = $AccelX
$YAccel = $AccelY
print ("x: " + $XAccel)
print ("y: " + $YAccel)
ENDIF
sleep(1000)
$XAccel = $AccelX
$YAccel = $AccelY
print("End of loop...Restarting")
goto(loop)
The issue was with having to specify other variables and not updating these variables in the script. Nomad, please post the working script and have a great day!
Here is my guess as to what is happening.
I think that the stand up sequence is running and then evaluating the gyro before the robot has a chance to get to a point that the gyro is in a standing position. I would add more time to the sleep command at the bottom. You might take it up to 10000 and see if that is the issue. If so, you could start reducing this down to however long it takes.
You would think that the line waiting for the auto positioner running to be false would prevent this from happening but, give it a shot. If that "Fixes" the issue, we will have a better idea of how to completely fix the issue.
ok i decrease the sleep with 1000 and up to 4000 not working. also you have the effect that jd will lie down for long time . before getting up.
Yea, I expected it to delay the standup time, but it answers that the script must be being called 2 times from somewhere. I don't have one of these sensors so I don't have a way to test. I think DJ is going to be your best help unless others have one and a JD that they can test with.
Use this code and then post the output in the little black window under the script back to this thread. Make sure to get all of it which might require that you scroll up a bit.
like this?
#autopositionstatus = ""
ControlCommand("MPU9150", Init)
sleep(100)
:loop
$YACCEL = $ACCELY
$XACCEL = $ACCELX
if($autopositionstatus=true)
print("autopositioner alredy running")
sleep(1000)
goto(loop)
endif
ControlCommand("MPU9150", RunOnce)
print("x8:" + $XACCEL)
print("y8:" + $YACCEL)
if($YACCEL > 8000)
print ("GETTING UP FROM FRONT")
controlcommand("auto position",autopositionaction,"getup")
waitfor($autopositionstatus=false)
elseif($YACCEL <-8000)
print("getting up from rear")
ControlCommand("Auto Position", AutoPositionAction, "stand from sit")
waitfor($autopositionstatus=false)
endif
sleep(1000)
goto(loop)
The text will happen after you run the script. it will look like this
Start of loop y = (something here) x = (Something here) Getting up from rear end of loop restarting
This will be in the little black box at the bottom of the script window.
Also, get the code I sent a couple of posts ago. It has a couple of more things that might solve or point to the problem.
The issue was with having to specify other variables and not updating these variables in the script. Nomad, please post the working script and have a great day!