-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/humble isaac improvements (#532)
* progress on several smacc client behaviors related with ros, wait action, ros launch , sleep, wait topic, etc * minor * missing * Añadidos archivos nuevos y cambios pequeños de archivos preexistentes de smacc2 (loggers y poco más) * Cierre de procesos lanzados por CbRoslaunch2 de forma recursiva funcionando * Borrado de funcion residual no utilizada en client_bases/smacc_ros_launch_client_2.cpp * Limpiado del fichero client_bases/smacc_ros_launch_client_2.cpp * format * Cambios hechos para mejorar codigo. Dejar result_ de CbRoslaunch en auto para que se quede como bloqueo de on Entry y lance forceFinish de onEntry, si se pone como this-> sale de onEntry y bloquea. Añadidos archivos en desarrollo cb_ros_stop_2 con ideas iniciales de funcionamiento * Fixed and improvements cblaunch2 and cbstop2 --------- Co-authored-by: atobaruela-ibrobotics <atobaruela@ibrobotics.com>
- Loading branch information
1 parent
cc59040
commit c1fa655
Showing
27 changed files
with
939 additions
and
40 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
80 changes: 80 additions & 0 deletions
80
smacc2/include/smacc2/client_bases/smacc_ros_launch_client_2.hpp
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,80 @@ | ||
// Copyright 2021 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Pablo Inigo Blasco, Brett Aldrich | ||
* | ||
******************************************************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <smacc2/smacc_client.hpp> | ||
#include <smacc2/smacc_state_machine.hpp> | ||
|
||
#include <rclcpp_action/client.hpp> | ||
#include <thread> | ||
|
||
namespace smacc2 | ||
{ | ||
namespace client_bases | ||
{ | ||
struct ProcessInfo | ||
{ | ||
pid_t pid; // PID del proceso hijo | ||
FILE * pipe; // Pipe para la salida del proceso hijo | ||
}; | ||
|
||
ProcessInfo runProcess(const char * command); | ||
void killGrandchildren(pid_t originalPid); | ||
void killProcessesRecursive(pid_t pid); | ||
|
||
class ClRosLaunch2 : public ISmaccClient | ||
{ | ||
public: | ||
ClRosLaunch2(); | ||
|
||
ClRosLaunch2(std::string packageName, std::string launchFilename); | ||
|
||
virtual ~ClRosLaunch2(); | ||
|
||
void launch(); | ||
|
||
void stop(); | ||
|
||
static std::future<std::string> executeRosLaunch( | ||
std::string packageName, std::string launchFilename, std::function<bool()> cancelCondition, | ||
ClRosLaunch2 * client = nullptr); | ||
|
||
// static std::string executeRosLaunch( | ||
// std::string packageName, std::string launchFilename, std::function<bool()> cancelCondition); | ||
|
||
std::string packageName_; | ||
|
||
std::string launchFileName_; | ||
|
||
pid_t launchPid_; | ||
|
||
protected: | ||
// std::future<std::string> result_; | ||
std::future<std::string> result_; | ||
|
||
typedef std::function<void> cancelCallback; | ||
|
||
static std::map<std::future<void>, cancelCallback> detached_futures_; | ||
|
||
std::atomic<bool> cancellationToken_ = ATOMIC_VAR_INIT(false); | ||
}; | ||
} // namespace client_bases | ||
} // namespace smacc2 |
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
70 changes: 70 additions & 0 deletions
70
smacc2/include/smacc2/client_behaviors/cb_ros_launch_2.hpp
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,70 @@ | ||
// Copyright 2021 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Pablo Inigo Blasco, Brett Aldrich | ||
* | ||
******************************************************************************************************************/ | ||
#pragma once | ||
|
||
#include <smacc2/client_bases/smacc_ros_launch_client_2.hpp> | ||
#include <smacc2/smacc_asynchronous_client_behavior.hpp> | ||
|
||
namespace smacc2 | ||
{ | ||
namespace client_behaviors | ||
{ | ||
enum class RosLaunchMode | ||
{ | ||
LAUNCH_DETTACHED, | ||
LAUNCH_CLIENT_BEHAVIOR_LIFETIME | ||
}; | ||
|
||
class CbRosLaunch2 : public smacc2::SmaccAsyncClientBehavior | ||
{ | ||
private: | ||
static std::vector<std::future<std::string>> detached_futures_; | ||
|
||
public: | ||
CbRosLaunch2(); | ||
|
||
CbRosLaunch2(std::string package, std::string launchfile, RosLaunchMode); | ||
|
||
// CbRosLaunch2(std::string packageName, std::string launchFileName); | ||
|
||
virtual ~CbRosLaunch2(); | ||
|
||
template <typename TOrthogonal, typename TSourceObject> | ||
void onOrthogonalAllocation() | ||
{ | ||
smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>(); | ||
} | ||
|
||
void onEntry() override; | ||
|
||
std::optional<std::string> packageName_; | ||
std::optional<std::string> launchFileName_; | ||
|
||
RosLaunchMode launchMode_; | ||
|
||
protected: | ||
std::future<std::string> result_; | ||
|
||
smacc2::client_bases::ClRosLaunch2 * client_; | ||
|
||
std::future<std::string> future_; | ||
}; | ||
} // namespace client_behaviors | ||
} // namespace smacc2 |
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 @@ | ||
// Copyright 2021 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Pablo Inigo Blasco, Brett Aldrich | ||
* | ||
******************************************************************************************************************/ | ||
#pragma once | ||
|
||
#include <smacc2/client_bases/smacc_ros_launch_client_2.hpp> | ||
#include <smacc2/smacc_asynchronous_client_behavior.hpp> | ||
|
||
namespace smacc2 | ||
{ | ||
namespace client_behaviors | ||
{ | ||
class CbRosStop2 : public smacc2::SmaccAsyncClientBehavior | ||
{ | ||
private: | ||
static std::vector<std::future<std::string>> detached_futures_; | ||
|
||
public: | ||
CbRosStop2(); | ||
|
||
CbRosStop2(pid_t launchPid); | ||
|
||
// CbRosStop2(std::string packageName, std::string launchFileName); | ||
|
||
virtual ~CbRosStop2(); | ||
|
||
template <typename TOrthogonal, typename TSourceObject> | ||
void onOrthogonalAllocation() | ||
{ | ||
smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>(); | ||
} | ||
|
||
void onEntry() override; | ||
|
||
std::optional<std::string> packageName_; | ||
std::optional<std::string> launchFileName_; | ||
|
||
protected: | ||
std::future<std::string> result_; | ||
|
||
smacc2::client_bases::ClRosLaunch2 * client_; | ||
|
||
std::future<std::string> future_; | ||
}; | ||
} // namespace client_behaviors | ||
} // namespace smacc2 |
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
Oops, something went wrong.