CoppeliaSim - Keyboard Input, Status Bar, Console Window, and Nil
According to http://www.forum.coppeliarobotics.com/viewtopic.php?f=9&t=1751 and http://www.forum.coppeliarobotics.com/viewtopic.php?f=9&t=5299 in CoppeliaSim forum, we can know that string.byte('A') represents character 'A' and auxiliaryData[1] stores keyboard input of simGetSimulatorMessage().
The dialog at bottom of CoppeliaSim is called status bar, while console window is hidden by default. By changing user setting, you can see it.
Warning: Closing console window leads to shutting down software CoppeliaSim itself.
Use simAddStatusbarMessage(auxiliaryData[1]) to print input message on status bar, then use print(auxiliaryData[1]) to print input message on console window.
You can check script of object naked car in folder example to know how to deal with keyboard input. For function reference, visit http://www.coppeliarobotics.com/helpFiles/en/apiFunctions.htm#simGetSimulatorMessage.
Sometimes functions return value nil which means nothing. It is not equal to 0 because it doesn't exist at all. To deal with value nil, we should use conditional statement such as if statement to check former return value of function. If former one exists, then you are able to use next return value which is not nil now. Without using if statement, script crashes when it bumps into value nil. For example, take a look at return values of simReadProximitySensor().
Comments
Post a Comment