Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gz_gep_tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Stasse
gz_gep_tools
Commits
2a050890
Commit
2a050890
authored
1 month ago
by
Olivier Stasse
Browse files
Options
Downloads
Patches
Plain Diff
Add object control over gz
parent
3113faab
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/gz_gep_tools/control_over_gz.hh
+44
-0
44 additions, 0 deletions
include/gz_gep_tools/control_over_gz.hh
src/control_over_gz.cc
+51
-0
51 additions, 0 deletions
src/control_over_gz.cc
with
95 additions
and
0 deletions
include/gz_gep_tools/control_over_gz.hh
0 → 100644
+
44
−
0
View file @
2a050890
/// Standard includes
#include
<vector>
#include
<string>
/// GZ includes
#include
<gz/msgs.hh>
#include
<gz/transport.hh>
namespace
gz_transport_hw_tools
{
class
ControlOverGz
{
public:
/// Provides the gazebo name.
ControlOverGz
(
std
::
string
&
world_prefix
);
/// Pause Gazebosim
bool
Pause
();
/// Start Gazebo
bool
Start
();
/// Reset Gazebosim
bool
Reset
();
protected:
/// Send a Pause request
bool
SendPauseRequest
(
bool
abool
);
/// World prefix
std
::
string
world_prefix_
;
/// list of services
std
::
string
control_gzsim_
;
/// GZ node
gz
::
transport
::
Node
node_
;
};
}
This diff is collapsed.
Click to expand it.
src/control_over_gz.cc
0 → 100644
+
51
−
0
View file @
2a050890
#include
<gz_gep_tools/control_over_gz.hh>
#include
<gz/msgs.hh>
#include
<gz/transport.hh>
namespace
gz_transport_hw_tools
{
ControlOverGz
::
ControlOverGz
(
std
::
string
&
world_prefix
)
:
world_prefix_
(
world_prefix
)
{
control_gzsim_
=
world_prefix
+
std
::
string
(
"/control"
);
}
bool
ControlOverGz
::
Reset
()
{
gz
::
msgs
::
WorldControl
req_world_ctrl
;
gz
::
msgs
::
WorldReset
req_world_reset
;
gz
::
msgs
::
Boolean
rep_bool
;
unsigned
int
timeout
=
5000
;
/// Set reset for everything
req_world_reset
.
set_all
(
true
);
/// Set the world reset inside the world control reset.
req_world_ctrl
.
set_allocated_reset
(
&
req_world_reset
);
/// Do request.
bool
result
;
node_
.
Request
(
control_gzsim_
,
req_world_ctrl
,
timeout
,
rep_bool
,
result
);
return
result
;
}
bool
ControlOverGz
::
SendPauseRequest
(
bool
abool
)
{
gz
::
msgs
::
WorldControl
req_world_ctrl
;
gz
::
msgs
::
Boolean
rep_bool
;
unsigned
int
timeout
=
5000
;
/// Set the world reset inside the world control reset.
req_world_ctrl
.
set_pause
(
abool
);
/// Do request.
bool
result
;
node_
.
Request
(
control_gzsim_
,
req_world_ctrl
,
timeout
,
rep_bool
,
result
);
return
result
;
}
bool
ControlOverGz
::
Pause
()
{
return
SendPauseRequest
(
true
);
}
bool
ControlOverGz
::
Start
()
{
return
SendPauseRequest
(
false
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment