Wiki

Clone wiki

scl-manips-group / install / bsoe_gui_ext

Overview

This extension creates a graphical user interface (GUI) with interactive features, and refined mouse control. It is built upon FREEGLUT. It contains an example built upon a new simulations application template. This application is highly modularized, and acts as a replacement for CRobotApp. Code is easily transferable.

Contact

Brian S.

PRE-REQUISITES

(1) Custom version of SCL, with minor SCL source modifications. Please contact me to obtain this. Please note that these changes are minimal, but are NOT SUPPORTED yet, and are not part of the master. This means that pulling the latest version of SCL master and updating the source code requires a manual merge. I will not be updating this modified SCL source code with the latest SCL master source changes. In the future, these modification may be merged into master, in which case, pulling the master for updates would become compatible.

(2) Trajectory extension (bitbucket). This is not strictly necessary. You can comment out all trajectory related code in src/gui/GlutHandlers.cpp, and comment out the trajectory extension CMakeLists include, within the scl_contact_example CMakeLists. This trajectory functionality within the GUI doesn't serve any functional purpose besides as a starting point for designing your own GUI trajectory interactions.

https://bitbucket.org/samirmenon/scl-manips-group/wiki/install/bsoe_traj_ext

GUI FEATURES

  • See application_linux/scl_contact_example. sh run_pr2.sh or sh run_multi_pr2.sh
  • Specify keyboard ui points in the XML. NOTE: Example application will crash if no UI point specified.
  • Click and drag operational points. Ctrl-click to select multiple points.
  • Add cameras to robot links in XML. Switch between views (key 0).
  • Apply external disturbances with mouse.
  • Refined camera movement. Mimics SolidWorks mouse-camera control around a fixed point (scroll wheel). Hold Ctrl-click to pan camera.
  • Query robot link user has last clicked. Offers a framework for further expansion.
  • No more command line arguments. See run_pr2.sh for example. NOTE: Specify only one controllers in XML.

APPLICATION

application_linux/scl_contact_example This example uses the GUI extension, and supports multiple robots. If you have the dynamics3d extension (see Kenji), then you can simulate contact for robots. Self-collision is simulated, but not robot-to-robot collision is simulated, because each robot runs on its own physics engine (see Samir). By default, the tao dynamics engine is uses so contact is not possible.

The example application template is a stripped down, restructuring of CExampleApp/CRobotApp. Please note that this extension does not support CRobotApp derived classes. However, code is easily transferable. Like before, add the custom tasks registrations function calls, add any extra initialization, and fill in stepMySimulation.

Main()

  1. CSimulationApp initialize
  2. CGraphics intialize
  3. CArguments inialize
  4. Multi-thread
    1. Run graphics and GUI
    2. Run dynamics and controls
    3. Run console shell

Class CSimulationApp - create and run dynamics and controller
Class CGraphics - create and run graphics and GUI
Class CArguments - parse any user defined arguments

INSTALLATION

You will need a custom version of SCL that has minor changes to the source code. Please contact me. Then add the extension.

# Get the modified SCL branch (scl-gui-dev branch).
# Build SCL and verify that example works.
# Add the extension
$ cd <scl-base-dir.git>
$ git checkout -b <my-fav-branch-with-gui-ext>
$ git submodule add https://<my-bitbucket-id>@bitbucket.org/bsoe/scl-gui-ext.git src/scl_ext/gui

NOTES FOR WRITING YOUR OWN APPLICATION

There are a few nuances to the new application template. These are handled if you build off the example application. However, they are still worth knowing.

CMakeList

#Set the compiler flag to use the extension (#Define USE_GUI_EXT)
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -std=c++0x -DGRAPHICS_ON -DW_THREADING_ON -DNDEBUG -DUSE_GUI_EXT")
#Include the following extension source files
INCLUDE(${SCL_BASE_DIR}src/scl_ext/gui/CMakeLists.txt)
#Add to the executable
add_executable(scl_contact_example_ctrl ${ALL_SRC} ${GUI_EXT_SRC})

XML

Add the user interface tags to the configuration file.

<!--user interface specifications, how to control tasks-->
<user_interface name = "pr2bot_hand">      
   <!--graphical point for mouse and keyboard-->
   <keyboard_key_set name="pr2bot_hand0">
      <robot>Pr2Bot</robot> <!--robot name-->
      <task>hand</task>     <!--task it controls-->
      <index>0</index>      <!--which set of keyboard keys-->
   </keyboard_key_set>
   <keyboard_key_set name="pr2bot_hand1">
      <robot>Pr2Bot</robot> <!--robot name-->
      <task>hand2</task>    <!--task it controls-->
      <index>1</index>      <!--which set of keyboard keys-->
   </keyboard_key_set>
</user_interface>

Application

In CSimulationApp::stepMySimuation(), update the task goal position from the GUI points. The GUI will never write to the tasks, to ensure thread safety.

//Update the operational point tasks position from UI point
scl::SGlut* glut_data = scl::SGlutGlobal::getData();
for (auto ui_point_pair : glut_data->op_point_) {
    scl::SGlutOpPoint* ui_point = ui_point_pair.second;
    if (ui_point->has_been_init_) {
        ui_point->task_->setGoalPos(ui_point->position_global_);
    }
}

The GUI point struct (scl::SGlutOpPoint) contains a rotation matrix, which represents the coordinates frames of the GUI Point. For example, updating the rotation frame to the robot body frame will ensure the 'w' key always moves the robot forward, no matter it's orientation in the world coordinates.

Other

Please read through the code and comments.

How to update the extensions

Navigate to the directory where you added the extension and do a git pull:

$ cd <scl-base-dir.git>
# Save all your changes (so you can get the latest submodule)
$ git stash 
# Go to the submodule dir (you have to do this to pull the submodule git repo)
$ cd src/scl_ext/gui
# Note that this is the submodule's origin/master branch. This will update it to the latest code.
$ git pull origin master
# Now your submodule is updated. So you have to commit the updated version to your actual scl branch.
$ cd ../../
$ git commit -a
# Now that you've got the updated submodule and committed it to your branch. Get your working code back.
$ git stash pop

Updated