- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
Adding New Node and API Function
        Darko Lukić edited this page Jun 10, 2020 
        ·
        33 revisions
      
    - Webots Core:
- Add a .wrl file in 
webots/resources/nodes/. - Add a .png image of size 128x128 pixels in 
webots/resources/nodes/icons/. - Add .cpp and .hpp files in 
src/webots/nodes, and add a new entry insrc/webots/Makefile. - Add an enum entry in 
webots/include/controller/c/webots/nodes.handwebots/include/controller/cpp/webots/Node.hpp. - Add the node name in 
wb_node_get_name()function insrc/lib/Controller/api/node.c. - Add a 
gen_const()entry inwebots/lib/controller/matlab/mgenerate.pyand run it. - Add the node in 
src/webots/nodes/utils/WbConcreteNodeFactory.cpp. - Add the node in 
src/webots/nodes/utils/WbNodeUtilities.cpp. - Add the node in 
src/webots/core/WbLanguage.cpp. 
 - Add a .wrl file in 
 - Documentation:
- Create a new file 
webots/docs/references/'node_name'.mdand add it to the menu. - Update 
webots/docs/reference/supervisor.md. - Update 
webots/docs/reference/nodes-and-keywords.md. - Add the new node in 
webots/docs/reference/node-chart.md. 
 - Create a new file 
 - If the node is a device:
- Add in 
webots/lib/controller/matlab/launcher.mandwebots/lib/controller/matlab/allincludes.hthe entries corresponding to the device node. - If the node name is newDevice, declare and define 
getNewDevice()andCreateNewDevice()inRobot.hppandRobot.cpp(#include in Robot.hpp needed). - If the node name is new_device, add 
extern void wb_new_device_init(WbDevice *)indevice.cand add one more branch to the switch indevice.c::wb_device_init(); - Add a corresponding robot window widget in 
webots/resources/projects/plugins/robot_windows/generic/. - If the node name is newDevice, add 
RosNewDevice.cppandRosNewDevice.hppfiles inwebots/projects/default/controller/ros/and add a new entry inwebots/projects/default/controller/ros/Makefile. If the new device is a sensor with a ~getValue() function, creates a topic for it. - Add the 
RosNewDeviceto the constructor ofRos.cppinwebots/projects/default/controller/ros/. - Go to Adding a new API function
 - Add a demo featuring this new device in 
webots/projects/samples/devices/and add it in thewebots/projects/guided_tour.txt. 
 - Add in 
 
- Add it in 
/include/controller/c/webots/. - Add it in 
/src/lib/Controller/api/(don't forget to include a "bad device tag" error message if the function takes a WbDeviceTag). - Add it in 
/src/lib/Controller/Controller.def. - Add it in 
/src/webots/nodes/. - Add it in 
/include/controller/cpp/webots/. - Add it in 
/resources/languages/cpp/. - Add it in 
/resources/languages/java/, i.e. in Makefile and controller.i. - Add it in 
/resources/languages/python/i.e. in Makefile and controller.i. - Add it in 
/lib/controller/matlab/mgenerate.pyand run it. - Add it in 
/src/webots/core/WbLanguage.cpp. - Add it in 
/docs/reference/'device_name'.md. - Add a sample usage demo in 
/projects/sample/. - Add it in 
/projects/default/controller/ros/:- Create a service or message description file (if possible use an already existing one or a standard one) 
include/srv/<function_name>.srvorinclude/msg/<function_name>.msgand run/projects/default/controllers/ros/headersGenerator.pyto generate headers. - Add it in 
Ros<Device>class: define a function callback and a service server (for a service) or a topic (for a message). - If the function corresponds to getting a value that changes at each step (e.g. sensor output) prefer a message/topic to a service.
 - Try to use as much as possible standard message types, sensor message types or geometry message types.
 - Add it in the 
/projects/languages/ros/webots_ros/CMakeLists.txtfile. - Add a test in 
/projects/languages/ros/webots_ros/src/complete_test.cpp. 
 - Create a service or message description file (if possible use an already existing one or a standard one) 
 - Add a new API test in 
/tests/api(new world and controller).