jdelacroix / simiam

A MATLAB-based educational bridge between theory and practice in robotics.
http://gritslab.gatech.edu/projects/robot-simulator
Other
104 stars 52 forks source link

How to change the environment and add some control button to the simulator ? #16

Open ArsyadAzhari opened 8 years ago

ArsyadAzhari commented 8 years ago

hi, i want to ask about how to change the environment and add some control button to the simulator ? please i need to help... if you don't mind....

MarcusFutterlieb commented 8 years ago

Hey Arsyad, maybe I can be of help. You can change the environment simply by changing the settings.xml file in the simiam root directory. Make sure that you keep the xml syntax. The simulator might run into trouble reading your file otherwise.

As for control buttons I believe you need to take a look into the +simiam/+ui/AppWindow.m file. You can add whatever buttons you like there.

ArsyadAzhari commented 8 years ago

thanks a lots for your help, but i'am a newbie in matlab, i can delete the obstacle from settings.xml but i can't add some control button because i don't know what to do or what the code. can you give some reference to build or modify GUI from the m file ?

MarcusFutterlieb commented 8 years ago

Hey Arsyad,

no worries, everyone has to start somewhere. Can you be a bit more specific of what kind of buttons you want to add + what the functionality should be? In my version of the simulator I have added a second figure with some control buttons that allow to turn on/off certain features, but I have not yet added this to my fork, but I was planning to do so this weekend.

ArsyadAzhari commented 8 years ago

actually, i want to control the robot speed with a slider and the movement with A (Left) and D (Right) keyboard button. i also want to use 3 robot in the simulator, is it possible ? how ?

MarcusFutterlieb commented 8 years ago

Hey Arsyad,

what you want should be possible. I remember that when I first got the simulator I was able to change the robot speed online. I have looked through my old code and it does not seem to work the same way in the new version of simiam. However, having a second window for a some control input buttons is not a problem. You can have a look at my fork if you want while I try to find out how to access the robot/controllers from the +simiam/+ui/AppWindow.m file.

MarcusFutterlieb commented 8 years ago

You can now use the slider to reduce the speed of the trailing Khepera robot

ArsyadAzhari commented 8 years ago

thanks a lot, but how to add more robot into the simulator ? and how to put the all figure (all plot graphic) into the figure option window that you made ? i mean that in the second window there are all grafik figure and some control button.

MarcusFutterlieb commented 8 years ago

Hey Arsyad,

I think in order to add a new robot you have to create a new one +simiam/robot, but I am not 100% on this (I will check later this week). Can you elaborate on your second question? Do you want to include the option figure into the main simulator figure?

ArsyadAzhari commented 8 years ago

no, do you know the pop up plot graph that show up when the simulator start ? i want that plot graph data is shown in the option figure window, thats it.

ArsyadAzhari commented 8 years ago

how to do that please....

MarcusFutterlieb commented 8 years ago

Okay, that should not be so hard. If you can figure out the figure handle you should be able to apply any modifications you desire to the figure. Here is how I created my option figure: figure_handle = figure('Name','Option Interface','Position',[0,400,300,200]); and here is how I find the figure handle anywhere in the code: figure_handle = findobj('type','figure','name','Option Interface');

I believe the figures you are talking about are usually launched as figure 2 and 3 (one for each robot). It might help to give a specific name to these figures to find them back more consistently. I believe they are created in +simiam/+util/Plotter.m

Hope that helps

ArsyadAzhari commented 8 years ago

actually, i want to build platooning (leader-follower) formation using this simulator. the scenario is :

ArsyadAzhari commented 8 years ago

Marcus, sorry to bother you but, can you tell me how to do this things :

for all of that things (checkbox and two slider) i already build the figure in the option figure window, but i haven't create the callback function.

please teach me how to formulating function for that operation

MarcusFutterlieb commented 8 years ago

