Wiki
Clone wikiscl-manips-group / scl_contact / GUI
(1) Copy qtgui and qcustomplot into /scl-contact/src/scl_ext
(2) Copy gui_main.cpp into application directory
CMakeList.txt
cmake_minimum_required(VERSION 2.8.9)
###########SPECIAL CODE TO FIND AND LINK QT5 LIB DIR #############
# Find includes in corresponding build directories
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(QT_USE_QTOPENGL TRUE)
#set(QCUSTOMPLOT_USE_LIBRARY TRUE)
SET(QTGUI_DIR ${SCL_BASE_DIR}src/scl_ext/qtgui)
SET(QTGUI_SRC ${SCL_BASE_DIR}/applications-linux/<insert application directory here>l/gui_main.cpp
${QTGUI_DIR}/CSimulatorUI.cpp
${QTGUI_DIR}/ui_src/CMainWindow.cpp
#${QTGUI_DIR}/ui_src/CGLWindow.cpp
${QTGUI_DIR}/ui_src/CGainsWindow.cpp
${QTGUI_DIR}/ui_src/CActuatorsWindow.cpp
${QTGUI_DIR}/ui_src/CControlWindow.cpp
${QTGUI_DIR}/ui_src/CPlotWindow.cpp
${QTGUI_DIR}/ui_src/CLinksWindow.cpp
${QTGUI_DIR}/ui_src/CFileMenu.cpp
#${QTGUI_DIR}/ui_src/CCameraMenu.cpp
${QTGUI_DIR}/ui_src/CControllerMenu.cpp
)
SET(QTCP_DIR ${SCL_BASE_DIR}src/scl_ext/qcustomplot)
SET(QTCP_SRC ${QTCP_DIR}/qcustomplot.cpp)
# Find the QtWidgets library
find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Gui)
#find_package(Qt5Declarative)
find_package(Qt5PrintSupport)
find_package(Qt5OpenGL)
find_package(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(./build_dbg)
INCLUDE_DIRECTORIES(./build_rel)
################Initialize the executable#################
#Set the include directories
INCLUDE_DIRECTORIES(...blah blah ... ${QTCP_DIR} ${QTGUI_DIR})
add_executable(${PROJECT_NAME}_gui ${QTGUI_SRC}
${QTCP_SRC}
${GUI_EXT_SRC}
${TRAJ_EXT_SRC}
${GUI_EXT_HEADER}
${HEADERS_3RD_PARTY}
)
###############SPECIAL CODE TO FIND AND LINK QT WIDGET LIB DIR ##################
# Use the Widgets module from Qt 5.
#qt5_use_modules(${PROJECT_NAME} Core Widgets Gui PrintSupport OpenGL)
qt5_use_modules(${PROJECT_NAME}_gui Core Widgets Gui PrintSupport OpenGL)
target_link_libraries(${PROJECT_NAME}_gui ${SCL_LIBRARY})
target_link_libraries(${PROJECT_NAME}_gui ${CHAI_LIBRARY})
target_link_libraries(${PROJECT_NAME}_gui ${DYN_LIBRARY})
target_link_libraries(${PROJECT_NAME}_gui gomp GL GLU GLEW glut ncurses rt dl)
Application
- in .hpp file:
public: sutil::CSharedMemory<SimulationUI, char> shmem;
- in .cpp file:
- in initialization list:
shmem(8089, 'x')
- in constructor:
- in initialization list:
bool flag = shmem.shmCreate(); if(false == flag) { throw(std::runtime_error("Simulation: Could not create shared memory")); }
Set the following information during application initialization:
- shmem.data_->robot_name_: name of the robot - used to pull information about the robot in simulation
- shmem.data_->joint_names_: joint names of the robot - used to display joint state in Actuators window
- shmem.data_->numDOF: number of degrees of freedom of robot - used to set up Actuators window desply
- shmem.data_->actuator_force_maxes_: Maximum forces for each joint - used to show the percentage of the maximum force currently exerted on the joint in Actuators window
- shmem.data_->numTasks: number of operational control tasks
- shmem.data_->numJoints: number of joints
- shmem.data_->task_names_: names of the operational control tasks
- shmem.data_->kp_values_: kp values for the operational control tasks - indexes of these values correspond with index values of the task names
- shmem.data_->kv_values_: kv values for the operational control tasks - indexes of these values correspond with index values of the task names
- shmem.data_->ki_values_: ki values for the operational control tasks - indexes of these values correspond with index values of the task names
At the beginning of step my simulation:
while(*shmem.data_signal_ != 'g') {sleep(1);}
Set the following information in stepMySimulation():
- shmem.data_->pos_goal: goal position
- shmem.data_->rot_goal: goal rotation - saved as Euler angles
- shmem.data_->vel_goal: goal velocity
- shmem.data_->force_goal: goal force
- shmem.data_->joint_forces_: current forces on each joint - indexes of these values correspond with index values of the joint names
- shmem.data_->joint_positions_: current positions of each joint - indexes of these values correspond with index values of the joint names
- shmem.data_->joint_velocities_: current velocities of each joint - indexes of these values correspond with index values of the joint names
- shmem.data_->joint_accelerations_: : current accelerations of each joint - indexes of these values correspond with index values of the joint names
- shmem.data_->force: current force on the end-effector with respect to the end-effector frame
- shmem.data_->control_type_: current control type
- shmem.data_->pos: current position of the end-effector with respect to the global frame
- shmem.data_->rot: current rotation of the end-effector with respect to the global frame - saved as Euler angles
To fully understand how information is shared between simulation & GUI, reference this diagram:
For examples of how to updated the shared memory variables, reference scl_box_gui in scl-contact branch control_analysis
make_rel.sh
make -j8 && cp -rf scl_box ../ && cp -rf scl_box_app_gui ../ && cd ..
Updated