hexapod-robot-simulator
hexapod-robot-simulator copied to clipboard
Draw the projection of the center of gravity on the ground plane
You'd need to update the following
1. The model VirtualHexapod to have an attribute that stores this point
https://github.com/mithi/hexapod-robot-simulator/blob/531fbb34d44246de3a0116def7e3d365de25b9f6/hexapod/models.py#L95
You can compute this point as outlined by the algorithm here, you should inject the point calculation to a different function and update the attribute of the VirtualHexapod when this is called in the two compute_orientation_properties of the hexapod.ground_contact_solver module.
https://github.com/mithi/hexapod-robot-simulator/blob/531fbb34d44246de3a0116def7e3d365de25b9f6/hexapod/ground_contact_solver/helpers.py#L14
2. In figure template, you should append a new point trace at the end of the data list
https://github.com/mithi/hexapod-robot-simulator/blob/531fbb34d44246de3a0116def7e3d365de25b9f6/hexapod/templates/figure_template.py#L226
The trace has the following format
{
"marker": {"color": INSERT_COLOR_HERE, "opacity": 1.0, "size": INSERT_SIZE_HERE},
"mode": "markers",
"name": "cog-projection",
"type": "scatter3d",
"x": [INSERT_COG_X_HERE],
"y": [INSERT_COG_Y_HERE,
"z": [0],
}
3. HexapodPlotter could draw this point in the figure template
https://github.com/mithi/hexapod-robot-simulator/blob/531fbb34d44246de3a0116def7e3d365de25b9f6/hexapod/plotter.py#L14
@mithi This has been open for a couple months now.
Let me know when you think a "seasoned" contributor can take it on.....i would be interest!
@mithi This has been open for a couple months now.
Let me know when you think a "seasoned" contributor can take it on.....i would be interest!
Sure go ahead, if you have some time to tinker around ... I I currently don't have time to explain things in detail but by inspecting the code I'm sure you'll be able to figure things out on your own... 😄
@mithi whaaatt? i like you detailed explanations, they get me thinking about clean code.
in all seriousness, thank you.
i only hope/expect can chime in when, and however you can.
so no pressure.
Hi @mithi. Apologies for the very very very long delay. I am finally done with school, can get back to OSS contributions, and I can start working on this issue before I start work again.
Though, I notice you re-implemented this project in JS. So do you still need this feature here?
@markkulube
Hey! Long time no see 😄 This issue is open, so if you'd like to work on it, you're more than welcome 🙂
@mithi a couple short questions:
-
What information is present in
dimensionsthat I can use to initialize the point of projection for the self.projection_point attribute? The initial value is None or is it a Point/Vector as per points.py?class VirtualHexapod:def __init__(self, dimensions):self._store_attributes(dimensions)self._init_legs()self._init_local_frame()self.projection_point = None -
I understand calculation of the point is to be abstracted to it's own function e.g. compute_projection_point(---), but what are it's parameters? It would really help if there was a mathematical formula you had in mind thereby answering this question!
@markkulube
VirtualHexapod has a property self.body which is a Hexagon
https://github.com/mithi/hexapod-robot-simulator/blob/531fbb34d44246de3a0116def7e3d365de25b9f6/hexapod/models.py#L61
Hexagon has a property self.cog this is the center of gravity which is of type point Point
The projection of the center of gravity is just a point where the z coordinate is zero. IE
cogProjection.x = cog.x
cogProjection.y = cog.y
cogProjection.z = 0
Thanks!