Hey Arsyad, it is pretty hard to help you without seeing the code, but from what I have gather of your request I think the best course of action is to look into the supervisor state machine of your robot. So here is what I would do:

 if (obj.check_event('at_goal'))
                obj.switch_to_state('stop');
            else
                obj.switch_to_state('ao_and_gtg');
            end 

figure_handle = findobj('type','figure','name','Your figure name');

figure_handle = findobj('type','figure','name','Option Interface'); if (isempty(figure_handle)==false) sliderhandle = findobj(figure_handle, 'tag', 'slider_speed'); slider_value = get(sliderhandle,'value'); value_tmp = obj.v_tmp*(slider_value/100); v = value_tmp/(log(abs(w)+2)+1); else v = obj.v_tmp/(log(abs(w)+2)+1); end%if

I hope I was able to give you some hints. I can have another look this weekend

ArsyadAzhari commented 8 years ago

marcus, in reality, the khepera3 has an ultrasonic sensor... can tell how to build the ultrasonic sensor of khepera robot in the simulator ? or can you show me how to add more ir range sensor and enlarge its range ?

ArsyadAzhari commented 8 years ago

marcus, i need a little help please... i want the robot drawing line if they are moving.... how to do that ???

MarcusFutterlieb commented 8 years ago

Where do you need the line? In the simulator, or do you just want to know the path the robots have executed during the simulation once it is over? I don t think the first option can be recommended, but you can certainly open a new figure in which you display the robots path. Something like:

figure(999999);
plot(robot_x,robot_y,'-ro');
ArsyadAzhari commented 8 years ago

i want to do the option 2, i have try the code [x, y, theta] = estimate unpack(); plot(x, y); and put it in the appwindow.m, but nothing happen...

MarcusFutterlieb commented 8 years ago

Hey Arsyad,

I am not 100% on this, but I don t think AppWindow.m is where you want to put this. My firt guess would be to put it in Simulator.m (somewhere in the function "step"). If you do:

figure(999999);
[x, y, theta] = estimate unpack();
plot(robot_x,robot_y,'-ro');

somewhere in there I think you should succeed. A couple of things though. It is probably better to work with the figure handle to always refer to the correct figure and it might be necessary to add a "hold on":

figure(999999);
[x, y, theta] = estimate unpack();
plot(robot_x,robot_y,'-ro');
hold on;

Otherwise the figure might be reloaded with out its history (so always just the current position of the robot). You could also just save the successive robot positions (write them into a file) and visualize the robots path after your experiment. If you don t need to see the robot path during the experiment this is most likely the least invasive method.

ArsyadAzhari commented 8 years ago

is it possible to draw the line inside the simulator field (option 1) ?

MarcusFutterlieb commented 8 years ago

Well, I feel like this will be much more complicated. For now the figure displays all the objects that you provided in the settings.xml file. Don t get me wrong, nothing is impossible, but for further help I would need to know what your aim is.

ArsyadAzhari commented 8 years ago

marcus, did you try the simulink demo of simiam ? why there is an error in msfun_Khepeera3 ???

MarcusFutterlieb commented 8 years ago

Hey Arsyad,

Unfortunately I have not tried the simulink demo so far. I would suggest that you open a new question for these, so people with more experience with the simulink version can see it and help you. :)

Marcus

ArsyadAzhari commented 8 years ago

i've succeed to put 3 robot in the simulator, and i want to make linear platooning formation of them.... i also succeed to build the formation using "go to goal" controller for every robot... but i realized that, to make linear platooning formation, i can follow the leader movement or i can follow the leaders path.... for now, i succeed to make linear platooning formation by following the leader movement using go to goal controller... so my next aim is to make linear platooning formation by following the leaders path, so my followers robot move precisely like the leader... is it can be done ? how ?

Dadwi commented 8 years ago

Good morning which version have you used to be able to put 3 robot in the simulator ?

ArsyadAzhari commented 8 years ago

the latest demo version...