diff --git a/documentation/src/SUMMARY.md b/documentation/src/SUMMARY.md index 35ff54c..fb880c2 100644 --- a/documentation/src/SUMMARY.md +++ b/documentation/src/SUMMARY.md @@ -3,10 +3,19 @@ [AQLARP](title-page.md) # Introduction - [Design Principles](ch01-01-design-principles.md) +- [Coordinate System](ch02-01-coordinate-system.md) # Building -- [Materials](ch02-01-required-materials.md) -# Documentation +- [Required Materials](ch03-01-required-materials.md) +- [Building](ch04-00-building.md) + - [Building The Legs](ch04-01-building-leg.md) + - [Building The Main Body](ch04-02-building-body.md) + - [Wiring](ch04-03-wiring.md) +- [Installing Software](ch05-01-installing-software.md) +# API +- [ROS2 topics](ch06-01-ros2-topics.md) +- [Code Structure](ch07-01-code-structure.md) +# Concepts explained -- [Inverse Kinematics](ch04-00-inverse-kinematics.md) - - [Inverse Kinematics Of The Legs](ch04-01-inverse-kinematics-legs.md) - - [Inverse Kinematics Of The Body](ch04-02-inverse-kinematics-body.md) \ No newline at end of file +- [Inverse Kinematics](ch08-00-inverse-kinematics.md) + - [Inverse Kinematics Of The Legs](ch08-01-inverse-kinematics-legs.md) + - [Inverse Kinematics Of The Body](ch08-02-inverse-kinematics-body.md) \ No newline at end of file diff --git a/documentation/src/ch-01-02-coordinate-system b/documentation/src/ch-01-02-coordinate-system new file mode 100644 index 0000000..1e0ca6a --- /dev/null +++ b/documentation/src/ch-01-02-coordinate-system @@ -0,0 +1 @@ +# diff --git a/documentation/src/ch02-01-coordinate-system.md b/documentation/src/ch02-01-coordinate-system.md new file mode 100644 index 0000000..b8c5e3a --- /dev/null +++ b/documentation/src/ch02-01-coordinate-system.md @@ -0,0 +1,17 @@ +# Defining AQLARP's coordinate system +Knowing AQLARP's coordinate system is import so you know what setting each axis will do. +Here are the definitions for it: +- X-axis: + - Increasing the value will make AQLARP move to the front + - Decreasing the value will make AQLARP move to the back +- Y-axis: + - Increasing the value will make AQLARP go up + - Decreasing the value will make AQLARP go down +- Z-axis: + - Increasing the value will make AQLARP go to the right + - Decreasing the value will make AQLARP go to the left + +The origin of these axis is where the leg is connected to the top joint, this is a per leg coordinate system. + +Below are some images to clarify what axis does what. +![](img/Coordinate-System-XY.png)![](img/Coordinate-System-XZ.png) \ No newline at end of file diff --git a/documentation/src/ch02-01-required-materials.md b/documentation/src/ch03-01-required-materials.md similarity index 100% rename from documentation/src/ch02-01-required-materials.md rename to documentation/src/ch03-01-required-materials.md diff --git a/documentation/src/ch04-00-building.md b/documentation/src/ch04-00-building.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch04-01-building-leg.md b/documentation/src/ch04-01-building-leg.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch04-02-building-body.md b/documentation/src/ch04-02-building-body.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch04-02-inverse-kinematics-body.md b/documentation/src/ch04-02-inverse-kinematics-body.md deleted file mode 100644 index 7fd522c..0000000 --- a/documentation/src/ch04-02-inverse-kinematics-body.md +++ /dev/null @@ -1,37 +0,0 @@ -# Inverse kinematic of the body -The inverse kinematics of the body is to transform pitch, roll and rotation into offsets for the x, y and z coordinate of a leg. -## Definitions -\\(l\\) length of the body - -\\(w\\) width of the body - -\\(pitch\\) desired pitch - -\\(roll\\) desired roll - -\\(rotation\\) desired rotation - -\\(rotation\\) desired rotation - -\\(m_{x}\\) leg movement x - -\\(m_{y}\\) leg movement y - -\\(m_{z}\\) leg movement z - -\\(x\\) x position of a leg relative to the center - -\\(z\\) z position of a leg relative to the center -## Pitch -The calculations for pitch are as follows: -$$m_{x} = \frac{l(1-\cos(pitch))}{2}$$ -$$m_{y} = \frac{l\sin(pitch)}{2}$$ -## Roll -The calculations for roll are as follows: -$$m_{z} = \frac{w(1-\cos(roll))}{2}$$ -$$m_{y} = \frac{w\sin(roll)}{2}$$ -## Rotation -The calculations for rotation are based on a [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix). These calculations are as follows: - -$$m_{x} = (x \times \cos(rotation) - z \times \sin(rotation)) - x$$ -$$m_{z} = (x \times \sin(rotation) + z \times \cos(rotation)) - z$$ \ No newline at end of file diff --git a/documentation/src/ch04-03-wiring.md b/documentation/src/ch04-03-wiring.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch05-01-installing-software.md b/documentation/src/ch05-01-installing-software.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch06-01-ros2-topics.md b/documentation/src/ch06-01-ros2-topics.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch07-01-code-structure.md b/documentation/src/ch07-01-code-structure.md new file mode 100644 index 0000000..e69de29 diff --git a/documentation/src/ch04-00-inverse-kinematics.md b/documentation/src/ch08-00-inverse-kinematics.md similarity index 100% rename from documentation/src/ch04-00-inverse-kinematics.md rename to documentation/src/ch08-00-inverse-kinematics.md diff --git a/documentation/src/ch04-01-inverse-kinematics-legs.md b/documentation/src/ch08-01-inverse-kinematics-legs.md similarity index 99% rename from documentation/src/ch04-01-inverse-kinematics-legs.md rename to documentation/src/ch08-01-inverse-kinematics-legs.md index ac69fb1..69e722a 100644 --- a/documentation/src/ch04-01-inverse-kinematics-legs.md +++ b/documentation/src/ch08-01-inverse-kinematics-legs.md @@ -42,7 +42,7 @@ Then finally we can combine them by adding them together. $$A = A_{x} + A_{y}$$ $$B = B_{y}$$ $$C = C_{y} + C_{z}$$ -## In code +## Code After transforming all these calculations into code, we get this: ```py def calc_angles(leg, x, y, z): diff --git a/documentation/src/ch08-02-inverse-kinematics-body.md b/documentation/src/ch08-02-inverse-kinematics-body.md new file mode 100644 index 0000000..39bcde1 --- /dev/null +++ b/documentation/src/ch08-02-inverse-kinematics-body.md @@ -0,0 +1,63 @@ +# Inverse kinematic of the body +The inverse kinematics of the body is to transform pitch, roll and rotation into offsets for the x, y and z coordinate of a leg. +## Definitions +\\(l\\) length of the body + +\\(w\\) width of the body + +\\(pitch\\) desired pitch + +\\(roll\\) desired roll + +\\(rotation\\) desired rotation + +\\(rotation\\) desired rotation + +\\(m_{x}\\) leg movement x + +\\(m_{y}\\) leg movement y + +\\(m_{z}\\) leg movement z + +\\(x\\) x position of a leg relative to the center + +\\(z\\) z position of a leg relative to the center +## Pitch +The calculations for pitch are as follows: +$$m_{x} = \frac{l(1-\cos(pitch))}{2}$$ +$$m_{y} = \frac{l\sin(pitch)}{2}$$ +## Roll +The calculations for roll are as follows: +$$m_{z} = \frac{w(1-\cos(roll))}{2}$$ +$$m_{y} = \frac{w\sin(roll)}{2}$$ +## Rotation +The calculations for rotation are based on a [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix). These calculations are as follows: + +$$m_{x} = (x \times \cos(rotation) - z \times \sin(rotation)) - x$$ +$$m_{z} = (x \times \sin(rotation) + z \times \cos(rotation)) - z$$ +## Combining Calculations +To combine these calculations you just calculate each one separately and then calculate the sum of all x calculations, then the sum of all y calculations and finally the sum of all z calculations. +## Code +After transforming these calculations into code, we get this: +```py +def calc_leg_offsets(leg, pitch, roll, rotation): + # Get the X and Z coordinate of the leg + x = (body_length / 2) if leg < 2 else -(body_length / 2) + z = -(body_width / 2) if leg == 0 or leg == 3 else (body_width / 2) + # Calculate the height difference of the leg to reach the target pitch + height_diff_pitch = x * sin(radians(pitch)) + # Calculate the height difference of the leg to reach the target roll + height_diff_roll = z * sin(radians(roll)) + # Calculate the X and Z offsets to keep the body centered + movement_x_pitch = x * (1 - cos(radians(pitch))) + movement_z_roll = z * (1 - cos(radians(roll))) + # Calculate the rotation offsets + movement_x_rotation = (x * cos(radians(rotation)) - z * sin(radians(rotation))) - x + movement_z_rotation = (x * sin(radians(rotation)) + z * cos(radians(rotation))) - z + # Merge the offsets and return them + return ( + movement_x_pitch + movement_x_rotation, + height_diff_pitch - height_diff_roll, + movement_z_roll + movement_z_rotation + ) +``` \ No newline at end of file diff --git a/documentation/src/img/Coordinate-System-XY.png b/documentation/src/img/Coordinate-System-XY.png new file mode 100644 index 0000000..ec5c7f2 Binary files /dev/null and b/documentation/src/img/Coordinate-System-XY.png differ diff --git a/documentation/src/img/Coordinate-System-XZ.png b/documentation/src/img/Coordinate-System-XZ.png new file mode 100644 index 0000000..e960451 Binary files /dev/null and b/documentation/src/img/Coordinate-System-XZ.png differ diff --git a/documentation/src/title-page.md b/documentation/src/title-page.md index 7b92f54..ba928f1 100644 --- a/documentation/src/title-page.md +++ b/documentation/src/title-page.md @@ -5,8 +5,6 @@ AQLARP stands for **A**ffordable **Q**uadruped **L**earning **A**nd **R**esearch AQLARP is licensed under the [MIT license](https://github.com/DeDiamondPro/AQLARP/blob/master/LICENSE). -