Skip to content

Commit 7278cee

Browse files
Merge pull request #8 from CollaborativeRoboticsLab/remove-container
Remove container
2 parents 330a7e5 + 28fac04 commit 7278cee

File tree

21 files changed

+431
-419
lines changed

21 files changed

+431
-419
lines changed

capabilities2_fabric/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ find_package(ament_cmake REQUIRED)
1515
find_package(rclcpp REQUIRED)
1616
find_package(rclcpp_action REQUIRED)
1717
find_package(capabilities2_msgs REQUIRED)
18+
find_package(bondcpp REQUIRED)
19+
find_package(backward_ros REQUIRED)
1820

1921
# Locate the static version of tinyxml2
2022
find_library(TINYXML2_LIB NAMES tinyxml2 PATHS /usr/local/lib NO_DEFAULT_PATH)
@@ -38,6 +40,7 @@ target_link_libraries(${PROJECT_NAME}
3840
ament_target_dependencies(${PROJECT_NAME}
3941
rclcpp
4042
rclcpp_action
43+
bondcpp
4144
capabilities2_msgs
4245
)
4346

capabilities2_fabric/docs/waypoint_runner_ex1.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,7 @@
22

33
### Dependencies
44

5-
This example uses nav2 stack and turtlebot3.
6-
7-
Run the following commands to install nav2 stack
8-
9-
```bash
10-
sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup
11-
```
12-
13-
Run the following commands to install turtlebot3
14-
15-
```bash
16-
sudo apt install ros-humble-turtlebot3*
17-
```
18-
19-
Clone the nav_stack default configuration and launch files to the same workspace if its not already availabe in the workspace. Capabilities2 Nav2 Runners are dependent on this package.
20-
21-
```bash
22-
cd src
23-
git clone https://github.com/CollaborativeRoboticsLab/nav_stack.git
24-
```
5+
This example uses nav2 stack and turtlebot3. Follow instructions from [Nav2 Dependency Installation](../../docs/nav2_setup.md) to setup nav stack.
256

267
### Plan selection
278

capabilities2_fabric/docs/waypoint_runner_ex2.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,7 @@
22

33
### Dependencies
44

5-
This example uses nav2 stack and turtlebot3.
6-
7-
Run the following commands to install nav2 stack
8-
9-
```bash
10-
sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup
11-
```
12-
13-
Run the following commands to install turtlebot3
14-
15-
```bash
16-
sudo apt install ros-humble-turtlebot3*
17-
```
18-
19-
Clone the nav_stack default configuration and launch files to the same workspace if its not already availabe in the workspace. Capabilities2 Nav2 Runners are dependent on this package.
20-
21-
```bash
22-
cd src
23-
git clone https://github.com/CollaborativeRoboticsLab/nav_stack.git
24-
```
5+
This example uses nav2 stack and turtlebot3. Follow instructions from [Nav2 Dependency Installation](../../docs/nav2_setup.md) to setup nav stack.
256

267
### Plan selection
278

capabilities2_fabric/include/capabilities2_executor/capabilities_fabric.hpp renamed to capabilities2_fabric/include/capabilities2_fabric/capabilities_fabric.hpp

Lines changed: 213 additions & 345 deletions
Large diffs are not rendered by default.

capabilities2_fabric/include/capabilities2_executor/capabilities_file_parser.hpp renamed to capabilities2_fabric/include/capabilities2_fabric/capabilities_file_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <rclcpp/rclcpp.hpp>
1111
#include <rclcpp_action/rclcpp_action.hpp>
1212

13-
#include <capabilities2_executor/capabilities_xml_parser.hpp>
13+
#include <capabilities2_fabric/capabilities_xml_parser.hpp>
1414
#include <capabilities2_msgs/action/plan.hpp>
1515

1616
/**

capabilities2_fabric/include/capabilities2_executor/capabilities_xml_parser.hpp renamed to capabilities2_fabric/include/capabilities2_fabric/capabilities_xml_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <string>
33
#include <vector>
44
#include <rclcpp/rclcpp.hpp>
5-
#include <capabilities2_executor/structs/connection.hpp>
5+
#include <capabilities2_fabric/utils/connection.hpp>
66

77
namespace capabilities2_xml_parser
88
{
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <bondcpp/bond.hpp>
2+
#include <rclcpp/rclcpp.hpp>
3+
4+
class BondClient
5+
{
6+
public:
7+
BondClient(rclcpp::Node::SharedPtr node, const std::string& bond_id, const std::string& bonds_topic = "/capabilities/bond")
8+
{
9+
bonds_topic_ = bonds_topic;
10+
bond_id_ = bond_id;
11+
node_ = node;
12+
}
13+
14+
void start()
15+
{
16+
RCLCPP_INFO(node_->get_logger(), "[BondClient] creating bond to capabilities server");
17+
18+
bond_ =
19+
std::make_unique<bond::Bond>(bonds_topic_, bond_id_, node_, std::bind(&BondClient::on_broken, this), std::bind(&BondClient::on_formed, this));
20+
21+
bond_->setHeartbeatPeriod(0.10);
22+
bond_->setHeartbeatTimeout(10.0);
23+
bond_->start();
24+
}
25+
26+
void stop()
27+
{
28+
RCLCPP_INFO(node_->get_logger(), "[BondClient] destroying bond to capabilities server");
29+
30+
if (bond_)
31+
{
32+
bond_.reset();
33+
}
34+
}
35+
36+
~BondClient()
37+
{
38+
stop();
39+
}
40+
41+
private:
42+
void on_formed()
43+
{
44+
// log bond established event
45+
RCLCPP_INFO(node_->get_logger(), "[BondClient] bond with capabilities server formed with id: %s", bond_id_.c_str());
46+
}
47+
48+
void on_broken()
49+
{
50+
// log bond established event
51+
RCLCPP_INFO(node_->get_logger(), "[BondClient] bond with capabilities server broken with id: %s", bond_id_.c_str());
52+
}
53+
54+
/** Ros node pointer */
55+
rclcpp::Node::SharedPtr node_;
56+
57+
/** Bond id string */
58+
std::string bond_id_;
59+
60+
/** Bond topic to be published */
61+
std::string bonds_topic_;
62+
63+
/** Heart beat bond with capabilities server */
64+
std::shared_ptr<bond::Bond> bond_;
65+
};

capabilities2_fabric/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<depend>rclcpp</depend>
1414
<depend>capabilities2_msgs</depend>
1515
<depend>rclcpp_action</depend>
16+
<depend>backward_ros</depend>
1617

1718
<!-- system dependency -->
1819
<depend>tinyxml2</depend>

capabilities2_fabric/src/capabilities_fabric.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <capabilities2_executor/capabilities_fabric.hpp>
1+
#include <capabilities2_fabric/capabilities_fabric.hpp>
22

3-
int main(int argc, char* argv[])
3+
int main(int argc, char** argv)
44
{
55
rclcpp::init(argc, argv);
66

@@ -9,6 +9,7 @@ int main(int argc, char* argv[])
99

1010
// Initialize the node components after construction
1111
node->initialize();
12+
1213
rclcpp::spin(node);
1314

1415
rclcpp::shutdown();

0 commit comments

Comments
 (0)