theAgingApprentice / HexaFloorRide

Arduino based six legged robot project
MIT License
0 stars 0 forks source link

globCoordsToLocal routine in flows.cpp has math bug #218

Closed nerdoug closed 6 months ago

nerdoug commented 1 year ago

believe this is what's causing 4 legged walking gait script - gait4.txt to have problems. I'm convinced the compiled code is correct, but executing script on bot doesn't work correctly.

nerdoug commented 6 months ago

just tried to open a similar new bug, but got an error message. The math for_endLegX in case 2 is suspect, and the formula used doesn't agree with the comments. Note that leg 5 is the opposite leg, and should use comparable formula for its LegX value. Probably need a diagram, and should create a permanent doc with diagrams that explain the math behind all these conversion routines

nerdoug commented 6 months ago

The local X value is the outward distance from the centre of the hip. For the side legs ( 2 & 5) this is outward from the robot, and lines up with the global Y direction. Leg 2 is on the left side of the robot, where the global Y values are positive. The local x value is the global Y value minus the distance from the hip to the front to back centre line. This lateral distance to the hip is d$sideY. So the local X value for leg 2 is: the global Y coordinate minus d$sideY = gy - d$sideY

For leg 5, on the other side of the robot, there's a similar situation, except the global Y values are negative. We want the positive value for our calculation, so we negate it, and the local X for leg 5 is (-1 * gy) - d$sideY