5 #include "ui_SimControlPanel.h" 13 mb.setText(QString(text.c_str()));
21 QTableWidget& table) {
23 table.setColumnCount(2);
28 for (
s32 col = 0; col < 2; col++) {
29 QTableWidgetItem* cell = table.item(i, col);
31 cell =
new QTableWidgetItem;
32 table.setItem(i, col, cell);
36 table.item(i, 0)->setText(QString(kv.first.c_str()));
37 table.item(i, 1)->setText(QString(kv.second->toString().c_str()));
46 : QMainWindow(parent),
48 _userParameters(
"user-parameters"),
60 }
catch (std::runtime_error& ex) {
65 printf(
"[SimControlPanel] Failed to load default user settings!\n");
72 printf(
"[SimControlPanel] Init simulator parameters...\n");
77 "[ERROR] Simulator parameters are not fully initialized. You forgot: " 80 throw std::runtime_error(
"simulator not initialized");
82 printf(
"\tsim parameters are all good\n");
120 if (
ui->cheetah3Button->isChecked()) {
122 }
else if (
ui->miniCheetahButton->isChecked()) {
130 if (!
ui->simulatorButton->isChecked() && !
ui->robotButton->isChecked()) {
132 "Error: you must select either robot or simulation mode");
139 printf(
"[SimControlPanel] Initialize Graphics...\n");
146 printf(
"[SimControlPanel] Initialize simulator...\n");
152 printf(
"[SimControlParameter] Load terrain...\n");
161 printf(
"[SimControlPanel] Init Robot Interface...\n");
255 auto cell =
ui->simulatorTable->item(row, 0);
256 std::string cellName = cell->text().toStdString();
258 if (cellName ==
"") {
271 parameter.setFromString(
272 ui->simulatorTable->item(row, 1)->text().toStdString());
273 }
catch (std::exception& e) {
279 printf(
"[ERROR] invalid data, restoring old data!\n");
281 parameter.set(oldValue, kind);
287 ui->simulatorTable->item(row, 1)->setText(
294 ui->simulatorTable->item(row, 1)->setText(
295 QString(parameter.toString().c_str()));
304 QString fileName = QFileDialog::getSaveFileName(
305 nullptr, (
"Save Simulator Table Values"),
"../config",
"All Files (*)");
306 if (fileName ==
nullptr || fileName ==
"") {
320 QString fileName = QFileDialog::getOpenFileName(
321 nullptr, (
"Load Simulator Table Values"),
"../config",
"All Files (*)");
322 if (fileName ==
nullptr || fileName ==
"") {
330 "new settings file %s doesn't contain the following simulator " 332 fileName.toStdString().c_str(),
334 throw std::runtime_error(
"bad new settings file");
346 auto cell =
ui->robotTable->item(row, 0);
347 std::string cellName = cell->text().toStdString();
349 if (cellName ==
"") {
355 .collection.lookup(cellName);
362 parameter.setFromString(
ui->robotTable->item(row, 1)->text().toStdString());
363 }
catch (std::exception& e) {
368 printf(
"[ERROR] invalid data, restoring old data!\n");
369 parameter.set(oldValue, kind);
374 ui->robotTable->item(row, 1)->setText(
383 cellName, parameter.get(parameter._kind), parameter._kind,
false);
387 ui->robotTable->item(row, 1)->setText(
388 QString(parameter.toString().c_str()));
392 cellName, parameter.get(parameter._kind), parameter._kind,
false);
398 QString fileName = QFileDialog::getSaveFileName(
399 nullptr, (
"Save Robot Table Values"),
"../config",
"All Files (*)");
400 if (fileName ==
nullptr || fileName ==
"") {
408 QString fileName = QFileDialog::getOpenFileName(
409 nullptr, (
"Load Quadruped Table Values"),
"../config",
"All Files (*)");
410 if (fileName ==
nullptr || fileName ==
"") {
419 fileName.toStdString());
422 "new settings file %s doesn't contain the following robot " 424 fileName.toStdString().c_str(),
426 throw std::runtime_error(
"bad new settings file");
433 kv.first, kv.second->get(kv.second->_kind), kv.second->_kind,
false);
443 "new settings file %s doesn't contain the following robot " 445 fileName.toStdString().c_str(),
447 throw std::runtime_error(
"bad new settings file");
453 kv.first, kv.second->get(kv.second->_kind), kv.second->_kind,
false);
461 QString fileName = QFileDialog::getOpenFileName(
462 nullptr, (
"Load Terrain Definition"),
"../config",
"All Files (*)");
463 if (fileName ==
nullptr || fileName ==
"") {
478 auto cell =
ui->userControlTable->item(row, 0);
479 std::string cellName = cell->text().toStdString();
481 if (cellName ==
"") {
495 parameter.setFromString(
ui->userControlTable->item(row, 1)->text().toStdString());
496 }
catch (std::exception& e) {
501 printf(
"[ERROR] invalid data, restoring old data!\n");
502 parameter.set(oldValue, kind);
507 ui->userControlTable->item(row, 1)->setText(
509 .collection.lookup(cellName)
518 cellName, parameter.get(parameter._kind), parameter._kind,
true);
522 ui->userControlTable->item(row, 1)->setText(
523 QString(parameter.toString().c_str()));
527 cellName, parameter.get(parameter._kind), parameter._kind,
true);
534 QString fileName = QFileDialog::getOpenFileName(
535 nullptr, (
"Load User Table Values"),
"../config",
"All Files (*)");
536 if (fileName ==
nullptr || fileName ==
"") {
544 fileName.toStdString());
554 kv.first, kv.second->get(kv.second->_kind), kv.second->_kind,
true);
560 kv.first, kv.second->get(kv.second->_kind), kv.second->_kind,
true);
568 QString fileName = QFileDialog::getSaveFileName(
569 nullptr, (
"Save User Table Values"),
"../config",
"All Files (*)");
570 if (fileName ==
nullptr || fileName ==
"") {
584 homeState.
q << -0.05, -0.8, 1.7, 0.05, -0.8, 1.7, -0.05, -0.8, 1.7, 0.05, -0.8, 1.7;
585 homeState.
qd = homeState.
q;
593 kickVelocity <<
ui->kickAngularX->text().toDouble(),
594 ui->kickAngularY->text().toDouble(),
ui->kickAngularZ->text().toDouble(),
595 ui->kickLinearX->text().toDouble(),
ui->kickLinearY->text().toDouble(),
596 ui->kickLinearZ->text().toDouble();
void resetGameController()
void updateTerrainLabel()
static void updateQtableWithParameters(ControlParameters ¶ms, QTableWidget &table)
const FBModelState< double > & getRobotState()
void runAtSpeed(bool graphics=true)
void on_goHomeButton_clicked()
ControlParameterCollection collection
void on_loadSimulatorButton_clicked()
ControlParameterValueKind _kind
void sendControlParameter(const std::string &name, ControlParameterValue value, ControlParameterValueKind kind, bool isUser)
void on_loadRobotButton_clicked()
ControlParameterValueKind
std::map< std::string, ControlParameter * > _map
void on_setTerrainButton_clicked()
SimControlPanel(QWidget *parent=nullptr)
ControlParameters _userParameters
bool isFullyInitialized()
RobotInterface * _robotInterface
typename Eigen::Matrix< T, 3, 1 > Vec3
#define SIMULATOR_DEFAULT_PARAMETERS
SimulatorControlParameters _parameters
void on_saveUserButton_clicked()
void loadRobotParameters(RobotControlParameters ¶ms)
void loadTerrainFile(const std::string &terrainFileName, bool addGraphics=true)
void on_kickButton_clicked()
void on_joystickButton_clicked()
void on_stopButton_clicked()
void on_userControlTable_cellChanged(int row, int column)
std::string getConfigDirectoryPath()
typename Eigen::Matrix< T, 6, 1 > SVec
void writeToYamlFile(const std::string &path)
#define DEFAULT_TERRAIN_FILE
void setRobotState(FBModelState< double > &state)
void on_robotTable_cellChanged(int row, int column)
PeriodicTaskManager * _interfaceTaskManager
bool _ignoreTableCallbacks
bool checkIfAllSet()
are all the control parameters initialized?
ControlParameter & lookup(const std::string &name)
RobotControlParameters & getRobotParams()
void loadUserParameters(ControlParameters ¶ms)
RobotControlParameters & getParams()
Graphics3D * _graphicsWindow
void setAnimating(bool animating)
void on_saveSimulatorButton_clicked()
static void createErrorMessage(const std::string &text)
QT gui for the simulator.
void on_simulatorTable_cellChanged(int row, int column)
void defineAndInitializeFromYamlFile(const std::string &path)
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
void loadSimulationParameters(SimulatorControlParameters ¶ms)
Interface to set gains/control parameters for simulator and robot These are designed to be updated in...
void on_loadUserButton_clicked()
#define DEFAULT_USER_FILE
void initializeFromYamlFile(const std::string &path)
SimulatorControlParameters & getSimParams()
void on_startButton_clicked()
void sendControlParameter(const std::string &name, ControlParameterValue value, ControlParameterValueKind kind, bool isUser)
void on_saveRobotButton_clicked()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Quat< T > bodyOrientation
std::string generateUnitializedList()
void on_driverButton_clicked()
std::string _terrainFileName