ayonga / frost-dev

Fast Robot Optimization and Simulation Toolkit (FROST)
http://ayonga.github.io/frost-dev/
Other
158 stars 63 forks source link

How to run animation for Atlas ? #10

Closed ankalou closed 7 years ago

ankalou commented 7 years ago

Hi, Thank you for developping FROST ! I am trying to install your code and to understand how it must be used, but I have some trouble... After running main_sim.m or main_opt.m in the Atlas example, I obtain a lot of nice variables in the workspace, but no animations, and I couldn't find timeseries or trajectories that could be interesting to plot. It would be nice to have some kind of visualization to understand what your program is doing... The (commented in the code) lines

export_file = fullfile(cur,'tmp','atlas_multi_contact_walking.avi');
anim = animator(atlas);
anim.animate(calcs,export_file)

do not work, and I found no documentation on the use of animator. Is there maybe some documentation pages I am missing ? Could you please explain me how you exploit the optimisation results ?

Thanks a lot !

ayonga commented 7 years ago

Hi,

Thanks for your interest in FROST. We have some initial code for simple animation (with stick figures, not mesh files). The codes are in the folder matlab/+frost/+Animator. Unfortunately, I have not implemented that on ATLAS yet. I will update you once we have ATLAS version ready.

Thanks.

VictorS10 commented 7 years ago

Hi Ayonga

I also want to use FROST but I don't really understand how to use it. I followed the tutorial and the example that is given "To run the multi-contact dynamic walking simulation of 3D ATLAS" by runing "main_sim.m" or "main_opt" but they just calculate the inertia matrix D(q), coriolis term C(q,dq)dq and gravity vector G(q) of ATLAS, and other variables as well but I don't understand what these files exactly do.. , what do they optimize?, I don't see any animation or plot that could give me some hint. Maybe there are some problems with my computer.. why sould I expect when I run these files?

I have the next warning in matlab (several times) when I run these files (I don't know if this warning is affecting or not. I'm using MATLAB 2015b): Warning: Attribute scalartext not supported.

In HolonomicConstraint/validateName (line 346) In HolonomicConstraint (line 192) In RobotLinks/addContact (line 55) In RightStance (line 25) In main_opt (line 13)

I saw the response you gave above, but in that folder (matlab/+frost/+Animator) I can not run any file in MATLAB. Basically I would like to know Which is the main file that should I run to see some animation or some plots in order to see what's going on?.

I would appreciate if you could give us more detailed information in order to understand well how to use this code in other platforms. Maybe It could be good to see first how it works for RABBIT or other simple biped robot (since it would be computationally less expensive).

Best regards!

ankalou commented 7 years ago

Hi, @ayonga Thanks a lot for the reply, I will try to run the animation as you said when I return from holiday. It seems that the FiveLinkAnimator is used in the RABBIT example ? I tried to run Atlas because it was the only example featured in the documentation, but perhaps it is easier to rub RABBIT.

@VictorS10 I believe the key to animation lies in this section of code from RABBIT's main_opt.m (@ayonga please correct me if I'm wrong) :

%% Animation
q_log_R = states{1}.x; % Right stance
q_log_L = q_log_R([1:3,6:7,4:5],:); % symmetric Left stance
q_log_L(1:3,:) = q_log_L(1:3,:) + repmat((q_log_R(1:3,end)-q_log_R(1:3,1)),1,21);

t_log_R = tspan{1};
t_log_L = t_log_R + t_log_R(end);

q_log = [q_log_R, q_log_L];
t_log = [t_log_R, t_log_L];

anim = Animator.FiveLinkAnimator(t_log, q_log);
anim.pov = Animator.AnimatorPointOfView.West;
anim.Animate(true);
anim.isLooping = false;
anim.updateWorldPosition = true;
anim.endTime = 20;
conGUI = Animator.AnimatorControls();
conGUI.anim = anim;

Have a nice weekend everyone !

RossHartley commented 7 years ago

@ankalou @VictorS10 The RABBIT example contains a specific animator for that particular robot. The generic animator is still under development.

I just pushed a commit where I made a slight modification to the RABBIT example. It should now build the robot model, optimize a trajectory, and animate the gait by simply running the main_opt.m script.

ankalou commented 7 years ago

@RossHartley Thank you ! I tried the committed version, but there seems to be a problem with the p_Torso function (lines 64 and 92 of FivelinkAnimator.m). Apparently it is necessary to generate the pHT value and to run the animator, but I found no other mention of this function in the rest of the project... Could there be a file missing ?

Edit : on second look, p_q2_right and left and p_Right and LeftToe are missing as well... I'm definitely missing something.

RossHartley commented 7 years ago

@ankalou I accidentally had line "rabbit.ExportKinematics([export_path,'kinematics/']);" comented out. This function generates the forward kinematics functions for a number of points on the robot that are used for animation.

I uncommented the line, and recommitted. The example should run for you after this change (let me know if this is not the case).

ankalou commented 7 years ago

@RossHartley Thanks a lot, I have the animation now ! It looks nice :)

VictorS10 commented 7 years ago

Yes, thanks! I looks great!

I just had some problems with the "datetime" in the "build_mex.m", since my OS is in french for one computer and in spanish for another. To fix that I just replace the line 55:


lang = getenv('LANG');


for:


lang = get(0, 'Language'); if strcmp(lang,'es_mx') lang = 'es_ES'; end


since the function "getenv('LANG')" gives me nothing. Finally, If I get "lang= 'es_mx' " it does not work, I think it's not compatible, that's why I change to 'es_ES'. =)

This was the original error: Error using datetime (line 598) Unable to parse date/time string '30-ago.-2017 10:42:23' using the format 'dd-MMMM-yyyy HH:mm:ss'. If the string contains day, month, or time zone names in a language foreign to the 'en_US' locale, those might not be recognized. You can specify a different locale using the 'Locale' parameter. Error in build_mex (line 63) mexDate = datetime(mexFile.date,'InputFormat','dd-MMMM-yyyy HH:mm:ss'); Error in SymExpression/export (line 104) build_mex(export_path,filename); Error in RABBIT/ExportKinematics (line 79) export(position, 'Vars', vars, 'File', filename); Error in main_opt (line 58) rabbit.ExportKinematics([export_path,'kinematics/']);

On the other hand, are there some papers, reports or other documents related to this development? (in order to know better the algorithm, advantages with respect to others, etc)

Thanks again!

ayonga commented 7 years ago

@VictorS10 Great Finding! We had the "Locale" issue when we were using it at France, and we thought we fixed it. Apparently, there is a better solution. Would you actually make a pull request for this change? Thanks.

Regarding the paper about this project. you can check out our most recent IROS paper. Preprint version can be found here. I also have a online documentation site at https://ayonga.github.io/frost-dev/. Some contents are out-of-date on that site, and I am currently updating it.

ankalou commented 7 years ago

Hi, I found how to solve the locale issue (tested on linux in french and in english, and on windows in spanish). If you use the method mexFile.datenum instead of mexFile.date, the result is independent of the system locale. You can then convert back to human-readable time using datetime to keep the debugging easy. To resume, you should replace lines 55-62 of build_mex.m by the following :

mexDate = datetime(mexFile.datenum,'ConvertFrom','datenum');
srcData = datetime(src_file.datenum,'ConvertFrom','datenum');

I'm not sure how to make a pull request, so if you add this change yourself it might be easier :)

ayonga commented 7 years ago

Thanks @ankalou !

I will make the changes you suggested.