-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for load/unload worlds; add full list of features #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2252ff6
Add Worlds to UI
jhanca-robotecai d015f12
Fix LoadLevel; fix UI
jhanca-robotecai 2c2c02d
Change default tab
jhanca-robotecai 45b01d8
Add URI/name support; add offline/online switch
jhanca-robotecai 51a644e
Code review fixes
jhanca-robotecai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,9 @@ namespace q_simulation_interfaces | |
connect(ui_->setSimStateButton, &QPushButton::clicked, this, &SimulationWidget::SetSimulationState); | ||
connect(ui_->stepSimServiceButton, &QPushButton::clicked, this, &SimulationWidget::StepSimulationService); | ||
connect(ui_->ComboEntities, &QComboBox::currentTextChanged, this, [this]() { this->GetEntityState(true); }); | ||
connect(ui_->getAvailableWorldsButton, &QPushButton::clicked, this, &SimulationWidget::GetAvailableWorlds); | ||
connect(ui_->loadWorldButton, &QPushButton::clicked, this, &SimulationWidget::LoadWorld); | ||
connect(ui_->unloadWorldButton, &QPushButton::clicked, this, &SimulationWidget::UnloadWorld); | ||
|
||
// Connect spawn position spin boxes to update marker | ||
connect(ui_->doubleSpinBoxX, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, | ||
|
@@ -234,6 +237,104 @@ namespace q_simulation_interfaces | |
setSimulationStateService_->call_service_async(cb, request); | ||
} | ||
|
||
|
||
void SimulationWidget::LoadWorld() | ||
{ | ||
if (!loadWorldService_) | ||
{ | ||
QMessageBox::warning(this, "Service Not Available", | ||
"Load World service is not available. Please select a valid service."); | ||
return; | ||
} | ||
|
||
simulation_interfaces::srv::LoadWorld::Request request; | ||
auto selectedWorld = ui_->availableWorldsCombo->currentText(); | ||
request.uri = selectedWorld.toStdString(); | ||
|
||
std::cout << "Loading world: " << request.uri << std::endl; | ||
|
||
auto cb = [this](auto response) | ||
{ | ||
ProduceWarningIfProblem(this, "Load World", response); | ||
if (response) | ||
{ | ||
ui_->currentWorldLabel->setText("Current world: " + | ||
QString::fromStdString(response->world.world_resource.uri)); | ||
} | ||
}; | ||
loadWorldService_->call_service_async(cb, request); | ||
} | ||
|
||
void SimulationWidget::UnloadWorld() | ||
{ | ||
if (!unloadWorldService_) | ||
{ | ||
QMessageBox::warning(this, "Service Not Available", | ||
"Unload World service is not available. Please select a valid service."); | ||
return; | ||
} | ||
|
||
simulation_interfaces::srv::UnloadWorld::Request request; | ||
|
||
auto cb = [this](auto response) | ||
{ | ||
ProduceWarningIfProblem(this, "Unload World", response); | ||
if (response) | ||
{ | ||
ui_->currentWorldLabel->setText("Current world: "); | ||
} | ||
}; | ||
unloadWorldService_->call_service_async(cb, request); | ||
} | ||
|
||
void SimulationWidget::GetAvailableWorlds() | ||
{ | ||
if (!getAvailableWorldsService_) | ||
{ | ||
QMessageBox::warning(this, "Service Not Available", | ||
"Get Available Worlds service is not available. Please select a valid service."); | ||
return; | ||
} | ||
|
||
simulation_interfaces::srv::GetAvailableWorlds::Request request; | ||
request.offline_only = true; | ||
|
||
auto cb = [this](auto response) | ||
{ | ||
ProduceWarningIfProblem(this, "Get Available Worlds", response); | ||
if (response && response->result.result == simulation_interfaces::msg::Result::RESULT_OK) | ||
{ | ||
ui_->availableWorldsCombo->clear(); | ||
|
||
auto worlds = response->worlds; | ||
for (const auto& world : worlds) | ||
{ | ||
ui_->availableWorldsCombo->addItem(QString::fromStdString(world.world_resource.uri)); | ||
} | ||
} | ||
}; | ||
getAvailableWorldsService_->call_service_async(cb, request); | ||
} | ||
|
||
void SimulationWidget::GetCurrentWorld() | ||
{ | ||
if (!getCurrentWorldService_) | ||
{ | ||
return; | ||
} | ||
Comment on lines
330
to
335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other service handlers produce a warning if the service is not present. |
||
simulation_interfaces::srv::GetCurrentWorld::Request request; | ||
auto cb = [this](auto response) | ||
{ | ||
ProduceWarningIfProblem(this, "Get Current World", response); | ||
if (response && response->result.result == simulation_interfaces::msg::Result::RESULT_OK) | ||
{ | ||
ui_->currentWorldLabel->setText("Current world: " + | ||
QString::fromStdString(response->world.world_resource.uri)); | ||
} | ||
}; | ||
getCurrentWorldService_->call_service_async(cb, request); | ||
} | ||
|
||
void SimulationWidget::ActionThreadWorker(int steps) | ||
{ | ||
actionThreadRunning_.store(true); | ||
|
@@ -877,6 +978,47 @@ namespace q_simulation_interfaces | |
serviceInterfaces_.insert(setSimulationStateService_); | ||
} | ||
break; | ||
case ServiceType::SERVICE_GET_CURRENT_WORLD: | ||
serviceInterfaces_.erase(getCurrentWorldService_); | ||
getCurrentWorldService_ = shouldReset | ||
? nullptr | ||
: std::make_shared<Service<simulation_interfaces::srv::GetCurrentWorld>>(selectedServiceName, node_); | ||
if (getCurrentWorldService_) | ||
{ | ||
serviceInterfaces_.insert(getCurrentWorldService_); | ||
} | ||
GetCurrentWorld(); | ||
break; | ||
case ServiceType::SERVICE_GET_AVAILABLE_WORLDS: | ||
serviceInterfaces_.erase(getAvailableWorldsService_); | ||
getAvailableWorldsService_ = shouldReset | ||
? nullptr | ||
: std::make_shared<Service<simulation_interfaces::srv::GetAvailableWorlds>>(selectedServiceName, node_); | ||
if (getAvailableWorldsService_) | ||
{ | ||
serviceInterfaces_.insert(getAvailableWorldsService_); | ||
} | ||
break; | ||
case ServiceType::SERVICE_LOAD_WORLD: | ||
serviceInterfaces_.erase(loadWorldService_); | ||
loadWorldService_ = shouldReset | ||
? nullptr | ||
: std::make_shared<Service<simulation_interfaces::srv::LoadWorld>>(selectedServiceName, node_); | ||
if (loadWorldService_) | ||
{ | ||
serviceInterfaces_.insert(loadWorldService_); | ||
} | ||
break; | ||
case ServiceType::SERVICE_UNLOAD_WORLD: | ||
serviceInterfaces_.erase(unloadWorldService_); | ||
unloadWorldService_ = shouldReset | ||
? nullptr | ||
: std::make_shared<Service<simulation_interfaces::srv::UnloadWorld>>(selectedServiceName, node_); | ||
if (unloadWorldService_) | ||
{ | ||
serviceInterfaces_.insert(unloadWorldService_); | ||
} | ||
break; | ||
case ServiceType::ACTION_SIMULATE_STEPS: | ||
simulateStepsAction_ = selectedServiceName; | ||
break; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.