Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
panda_simulation
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
Container registry
Model registry
Operate
Environments
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
Nikhil Ambardar
panda_simulation
Commits
f8d78182
Commit
f8d78182
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
show boxes in gazebo
parent
6aff781d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+4
-2
4 additions, 2 deletions
CMakeLists.txt
models/box.sdf
+22
-0
22 additions, 0 deletions
models/box.sdf
package.xml
+9
-1
9 additions, 1 deletion
package.xml
src/robot_control_node.cpp
+56
-0
56 additions, 0 deletions
src/robot_control_node.cpp
with
91 additions
and
3 deletions
CMakeLists.txt
+
4
−
2
View file @
f8d78182
...
...
@@ -32,6 +32,8 @@ find_package(Boost REQUIRED COMPONENTS filesystem)
find_package
(
PkgConfig REQUIRED
)
pkg_check_modules
(
JSONCPP jsoncpp
)
pkg_check_modules
(
SDF sdformat REQUIRED
)
message
(
${
JSONCPP_LIBRARIES
}
)
# ################################################################################################################################
...
...
@@ -54,14 +56,14 @@ catkin_package(CATKIN_DEPENDS
# ################################################################################################################################
# Specify additional locations of header files Your package locations should be listed before other locations
include_directories
(
${
catkin_INCLUDE_DIRS
}
)
include_directories
(
${
catkin_INCLUDE_DIRS
}
${
SDF_INCLUDE_DIRS
}
)
add_executable
(
robot_control_node src/robot_control_node.cpp
)
add_executable
(
box_publisher_node src/box_publisher.cpp
)
add_executable
(
robot_state_initializer_node src/robot_state_initializer.cpp
)
add_executable
(
move_group_interface_tutorial src/move_group_interface_tutorial.cpp
)
target_link_libraries
(
robot_control_node
${
catkin_LIBRARIES
}
boost_filesystem
${
JSONCPP_LIBRARIES
}
)
target_link_libraries
(
robot_control_node
${
catkin_LIBRARIES
}
boost_filesystem
${
JSONCPP_LIBRARIES
}
${
SDF_LIBRARIES
}
)
target_link_libraries
(
box_publisher_node
${
catkin_LIBRARIES
}
)
target_link_libraries
(
robot_state_initializer_node
${
catkin_LIBRARIES
}
)
target_link_libraries
(
move_group_interface_tutorial
${
catkin_LIBRARIES
}
${
Boost_LIBRARIES
}
)
...
...
This diff is collapsed.
Click to expand it.
models/box.sdf
0 → 100644
+
22
−
0
View file @
f8d78182
<?xml version="1.0" ?>
<sdf
version=
"1.5"
>
<model
name=
"box"
>
<static>
true
</static>
<link
name=
"link"
>
<visual
name=
"visual"
>
<material>
<script>
<uri>
/usr/share/gazebo-9/media/materials/scripts/gazebo.material
</uri>
<name>
Gazebo/DarkMagentaTransparent
</name>
</script>
</material>
<pose>
2 3 0.5 0 0 0
</pose>
<geometry>
<box>
<size>
1 1 1
</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
package.xml
+
9
−
1
View file @
f8d78182
...
...
@@ -20,7 +20,8 @@
<depend>
controller_manager
</depend>
<depend>
effort_controllers
</depend>
<depend>
gazebo_ros
</depend>
<!-- <depend>gazebo_ros</depend>-->
<depend>
gazebo_plugins
</depend>
<depend>
gazebo_ros_control
</depend>
<depend>
joint_state_controller
</depend>
<depend>
joint_state_publisher
</depend>
...
...
@@ -41,10 +42,17 @@
<depend>
controller_interface
</depend>
<depend>
hardware_interface
</depend>
<build_depend>
sdformat
</build_depend>
<exec_depend>
sdformat
</exec_depend>
<exec_depend>
gazebo_ros
</exec_depend>
<exec_depend>
pluginlib
</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<controller_interface
plugin=
"${prefix}/controller_plugins.xml"
/>
<gazebo_ros
gazebo_media_path=
"/usr/share/gazebo-9/media/materials/scripts"
/>
</export>
</package>
This diff is collapsed.
Click to expand it.
src/robot_control_node.cpp
+
56
−
0
View file @
f8d78182
...
...
@@ -6,9 +6,63 @@
#include
<ros/ros.h>
#include
<boost/filesystem.hpp>
#include
<sdformat-6.0/sdf/sdf.hh>
// for sdf model parsing
#include
<gazebo_msgs/SpawnModel.h>
// for spawning stuff in gazebo
static
const
std
::
string
PLANNING_GROUP_ARM
=
"panda_arm"
;
static
const
std
::
string
APP_DIRECTORY_NAME
=
".panda_simulation"
;
void
spawnCollisionBox
(
shape_msgs
::
SolidPrimitive
shape
,
geometry_msgs
::
Pose
pose
)
{
if
(
shape
.
type
!=
shape
.
BOX
)
{
ROS_ERROR
(
"Safety-zone could not be created due to wrong shape-type"
);
return
;
}
sdf
::
SDFPtr
sdf
(
new
sdf
::
SDF
());
sdf
::
init
(
sdf
);
auto
sdfFileName
=
ros
::
package
::
getPath
(
ROS_PACKAGE_NAME
)
+
"/models/box.sdf"
;
assert
(
sdf
::
readFile
(
sdfFileName
,
sdf
));
ROS_INFO_NAMED
(
"model-loader"
,
"successfully read SDF file: %s"
,
sdf
->
ToString
().
c_str
());
auto
visualElement
=
sdf
->
Root
()
->
GetElement
(
"model"
)
->
GetElement
(
"link"
)
->
GetElement
(
"visual"
);
auto
poseElement
=
visualElement
->
GetElement
(
"pose"
);
auto
sizeElement
=
visualElement
->
GetElement
(
"geometry"
)
->
GetElement
(
"box"
)
->
GetElement
(
"size"
);
std
::
ostringstream
poseStream
;
poseStream
<<
pose
.
position
.
x
<<
" "
<<
pose
.
position
.
y
<<
" "
<<
pose
.
position
.
z
<<
" 0 0 0"
;
poseElement
->
Set
(
poseStream
.
str
());
ROS_INFO_NAMED
(
"model-loader"
,
"successfully changed SDF file, pose is: %s"
,
poseElement
->
GetValue
()
->
GetAsString
().
c_str
());
std
::
ostringstream
sizeStream
;
sizeStream
<<
shape
.
dimensions
[
0
]
<<
" "
<<
shape
.
dimensions
[
1
]
<<
" "
<<
shape
.
dimensions
[
2
];
sizeElement
->
Set
(
sizeStream
.
str
());
ROS_INFO_NAMED
(
"model-loader"
,
"successfully changed SDF file, size is: '%s', should be '%s'"
,
sizeElement
->
GetValue
()
->
GetAsString
().
c_str
(),
sizeStream
.
str
().
c_str
());
ros
::
NodeHandle
n
;
ros
::
ServiceClient
client
=
n
.
serviceClient
<
gazebo_msgs
::
SpawnModel
>
(
"/gazebo/spawn_sdf_model"
);
gazebo_msgs
::
SpawnModel
spawnModelService
;
spawnModelService
.
request
.
robot_namespace
=
"box space"
;
// spawnModelService.request.initial_pose = pose; // not required here
spawnModelService
.
request
.
model_name
=
sdf
->
Root
()
->
GetElement
(
"model"
)
->
GetAttribute
(
"name"
)
->
GetAsString
();
spawnModelService
.
request
.
model_xml
=
sdf
->
ToString
().
c_str
();
// spawnModelService.request.reference_frame = ; // if left empty, world is used
if
(
client
.
call
(
spawnModelService
))
{
ROS_INFO
(
"result: %s"
,
spawnModelService
.
response
.
success
?
"success!"
:
"failed!"
);
ROS_INFO
(
"result: %s"
,
spawnModelService
.
response
.
status_message
.
c_str
());
}
else
{
ROS_ERROR
(
"Failed to call service '/gazebo/spawn_sdf_model'"
);
}
}
moveit_msgs
::
CollisionObject
extractObstacleFromJson
(
Json
::
Value
&
root
,
std
::
string
name
)
{
moveit_msgs
::
CollisionObject
collision_object
;
...
...
@@ -47,6 +101,8 @@ moveit_msgs::CollisionObject extractObstacleFromJson(Json::Value &root, std::str
collision_object
.
primitive_poses
.
push_back
(
box_pose
);
collision_object
.
operation
=
collision_object
.
ADD
;
spawnCollisionBox
(
primitive
,
box_pose
);
return
std
::
move
(
collision_object
);
}
...
...
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