Comments (8)
Is there already someone working on this? I'd like to contribute to this project it looks really interesting. I'm new to GitHub and have some experience in Python and this seems like a nice possibility to improve my Python and writing skills!
from pyswarms.
Hey @whzup ! Welcome!
No one's working on this and sure this one's yours 👍 Be sure to fork the development
branch and simply start the notebook inside the examples/
directory 😄
If you have any questions (the github process in general, on inverse kinematics, etc.), do not hesitate to ping us!
from pyswarms.
Thanks a lot!
I have a question regarding the function that is to be optimized. In the gist to your blog post on row 43 of roboticArm.py you use np.array([Etip[0,3],Etip[1,3],Etip[2,3]])
as the position function, why is it that the position is exactly the third column of the matrix? Also, I'm guessing that Etip
is the transformation matrix for the end tip so that if you multiply it by a vector the position of the end tip would be the result, or am I wrong with that?
from pyswarms.
Hi @whzup !
Awesome questions! Made me review my robotics basics again. 😆 So, for a Denavit Hartenberg (D-H) transformation matrix, the values in the fourth column (we start indexing by 0) describes the translation from axis x to axis y (Check the last sentence in this link). That's why we are only taking those values.
Imagine your elbow joint as axis x and your wrist joint as axis y. If you want to know how your wrist joint translates with respect to your elbow joint, you compute the D-H matrix by doing a dot-product:
import numpy as np
transform_matrix_from_elbow_to_wrist = np.dot(elbow_joint, wrist_joint)
The result is a 4 x 4 matrix that we now know as the D-H transformation matrix. But what if we want to know how the end-tip of our index finger translates with respect to our elbow joint? Then, we successively compute the transformation matrix from elbow to wrist, then wrist to index finger tip. Same reason why there 's a succession of np.dot
s to obtain Etip
.
I'm guessing that Etip is the transformation matrix for the end tip so that if you multiply it by a vector the position of the end tip would be the result, or am I wrong with that
In hindsight, I think that my variable name is misleading. You are right that the Etip is the transformation matrix from the zeroth-axis to the end-tip. Although I am not sure about multiplying a vector to find the end-tip position. Usually we just obtain the three values in the fourth column.
from pyswarms.
Thanks for the fast response. Really interesting to learn some things about robots on the fly 😋.
I have some other issues though:
-
The
pyswarms.singleGlobalBestPSO
class creates an array of lengthn_particles
with each element being an array of the six parameters. I think this deliberate but it kind of complicates the function for the transformation matrix. I more or less copied your version of the function. -
Is there a way to include a "target" in the
pyswarms.singleGlobalBestPSO
class such that I can just feed it the function and the target or do I have to manually add this in the optimization function? Alternatively, can thepyswarms.singleGlobalBestPSO
class take a function with more than one argument as an input for the optimization? I have been looking around in the source code but it seemed to me that it only works with functions that only take one input.
For lack of a better alternative, here a pastebin of my code (copied into IDLE from the notebook)
Thanks for the help thus far. I very much appreciate such a welcoming atmosphere!
from pyswarms.
Hey @whzup ! Hope you are enjoying!
- Is there a way to minimize this complexity? I made it deliberate before so that we can explicitly see the matrix itself, but I think we can leave that one out, no problem. We can just state in the notebook that there is a transformation matrix but we'll just take the following parameters.
So what I'm thinking is like this (feel free to deviate as you please):
[input_swarm] --> get_endtip_pos() --> get_distance(target) --> [fitness]
In terms of matrix shapes (you can check them using np.shape
):
(n_particles, 6) --> in: (n_particles, 6), out: (n_particles, 3) --> in: (n_particles, 3) target=(3, ), out: (n_particles, ) --> (n_particles,)
- Inside the
get_endtip_pos()
, instead of computing the whole transformation matrix, we can just compute for the three translation elements in the fourth column (a * np.cos(theta)
,a * np.sin(theta)
,d
). This saves us from indexing needlessly. Although I think it's important that the input dimensions should still be 6.
- For
target
, I think for now this should be defined in the objective function itself. I realized that there may be cases where the objective function must be parameterized. Maybe next time we can update pyswarms to take on**kwargs
in the objective function when computing.
Oh, you should definitely check out replt.it. It enables you to execute pasted code, and even install pyswarms (and other PyPI libraries) in the process! 👍
Feel free to message if you have questions!
from pyswarms.
Being able to parameterize the objective function is really useful to me. I got this to work using **kwargs
and was about ready to submit a PR when i saw this discussion. Do you guys mind if submit one?
from pyswarms.
Hi @bradahoward ! Yes please feel free to open a PR. But I'd recommend you to open an Issue first so can keep a history of all things happening in this project 👍
While you're at it, I'm wondering if it's better to use *args
than **kwargs
. Would you mind investigating that as well and check which one works in a usability standpoint?
from pyswarms.
Related Issues (20)
- Final Best Position Logical Error
- init_pos does not seem to work as expected
- TypeError: f() got an unexpected keyword argument 'print_step'
- Tests fail with Matplotlib 3.7
- A toy problem example - need help to use PySwarms
- Release missmatch (Missing release on github)
- Having Issue in optimizer HOT 1
- mean_neighbor_cost value in history Tuple of optimizers
- parallel pyswarms not working
- TypeError: '<' not supported between instances of 'generator' and 'float' HOT 1
- Test failures
- Dependency on future
- Unexpected stagnation with VonNeumann and Pyramid topologies HOT 1
- Typo Error in Documentation: Incorrect Hyperlink for use case examples in Launching Pad Section
- ValueError: Unable to configure handler 'file_default' HOT 2
- The new open-source Python library **PyPop7** can be used as an alternative to this widely used library for PSO.
- Pyswarms changes dtype from pyten.mp.MPS() to np.ndarray()
- 3D Plotting Broken HOT 1
- networkx graph netwrok data
- Add docs that pyswarms is minimization solver HOT 1
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 pyswarms.