-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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
85 changes: 85 additions & 0 deletions
85
...it_ros/move_group/src/default_capabilities/load_geometry_from_file_service_capability.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Bilal Gill */ | ||
|
||
#include "load_geometry_from_file_service_capability.h" | ||
|
||
#include <moveit/moveit_cpp/moveit_cpp.h> | ||
#include <moveit/move_group/capability_names.h> | ||
#include <moveit/utils/logger.hpp> | ||
|
||
#include <fstream> | ||
|
||
namespace move_group | ||
{ | ||
|
||
namespace | ||
{ | ||
rclcpp::Logger getLogger() | ||
{ | ||
return moveit::getLogger("load_geometry_from_file_service"); | ||
} | ||
} // namespace | ||
|
||
LoadGeometryFromFileService::LoadGeometryFromFileService() : MoveGroupCapability(LOAD_GEOMETRY_FROM_FILE_SERVICE_NAME) | ||
{ | ||
} | ||
|
||
void LoadGeometryFromFileService::initialize() | ||
{ | ||
load_geometry_service_ = context_->moveit_cpp_->getNode()->create_service<moveit_msgs::srv::LoadGeometryFromFile>( | ||
LOAD_GEOMETRY_FROM_FILE_SERVICE_NAME, | ||
[this](const std::shared_ptr<moveit_msgs::srv::LoadGeometryFromFile::Request>& req, | ||
const std::shared_ptr<moveit_msgs::srv::LoadGeometryFromFile::Response>& res) { | ||
std::ifstream file(req->file_path_and_name); | ||
if (!file.is_open()) | ||
{ | ||
RCLCPP_ERROR(getLogger(), "Unable to open file %s for loading CollisionObjects", | ||
req->file_path_and_name.c_str()); | ||
res->success = false; | ||
return; | ||
} | ||
planning_scene_monitor::LockedPlanningSceneRW locked_ps(context_->planning_scene_monitor_); | ||
locked_ps->loadGeometryFromStream(file); | ||
file.close(); | ||
res->success = true; | ||
} // End of callback function | ||
); | ||
} | ||
} // namespace move_group | ||
|
||
#include <pluginlib/class_list_macros.hpp> | ||
|
||
PLUGINLIB_EXPORT_CLASS(move_group::LoadGeometryFromFileService, move_group::MoveGroupCapability) |
62 changes: 62 additions & 0 deletions
62
moveit_ros/move_group/src/default_capabilities/load_geometry_from_file_service_capability.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Bilal Gill */ | ||
|
||
#pragma once | ||
|
||
#include <moveit/move_group/move_group_capability.h> | ||
#include <moveit_msgs/srv/load_geometry_from_file.hpp> | ||
|
||
namespace move_group | ||
{ | ||
/** | ||
* @brief Move group capability to save CollisionObjects in a PlanningScene to a .scene file | ||
* | ||
*/ | ||
class LoadGeometryFromFileService : public MoveGroupCapability | ||
{ | ||
public: | ||
LoadGeometryFromFileService(); | ||
|
||
/** | ||
* @brief Initializes service when plugin is loaded | ||
* | ||
*/ | ||
void initialize() override; | ||
|
||
private: | ||
rclcpp::Service<moveit_msgs::srv::LoadGeometryFromFile>::SharedPtr load_geometry_service_; | ||
}; | ||
} // namespace move_group |
85 changes: 85 additions & 0 deletions
85
moveit_ros/move_group/src/default_capabilities/save_geometry_to_file_service_capability.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Bilal Gill */ | ||
|
||
#include "save_geometry_to_file_service_capability.h" | ||
|
||
#include <moveit/moveit_cpp/moveit_cpp.h> | ||
#include <moveit/move_group/capability_names.h> | ||
#include <moveit/utils/logger.hpp> | ||
|
||
#include <fstream> | ||
|
||
namespace move_group | ||
{ | ||
|
||
namespace | ||
{ | ||
rclcpp::Logger getLogger() | ||
{ | ||
return moveit::getLogger("save_geometry_to_file_service"); | ||
} | ||
} // namespace | ||
|
||
SaveGeometryToFileService::SaveGeometryToFileService() : MoveGroupCapability(SAVE_GEOMETRY_TO_FILE_SERVICE_NAME) | ||
{ | ||
} | ||
|
||
void SaveGeometryToFileService::initialize() | ||
{ | ||
save_geometry_service_ = context_->moveit_cpp_->getNode()->create_service<moveit_msgs::srv::SaveGeometryToFile>( | ||
SAVE_GEOMETRY_TO_FILE_SERVICE_NAME, | ||
[this](const std::shared_ptr<moveit_msgs::srv::SaveGeometryToFile::Request>& req, | ||
const std::shared_ptr<moveit_msgs::srv::SaveGeometryToFile::Response>& res) { | ||
std::ofstream file(req->file_path_and_name); | ||
if (!file.is_open()) | ||
{ | ||
RCLCPP_ERROR(getLogger(), "Unable to open file %s for saving CollisionObjects", | ||
req->file_path_and_name.c_str()); | ||
res->success = false; | ||
return; | ||
} | ||
planning_scene_monitor::LockedPlanningSceneRO locked_ps(context_->planning_scene_monitor_); | ||
locked_ps->saveGeometryToStream(file); | ||
file.close(); | ||
res->success = true; | ||
} // End of callback function | ||
); | ||
} | ||
} // namespace move_group | ||
|
||
#include <pluginlib/class_list_macros.hpp> | ||
|
||
PLUGINLIB_EXPORT_CLASS(move_group::SaveGeometryToFileService, move_group::MoveGroupCapability) |
62 changes: 62 additions & 0 deletions
62
moveit_ros/move_group/src/default_capabilities/save_geometry_to_file_service_capability.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of PickNik Inc. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Bilal Gill */ | ||
|
||
#pragma once | ||
|
||
#include <moveit/move_group/move_group_capability.h> | ||
#include <moveit_msgs/srv/save_geometry_to_file.hpp> | ||
|
||
namespace move_group | ||
{ | ||
/** | ||
* @brief Move group capability to save CollisionObjects in a PlanningScene to a .scene file | ||
* | ||
*/ | ||
class SaveGeometryToFileService : public MoveGroupCapability | ||
{ | ||
public: | ||
SaveGeometryToFileService(); | ||
|
||
/** | ||
* @brief Initializes service when plugin is loaded | ||
* | ||
*/ | ||
void initialize() override; | ||
|
||
private: | ||
rclcpp::Service<moveit_msgs::srv::SaveGeometryToFile>::SharedPtr save_geometry_service_; | ||
}; | ||
} // namespace move_group |
This file contains 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