Skip to content

Commit

Permalink
Simple rviz panel for interaction with spot
Browse files Browse the repository at this point in the history
Can use the panel to claim and release the lease, power on and off, sit down and stand up, and set the body pose.

To add, go to panels>add new panel and select SpotControlPanel in spot_viz
  • Loading branch information
heuristicus committed Jun 23, 2021
1 parent caacc5d commit c3a4f12
Show file tree
Hide file tree
Showing 7 changed files with 575 additions and 198 deletions.
29 changes: 28 additions & 1 deletion spot_viz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
cmake_minimum_required(VERSION 2.8.3)
project(spot_viz)

find_package(catkin REQUIRED COMPONENTS)
find_package(catkin REQUIRED COMPONENTS rviz)

catkin_package()

set(CMAKE_AUTOMOC ON)

if(rviz_QT_VERSION VERSION_LESS "5")
message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
include(${QT_USE_FILE})
else()
message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets UiTools)
set(QT_LIBRARIES Qt5::Widgets Qt5::UiTools)
endif()

include_directories(
${catkin_INCLUDE_DIRS}
)

set(SRC_FILES
src/spot_panel.cpp
)

add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})

install(TARGETS
${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY rviz DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(FILES plugin_description.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
9 changes: 8 additions & 1 deletion spot_viz/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@

<buildtool_depend>catkin</buildtool_depend>

<build_depend>qtbase5-dev</build_depend>
<build_depend>rviz</build_depend>

<exec_depend>libqt5-core</exec_depend>
<exec_depend>libqt5-gui</exec_depend>
<exec_depend>libqt5-widgets</exec_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>rviz</exec_depend>

<export>
<rviz plugin="${prefix}/plugin_description.xml"/>
</export>
</package>
</package>
9 changes: 9 additions & 0 deletions spot_viz/plugin_description.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<library path="lib/libspot_viz">
<class name="spot_viz/SpotControlPanel"
type="spot_viz::ControlPanel"
base_class_type="rviz::Panel">
<description>
A panel for controlling the Boston Dynamics Spot robot with the Clearpath driver
</description>
</class>
</library>
231 changes: 231 additions & 0 deletions spot_viz/resource/spot_control.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>456</width>
<height>618</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="claimLayout">
<item>
<widget class="QPushButton" name="claimLeaseButton">
<property name="text">
<string>Claim Lease</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="releaseLeaseButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Release Lease</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="powerLayout">
<item>
<widget class="QPushButton" name="powerOnButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Power On</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="powerOffButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Power Off</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="sitStandLayout">
<item>
<widget class="QPushButton" name="sitButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Sit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="standButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Stand</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="bodyPoseGridLayout">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="bodyPoseLabel">
<property name="text">
<string>Body Pose Control</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="rollLabel">
<property name="text">
<string>Roll</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="yawLabel">
<property name="text">
<string>Yaw</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="setBodyPoseButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Set Body Pose</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="pitchLabel">
<property name="text">
<string>Pitch</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="bodyHeightLabel">
<property name="text">
<string>Body height</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="bodyHeightSpin">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>2</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="rollSpin">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="pitchSpin">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="yawSpin">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit c3a4f12

Please sign in to comment.