New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modelling flexible link robots using virtual link/joint method #530
Comments
Hi ! Yes it is perfectly doable, in fact it was partly designed for this specific use case. I don't have much time to help you at the moment but I will try to give you some insight on how to do it tomorrow. |
Awesome! I don't need to reinvent the wheel then. Looking forward for insights from you. |
@duburcqa, please let me know about insights that you mentioned as soon as you can |
First, there is an example of simple RL environment based on Jiminy here. Next, a basic tutorial is available here. Finally, a sketch of document can be found here. Regarding your specific setup, you can add deformation points either at the location of an actual joint or a fixed frame. In you case, it seems to be fixed frame. You need to adapt your kinematic tree to break up the single link in several smaller fixed rigidly attached to each other using "fixed" joints. Each of the sub-links must have their own visual and collision geometries. Then, once you URDF model is adapted you can start simulating flexibility very easily. To this end, two options must be configured:
where Here is a very basic example to create a flexible model:
I recommend you to have a look to the set of all available options for both the engine and the model using |
@duburcqa, thank you very much for detailed insights on implementing flexible robot simulator. Are you familiar with any other simulators/software for easy simulation flexible robots, so I can compare results of Jiminy with something external? |
Hum, I don't think there is any, probably because of the lack of consensus regarding the model. The one I'm using builds on the work of Matthieu Vigne and adds armature inertia to make sure the velocity is continuous. It enables to take larger integration time steps without diverging. The exact model requires Finite Element Analysis (FEA), which is way to costly for RL applications. |
I see, thank you! I will close the issue for now. |
Closed too early 😅 I installed Jiminy using On the positive side, I can successfully run an example on Google Colab. I created a URDF file with single active revolute joint and 3 fixed joints to simulate flexibilities. Then I defined
|
Yes definitely, you need to use the same version that the one used to compile jiminy, or to compile jiminy yourself (which is quite straightforward). The right versions for the master branch are
Yes, but it should be the same since there is no forces applied in the two other directions (orthogonal to gravity according to your figure). Plus physically everything is 3D.
It follows pinocchio paradigm, so a quaternion (4 components) and a angular velocity (3 components). Nota Bene: I would be happy if you could share your notebook, it could be a great addition to the few existing examples ! |
@duburcqa, thank you for your answer. I will gladly share my notebook once it works. Sorry for bothering but I have new questions, I hope you can help me out. Based on your previous comments I implemented a toy example, but can't simulate it, I get
And a python code
Am I missing something trivial? I tried to go through unittests to see how you simulate flexibility and didn't find anything useful for solving my problem. |
If you use You get none of the links have non-zero inertia along x axis, which is problematic if the flexibility is enabled because it could in theory rotate around them, even though it is never going to be the case by design. I will check if it is possible to fix it. If not, I will have a look to adding single-dof flexibility model as option. |
After having a closer look to the issue, I think the best approach is just to set the armature inertia of the deformation points to a value larger than 0 on x axis, ie 1. It is due to some compounding of errors causing non-zero acceleration around y-axis (0.1) that gets integrated slowly by slowly. I will check if it is possible to prevent it. |
Thanks a lot @duburcqa now I see
But I saw in your unit tests that you pass all the states. How come I can't do the same? Another question: do you have any function that retrieves joint angles of the spherical flexible joints from quaternion? |
I found the root cause of the compounding of errors, your approximation of This part of the code is not properly tested for now, and your use case exhibits a bunch of bugs that I'm currently fixing (mainly affecting the visualization). I will write a unit test based on it if I have time to do it.
It is because your initial is just wrong because you have one actual revolute joint and a quaternion. Another approach is to always provide the rigid state and let the simulator put the zero the deformation points:
Yes:
|
PR #535 fixes a bunch of bugs. I have this complete example working:
|
The PR #536 is adding unit tests to make sure it keeps working in the future. It should be merged on dev branch tomorrow morning. I could release a new version on pypi if you need it. |
Thank you very much for looking deeply into my issue. How can I use your latest changes in Jiminy? Do I need to pull devel branch and install it using About initial state: even if I initialize it correctly with A question about controllers: how can I define it? I try to do it this way
but I get broadcasting issues. Does simulator or controller know about active and passive flexible joints? Do they know that I only want to control active joints? |
No, you need to follow the procedure to described in the documentation, or one of the CI scripts. Alternatively, you can download pre-compiled wheels for linux here.
What is the error message ? You mean segfault ? You cannot do
And yes you will get broadcasting issues because here Here is a goody just for the fun (40 deformation points): |
Hey, there. A new day new questions 😄 Wow, you simulation looks awesome; the object there looks like a rope. I didn't get to which part of my question about installing your no is referred to, if I use Easy-install on Ubuntu 18+ will I get all the latest updates? When specifying flexible link states I get
Regarding controller, I attached EncoderSensor to the link and used its states for feedback, thank you for the insight. Another question about controller: it is possible to pass time varying reference to it? In Google Colab notebook I cannot get a proper visualization using this command
I get a couple of warnings |
To get the last update, either you need to install to follow the instruction to build from source and checkout the dev branch, or you can just install the precompiled wheel available here. Just unpack the "wheelhouse" artefacts and run:
Do you have a complete example ? Because I'm quite sure there is no bug here.
Yes, just create a proper controller rather than a simple callback, and use the time to fetch the right reference. You need to inherit from
I think I have fixed those issues in the dev branch. Can you check if it works ? |
I followed your instructions about getting the latest updates using "wheelhouse" but still notebook crashes while visualizing the robots motion. Here is the notebook I use, you can copy it and run to reproduce the issue. |
First, you need to disable the browser tracking protection of firefox to make it work. But on my side, it still does not manage to connect to ipython for some reason. I will have a look to see if I can do something about it. Besides, I would suggest to use |
I think I found the issue with Google colab. I should be able to fix it soon. Reverse engineering how it works without docs or source code was painful. Alternatively, you have the option to save it as a video using the options
|
Where do I need to set A question about simulator: before stumbling upon the Jiminy I wrote very small ad-hoc simulator for the flexible arm; there I also use pinocchio as a backend. In my code a robot is described using a URDF where passive joint that approximate flexibility of the link are revolute joints as well. In ODE to compute accelerations I call forward dynamics algorithm (aba) in pinocchio by passing joints positions, velocities and a torque vector Once I had the Jiminy simulator running I wanted to compare its solution with mine simulators solution. All the conditions were the same: URDF is the same, controllers are the same . But, unfortunately, trajectories do not coincide, for example, the motion of flexible joints differ by an order of magnitude. I have been trying to find a bug in my code, but I haven't so far. How can I make sure that Jiminy provides correct solution? I can provide a link to my simulator if you need it. What I found strange about Jiminy's solution is that in steady state when the active joint is rotated by |
in
First of all, you should configure both integrator to use the simple euler explicit schema. Jiminy is using the adaptive stepper Runge Kutta Dopri 5 by default. It is also possible to use RK45, which is fixed step but more complex that Euler Explicit. I would say the simpler the better. Yet It would be helpful if you could provide your simulator.
Do you have a script to illustrate this ?
Yes indeed. Strange. There is no magic in the simulation here, which you described quite precisely in your message already. So I'm a bit puzzled. |
The code for comparing trajectories in here in the script Unfortunately, Let me know if you have any why simulated trajectories are so different. |
I have fixed the viewer in google colab. it is quite laggy but it works x) You need to update the ipykernel for it to work:
y the way, I suggest opening a view in one cell, and ask for replay in another one. This way, it will replay in the already existing cell, avoiding the open and close the view systematically, which is costly.
|
Yes, you need to decrease the step size |
I have control |
The snippet to record and show video:
Yes it does, but 1ms may still be too large without armature inertia apparently. It is a bit surprising but definitely not impossible. You should increase the flexibility inertia to smooth that out. |
Thank you for solving issues with a visualization. I will try it out tomorrow. Regarding simulation: I decreased |
Interesting. How can I check that myself ? From the video based on your "original" notebook it looks quite right. |
By doing what I do -- described here. There is a chance that I am doing something wrong: maybe converting quaternions to angles or something entirely else. |
Hum, I would say yes there is a mistake with your extract of the result. Because here is the video: To me it looks exactly as it should. Nota bene: You will find the latest wheels to download here once it is done compiling (it takes about 45min). |
Here is a function I use for extracting flexible joint positions
|
Your extract is ok, but it this example, the arm is almost right, presumably because the flexibility are much stronger. I think you cannot compare your stiffness with the one of jiminy easily. here is the formula:
video2.mp4You may want to disable the position and velocity bounds in jiminy, because I assume you did not implement them in your simulator. |
I will release a new version of jiminy tonight. For now, you can get it here if you want. I have fixed the interactive viewer mode in google colab, but since it is laggy and quite fragile (it works better in mybinder) I have added a video mode that is used by default instead. |
About flexibility, I still don't understand why visualization and reading from Is it too difficult to add 1D spring to Jiminy? I will try new version tomorrow. |
You must have a bug somewhere because I'm sure both matches. You can reply log files with jiminy using
It is not about how difficult it is. It is just that it does not make sense physically since the deformation are never 1D in reality. And how do you even choose the axis ? Fixed frame do not even have an axis in standard URDF specification, only an origin. It makes sense for 1D motors and some authors are doing it in the literature but it is not generic. Moreover, it is no advantage over 3D spring in terms of computation speed or physical validity. Pinocchio (and Jiminy) is not made with planar robots in mind but for real robots in the first place. |
I have released a new version of jiminy and made your problem a demo here. |
By the way, you could implement yourself the model you like by replacing fixed joints by revolute, adding "motors" to them and defining an internal dynamics for them (through |
I'm going to have a look to motor transmission flexibility (what you have in mind) today and do a comparison between the two models to see how different it is. |
@duburcqa Thanks a lot for trying to solve my issues. I didn't have time to work on jiminy implementation of my setup, and probably won't have time in the weekend. I will get back to flexible link simulation ASAP |
No problem, just I will not have time to work on improving jiminy until august after today. |
Hi!
I want to model a flexible link robot by truncating the link into several virtual links connected by means of passive virtual joints with certain stiffness and damping (see the figure below, it explains the concept for single link robot). I have a URDF file that describes approximated model, but it doesn't contain joint stiffness and damping. I want to implement a simulator for training and RL agent. Is it possible to it using jiminy? Do you have any examples of flexible robots? What is the best place to start implementing flexible link robot simulator?
Thank you in advance!
d
The text was updated successfully, but these errors were encountered: