Comments (2)
First solution: Hexapod body will only twist when at least three hip angles at a time.
Second solution:
# hexapod will only definitely NOT twist
# if only two of the legs (currently on the ground)
# has twisted its hips/coxia
# i.e. only 2 legs with ground contact points have changed alpha angle
# i.e. we don't care if the legs which are not on the ground twisted its hips
Thinking about other cases we should account for as well as other possible algorithms.
from hexapod-robot-simulator.
Currently implemented like this
hexapod-robot-simulator/hexapod/models.py
Line 222 in f67434e
def _find_if_might_twist(self, poses):
# hexapod will only definitely NOT twist
# if only two of the legs (currently on the ground)
# has twisted its hips/coxia
# i.e. only 2 legs with ground contact points have changed alpha angle
# i.e. we don't care if the legs which are not on the ground twisted its hips
did_change_count = 0
for leg_point in self.ground_contacts:
# find the leg id of the ground contact point
right_or_left, front_mid_or_back, _ = leg_point.name.split("-")
leg_placement = right_or_left + "-" + front_mid_or_back
leg_id = self.body.VERTEX_NAMES.index(leg_placement)
# alpha before new pose
old_hip_angle = self.legs[leg_id].coxia_angle()
# new alpha pose
new_hip_angle = get_hip_angle(leg_id, poses)
if not np.isclose(old_hip_angle, new_hip_angle or 0):
did_change_count += 1
if did_change_count >= 3:
return True
return False
and
def find_twist_frame(old_ground_contacts, new_ground_contacts):
# This is the frame used to twist the model about the z axis
def _make_contact_dict(contact_list):
contact_dict = {}
for leg_point in contact_list:
name = leg_point.name
contact_dict[name] = leg_point
return contact_dict
def _twist(v1, v2):
# Note: theta is in radians
# https://www.euclideanspace.com/maths/algebra/vectors/angleBetween/
theta = np.arctan2(v2.y, v2.x) - np.arctan2(v1.y, v1.x)
# frame to rotate around z
cos_theta = np.cos(theta)
sin_theta = np.sin(theta)
return np.array(
[
[cos_theta, -sin_theta, 0, 0],
[sin_theta, cos_theta, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
]
)
# Make dictionary mapping contact point name and leg_contact_point
old_contacts = _make_contact_dict(old_ground_contacts)
new_contacts = _make_contact_dict(new_ground_contacts)
# Find at least one point that's the same
same_point_name = None
for key in old_contacts.keys():
if key in new_contacts.keys():
same_point_name = key
break
# We don't know how to rotate if we don't
# know at least one point that's contacting the ground
# before and after the movement
# so we assume that the hexapod didn't move
if same_point_name is None:
return np.eye(4)
old = old_contacts[same_point_name]
new = new_contacts[same_point_name]
# Get the projection of these points in the ground
old_vector = Point(old.x, old.y, 0)
new_vector = Point(new.x, new.y, 0)
twist_frame = _twist(new_vector, old_vector)
# ❗IMPORTANT: We are assuming that because the point
# is on the ground before and after
# They should be at the same point after movement
# I can't think of a case that contradicts this as of this moment
return twist_frame
from hexapod-robot-simulator.
Related Issues (20)
- Add more and better tests and test cases HOT 15
- pip install problem (on windows) HOT 2
- Improve code quality HOT 4
- Most plotter instance methods should be static methods HOT 1
- Add docstrings for public packages etc HOT 6
- Modify to be more pythonic
- Fix README's Incorrect list-item indent and Misaligned table fence HOT 1
- ❗Algorithm for computing hexapod orientation does not account for all cases HOT 8
- Draw the projection of the center of gravity on the ground plane HOT 7
- Ideas to improve code quality HOT 2
- Unexpected Behaviors to Address HOT 1
- Rename Point class to Vector HOT 4
- Refactoring Suggestions HOT 4
- Refactor pages HOT 1
- Change Naming conventions (suggestions) HOT 1
- Minor refactoring suggestions to improve code quality HOT 9
- Implementation improvements
- Hexapod should twist when all femur joints are on the ground HOT 1
- Wrong __repr__ param of Linkage HOT 1
- Unused assigned variable (remove this) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexapod-robot-simulator.