Skip to content
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

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

Open
ArsyadAzhari opened this issue Jan 15, 2016 · 26 comments

Comments

@ArsyadAzhari
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link

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

@ArsyadAzhari
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link
Author

how to do that please....

@MarcusFutterlieb
Copy link

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
Copy link
Author

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

  • there are 2 or more robot in the simulator
  • the robot can manually drive (using control button such as slider) or automated (following the leader)
  • the second window (option figure window), is used to plot (display) information (parameters) about V, and W of each robot
  • in the bottom of the option figure window, there are control button (such as slider) to manually control the robot and a button to make the robot automaticallly driven

@ArsyadAzhari
Copy link
Author

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

  • i want to use the checkbox in the option figure to change the controller to GoToAngle (not AOandGTG)
  • i also want to use the slider to varying the speed and linear velocity of the robot, so there will be two slider

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
Copy link

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:

  • Item Go to your robots supervisor (e.g. +simiam/+controller/+khepera3/K3Supervisor.m)
  • Item There try to locate the part that chooses which controller is used (for me this is line 141-148)
 if (obj.check_event('at_goal'))
                obj.switch_to_state('stop');
            else
                obj.switch_to_state('ao_and_gtg');
            end 
  • Item Here try to gain access to your figure

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

  • Item Once you have the figure handle you can access its elements (slider, check box, etc). Here is what I did to set the velocity in AOandGTG.m

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
Copy link
Author

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
Copy link
Author

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

@MarcusFutterlieb
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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

@MarcusFutterlieb
Copy link

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
Copy link
Author

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

@MarcusFutterlieb
Copy link

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
Copy link
Author

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
Copy link

Dadwi commented May 9, 2016

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

@ArsyadAzhari
Copy link
Author

the latest demo version...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants