How to use the GUI in Matlab.
We need Robotics Toolbox to be able to use our GUI. The Robotics Toolbox adds ROS functionality to matlab, which is used by us. This tutorial assumes you already have a Matlab with the Robotics Toolbox installed. The process might be a little bit long, but you only have to do it once (unless we change our message types definition anytime in the future).
If you want to test if ROS is working in Matlab, launch anything that has ROS, for instance:
roslaunch r5_src_simulation ValkyrieRviz.launch
In the Matlab terminal, run the following:
$ rosinit
$ rostopic list
If it returns the current topics from ROS, then everything works! In order to stop ROS from running in Matlab, run:
$ rosshutdown
In this competition we need to use some message types which doesn't come already in standard ROS. Adam created some message types and the SRC software that NASA released also have new message types. We need to make Matlab understand these message types. You need to install the robotics add-ons. For this, you need to be running Matlab as sudo. Then, run the following in a Matlab terminal:
For Matlab 2016 and newer:
$ roboticsAddons
For Matlab 2015 and older:
$ roboticsSupportPackages
Follow the instructions to install the add-ons. You will need a Mathworks account and password, but I guess you should have one by now if you have a license with the robotics toolbox.
The next step is to add the new message types: the ones that Adam created (called comm_comm) and the ones from NASA package (ihmc_msgs). In order to add these types to Matlab, do the following steps:
- Go to your /Documents folder and create a new folder called src.
- Copy the comm_comm folder from our repo into src.
- Copye the ihmc_msgs folder into src. You should be able to find it in /opt/ros/indigo/share/
- Open Matlab inside our folder /hcrl_src/GUI/addMsgsMatlab
- Open the file CreateRosCustumMsgs
- Change the path that goes to your Documents folder (I guess you will just have to change the user name, in mine is marcelino).
- Run the CreateRosCustomMsgs.m file. Sometimes it displays a bunch of warning related to Java, but you can ignore it.
- After running the procedure, Matlab asks you to follow 3 steps to finish the procedure. Do exactly what Matlab says.
- Once you do the previous steps, when you reopen Matlab and type 'rosmsg list', you should see messages starting with /comm_comm/*** and also /ihmc_msgs/***
If the last step worked, great! You can now use ROS in Matlab with the new datatypes defined.
In order to test the Matlab code that sends two waypoints for the hand position into NASA's simulation environment, do the following:
- Run SRC simulation: roslaunch srcsim qual2.launch init:=true walk_test:=false
- Wait until the initialization procedure is over. The terminal will display the following message:
[startup_robot-11] process has finished cleanly
- Open Matlab in the folder /hcrl_src/ihmc_development/Matlab/test_hand_waypoint
- Run the file SendHandData.m
You should be able to see the hand moving from initial position towards a waypoint to the left of the body then a second waypoint in front of it.