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
7c9eecd8
Commit
7c9eecd8
authored
2 weeks ago
by
Olivier Stasse
Browse files
Options
Downloads
Patches
Plain Diff
[control_over] Add Method SetPose (current status: not working)
parent
580b5549
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
+12
-2
12 additions, 2 deletions
include/gz_gep_tools/control_over_gz.hh
src/control_over_gz.cc
+37
-1
37 additions, 1 deletion
src/control_over_gz.cc
with
49 additions
and
3 deletions
include/gz_gep_tools/control_over_gz.hh
+
12
−
2
View file @
7c9eecd8
...
...
@@ -6,6 +6,9 @@
/// GZ includes
#include
<gz/msgs.hh>
#include
<gz/msgs/clock.pb.h>
#include
<gz/msgs/world_control.pb.h>
#include
<gz/msgs/world_control_state.pb.h>
#include
<gz/transport.hh>
#include
"joint_state_interface.hh"
...
...
@@ -36,6 +39,10 @@ class ControlOverGz {
/// Send World Control state to Init ECM.
bool
SendWorldControlStateToInitECM
(
const
RobotCtrlJointInfos
&
rbt_ctrl_joint_infos
);
/// Set Pose
bool
SetPose
(
double
x
,
double
y
,
double
z
,
double
qx
,
double
qy
,
double
qz
,
double
qw
);
/// Initialization of the ECM by reading the world control state
bool
ReadWorldStateToInitECM
();
...
...
@@ -44,7 +51,7 @@ class ControlOverGz {
/// Display link values
void
DisplayLinkValues
();
protected:
...
...
@@ -63,9 +70,12 @@ class ControlOverGz {
/// Name of state service
std
::
string
state_service_gzsim_
;
/// Name of w
r
old control state service.
/// Name of wo
r
ld control state service.
std
::
string
wrld_ctrl_state_srv_gzsim_
;
/// Name of set pose service.
std
::
string
set_pose_service_gzsim_
;
/// GZ node
gz
::
transport
::
Node
node_
;
...
...
This diff is collapsed.
Click to expand it.
src/control_over_gz.cc
+
37
−
1
View file @
7c9eecd8
...
...
@@ -25,6 +25,9 @@ ControlOverGz::ControlOverGz(std::string &world_prefix, bool debug_level)
/// State gzsim service
state_service_gzsim_
=
world_prefix
+
std
::
string
(
"/state"
);
/// Set pose service
set_pose_service_gzsim_
=
world_prefix
+
std
::
string
(
"/set_pose"
);
std
::
string
gazebo_clock_topic_name
;
gazebo_clock_topic_name
=
world_prefix
+
std
::
string
(
"/clock"
);
node_
.
Subscribe
<
ControlOverGz
,
gz
::
msgs
::
Clock
>
(
gazebo_clock_topic_name
,
...
...
@@ -152,7 +155,7 @@ bool ControlOverGz::ReadWorldStateToInitECM()
void
ControlOverGz
::
DisplayLinkValues
()
{
auto
entities
=
Robot_ECM_
.
EntitiesByComponents
(
gz
::
sim
::
components
::
Link
());
for
(
auto
it_entity
=
entities
.
begin
();
it_entity
!=
entities
.
end
();
it_entity
++
)
...
...
@@ -220,6 +223,7 @@ bool ControlOverGz::SendWorldControlStateToInitECM(const RobotCtrlJointInfos &rb
}
}
/// Create the serialized state.
req_serialized_state
=
new
gz
::
msgs
::
SerializedState
();
/// Generate the serialized state msg from the ECM.
...
...
@@ -244,4 +248,36 @@ bool ControlOverGz::SendWorldControlStateToInitECM(const RobotCtrlJointInfos &rb
return
true
;
}
bool
ControlOverGz
::
SetPose
(
double
x
,
double
y
,
double
z
,
double
qx
,
double
qy
,
double
qz
,
double
qw
)
{
gz
::
msgs
::
Pose
pose_msg
;
gz
::
msgs
::
Boolean
rep_bool
;
unsigned
int
timeout
=
3000
;
bool
result
;
gz
::
msgs
::
Vector3d
*
aPosition
=
pose_msg
.
mutable_position
();
aPosition
->
set_x
(
x
);
aPosition
->
set_y
(
y
);
aPosition
->
set_z
(
z
);
gz
::
msgs
::
Quaternion
*
aQuaternion
=
pose_msg
.
mutable_orientation
();
aQuaternion
->
set_x
(
qx
);
aQuaternion
->
set_y
(
qy
);
aQuaternion
->
set_z
(
qz
);
aQuaternion
->
set_w
(
qw
);
/// Set Robot Pose
/// by calling the /prefix_world/set_pose Gazebo service.
if
(
!
node_
.
Request
(
set_pose_service_gzsim_
,
pose_msg
,
timeout
,
rep_bool
,
result
))
{
std
::
cerr
<<
"Unable to send reset request ! timeout "
<<
wrld_ctrl_state_srv_gzsim_
<<
" "
<<
result
<<
std
::
endl
;
result
=
false
;
}
return
true
;
}
}
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