Skip to content

Commit bf68bca

Browse files
committed
FIX: initializers
1 parent 45f3af2 commit bf68bca

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

robotiq_hande_driver/CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,19 @@ endif()
77

88
find_package(ament_cmake REQUIRED)
99

10-
# add_library(
11-
# libmodbus
12-
# )
13-
1410
include_directories(
1511
"include"
1612
"src"
1713
)
1814

19-
add_executable(communication src/communication.cpp)
20-
add_executable(protocol_logic src/protocol_logic.cpp)
21-
add_executable(application src/application.cpp)
22-
add_executable(hande_driver src/hande_driver.cpp)
15+
add_executable(hande_driver src/hande_driver.cpp src/application.cpp src/protocol_logic.cpp src/communication.cpp)
16+
target_link_libraries(hande_driver ${catkin_LIBRARIES})
17+
target_link_libraries(hande_driver /lib/x86_64-linux-gnu/libmodbus.so)
2318

2419
target_include_directories(hande_driver PUBLIC
2520
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2621
$<INSTALL_INTERFACE:include>)
27-
target_compile_features(hande_driver PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
22+
target_compile_features(hande_driver PUBLIC c_std_99 cxx_std_20) # Require C99 and C++17
2823

2924
install(TARGETS hande_driver
3025
DESTINATION lib/${PROJECT_NAME})

robotiq_hande_driver/src/application.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
#include <cstdio>
12
#include "application.hpp"
23

34

45
namespace hande_driver
56
{
67

7-
ApplicationLayer::ApplicationLayer(){
8-
protocol_logic_ = ProtocolLogic();
8+
ApplicationLayer::ApplicationLayer()
9+
: requested_position_(0)
10+
, position_(0)
11+
, current_(0)
12+
{
13+
printf("ApplicationLayer constructor\n");
914
}
1015

11-
ApplicationLayer::~ApplicationLayer(){}
16+
ApplicationLayer::~ApplicationLayer(){
17+
printf("ApplicationLayer destructor\n");
18+
}
1219

1320
void ApplicationLayer::stop(){
1421
protocol_logic_.stop();

robotiq_hande_driver/src/communication.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <cstdio>
12
#include <stdint.h>
23

34
#include "communication.hpp"
@@ -17,14 +18,19 @@ constexpr uint8_t slaveID = 0x09;
1718
constexpr uint16_t gripperOutputFirstReg = 0x07D0;
1819
constexpr uint16_t gripperInputFirstReg = 0x03E8;
1920

20-
Communication::Communication(){
21+
Communication::Communication()
22+
: input_registers(0, 0, 0)
23+
, output_registers(0, 0, 0)
24+
{
25+
printf("Communication constructor\n");
2126
mb = modbus_new_rtu(deviceName, baudrate, parity, dataBits, stopBit);
2227
modbus_set_slave(mb, slaveID);
2328
modbus_set_debug(mb, debugModbus);
2429
connect();
2530
}
2631

2732
Communication::~Communication(){
33+
printf("Communication destructor\n");
2834
disconnect();
2935
modbus_free(mb);
3036
}

robotiq_hande_driver/src/hande_driver.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@
22
#include <unistd.h>
33
#include "application.hpp"
44

5+
56
int main(int argc, char ** argv)
67
{
78
(void) argc;
89
(void) argv;
910

10-
printf("hello world robotiq_hande_driver package\n");
11+
printf("hello world robotiq_hande_driver package4\n");
12+
hande_driver::ApplicationLayer app_test;
1113

12-
hande_driver::ApplicationLayer app_test = hande_driver::ApplicationLayer();
14+
printf("Activation robotiq_hande_driver\n");
1315
app_test.activate();
1416
sleep(2);
1517

18+
printf("Open-Close loop x2\n");
19+
20+
printf("Open\n");
1621
app_test.open();
1722
sleep(2);
23+
printf("Close\n");
1824
app_test.close();
1925
sleep(2);
26+
27+
printf("Open\n");
2028
app_test.open();
2129
sleep(2);
30+
printf("Close\n");
2231
app_test.close();
2332

33+
printf("Finished\n");
34+
2435
return 0;
2536
}

robotiq_hande_driver/src/protocol_logic.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
#include <cstdio>
12
#include "protocol_logic.hpp"
23

34

45
namespace hande_driver
56
{
67

7-
ProtocolLogic::ProtocolLogic(){
8-
communication_ = Communication();
8+
ProtocolLogic::ProtocolLogic()
9+
: status_(0)
10+
, activation_status_(GRIPPER_RESET)
11+
, action_status_(STOPPED)
12+
, gripper_status_(NOT_USED)
13+
, object_detection_status_(REQ_POS_NO_OBJECT)
14+
, fault_status(0)
15+
, position_request_echo(0)
16+
, position(0)
17+
, current(0)
18+
{
19+
printf("ProtocolLogic constructor\n");
920
}
1021

1122
ProtocolLogic::~ProtocolLogic(){
12-
communication_.~Communication();
23+
printf("ProtocolLogic destructor\n");
1324
}
1425

1526
void ProtocolLogic::reset(){

0 commit comments

Comments
 (0)