Explaining callbacks

You can get the complete code from chapter_8_codes/Matlab/teleop.m. Let's look at the content and functions of each callback. The first callback we are going to see is for the ROS MASTER IP edit box:

    function edit1_Callback(hObject, eventdata, handles) 
    global ros_master_ip 
    ros_master_ip = get(hObject,'String') 

When we enter an IP address from the ROS network in this edit box, it will store the IP address as a string in a global variable called ros_master_ip. If you don't enter the IP, then a default value is loaded, defined outside the callback.

Here are the initial values of ros_master_ip, ros_master_port, and teleop topic.

 ros_master_ip = '192.168.1.102'; ros_master_port = '11311'; teleop_topic_name = '/cmd_vel_mux/input/teleop'; ...

Get ROS Programming: Building Powerful Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.