![]() If no modifier (shift, control or alt) key is pressed, the key code is the ASCII code of the corresponding key or a special value (e.g., for the arrow keys). The returned value, if non-negative, is a key code corresponding to a key currently pressed. Note that the first key will be available only after the first sampling period elapsed.Īfter that, values can be read by calling the wb_keyboard_get_key function repeatedly until this function returns -1. The sampling_period parameter is expressed in milliseconds, and defines how frequently readings are updated. You may have to click inside the 3D window, so that it gets selected (e.g., active) and the key press events can be sent to the controller program.įirst, it is necessary to enable keyboard input by calling the wb_keyboard_enable function. These functions allow a controller program to read keys pressed on the computer keyboard when the 3D window of Webots is selected and the simulation is running. Period = wb_keyboard_get_sampling_period() WB_KEYBOARD_KEY, WB_KEYBOARD_SHIFT, WB_KEYBOARD_CONTROL, WB_KEYBOARD_ALT wb_keyboard_enable( sampling_period) WB_KEYBOARD_NUMPAD_RIGHT, WB_KEYBOARD_NUMPAD_DOWN, WB_KEYBOARD_NUMPAD_END, WB_KEYBOARD_NUMPAD_HOME, WB_KEYBOARD_NUMPAD_LEFT, WB_KEYBOARD_NUMPAD_UP, WB_KEYBOARD_RIGHT, WB_KEYBOARD_DOWN, WB_KEYBOARD_PAGEUP, WB_KEYBOARD_PAGEDOWN, Keep in mind that to control the robot, it must be selected.WB_KEYBOARD_END, WB_KEYBOARD_HOME, WB_KEYBOARD_LEFT, WB_KEYBOARD_UP, I would recommend at this point to save your world! Saving as always good. The code for the controller should now show up on the right. We’ll start with creating a brand new controller. The greatest thing with Webots is that you can code your robots right from You should have a scene like this! Except the robot should be moving around. You can then Ctrl-C + Ctrl-V your way to more crates! Of the wooden box, then modify the scale to 0.1 x 0.1 x 0.1, and translation It’s way too big, so select the drop down to the left ![]() Select the rectangle arena, then press the add button and search or “Box”, Let’s give him some more things to avoid… Crates! Simply rolls around the scene avoiding obstacles. Is the code that controls robots, and the default controller for this robot We have our first robot! Watch him running around.Įach robot has a controller attached to it which controls the robot. Then press the add button at the top to add the e-puck robot. On the left you can see all the elements of your world. ![]() You now have an arena! You can now put things inside this arena to play with. Then choose a directory to create the project.Īnd finally, check the final box saying you want a rectangle arena. We’ll be creating a new project directory with the wizard tab at the top:Ĭlick Next. Today we’ll be using webots to simulate and control a little e-puck robot. You can always comeīack, and I’ll even have little embeds so you can feel like you’re getting everything If you want to follow along with this tutorial It allows you to play with all sorts of robots on your computer. Thankfully, you can actually have your very own Nan robot without selling your soul. Oh wait, I think I have a spare lying around…. Oh wait, you tell me that you don’t have a spare 10 grand lying around? Well, that’s Go buy one! They’re only $7990 USD (10,720 AUD)! Bargain!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |