top of page

Forum Comments

Bella, unbelievable, but now even more beautiful!
In Showcase
Issue with the last step of Nybble set-up
In Basic Assembly and Setup
MPU causing jitters in kitty
In Software
Mark DeNies
Nov 04, 2020
Thanks Rongzhong! To change speed, I did several things: First, less frequent calls to checkBodyMotion (more below), then, when the loop is run, I update the motors only when the current time is greater than 40ms since the last time. I then update ALL the motors. Taking a cue from your transform() function, I linearly interpolate between duty points (entries in the instincts). By changing the number of interpolation steps, I change the speed. From 1 step (fastest) to 50 steps (very slow). Since the motors are all updated at once, this gives a significant speedup all by itself. I use two buttons on the remote to increase or decrease "stepsPerDuty". The code: if(bRunning) { if (tPrevMotorCall + tMotorWait <= tCur) { checkBodyMotion(); //fetch current gyro info only when needed tPrevMotorCall += tMotorWait; // tMotorWait is typically ~40ms for (int i=0; i<8; i++) { int dutyIdx = iDuty * WALKING_DOF + jointIdx - firstMotionJoint; float prevAngle = previousAngle[i]; float targetAngle = motion.dutyAngles[dutyIdx]; float stepAngle = iStep * float(targetAngle-prevAngle)/stepsPerDuty; float adj = adjust(jointIdx); mostRecentAngle[i] = prevAngle+stepAngle; //save most recent angle for this motor (used below) calibratedPWM(jointIdx, prevAngle + stepAngle + adj); jointIdx++; } jointIdx = DOF - WALKING_DOF; iStep++; if (iStep > stepsPerDuty) { //when finished the last interpolation, advance to the for (int i=0; i<8; i++) // next Duty step (entry in the current skill) previousAngle[i] = mostRecentAngle[i]; iDuty++; iStep = 1; if (iDuty == motion.period) iDuty = 0; bFirstLoop = false; // bFirstLoop is used for debugging only } } } Some explanation is probably needed: prevAngle[] contains the previous duty angle (from the intrinsic tables) for use in interpolation. UNLESS a new motion was started --in which case it will contain the most recent interpolated angle. This allows the new motion to smoothly interpolate from wherever Nybble was in the previous skill to the first position of the current skill. Also, checkBodyMotion() is only called when I need a adjustment value, since it takes significant time. But this causes trouble with its queue overflowing. So I found some fairly simple code to read the IMU registers directly and calculate the angles. Since this replaced the Rowling IMU library, it also saved 6K of program space and speeds up everything.
0

Mark DeNies

More actions
bottom of page