Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit 68ba853

Browse files
authored
Merge pull request #241 from project-march/release/v0.3.0
Release v0.3.0
2 parents 5c9f182 + 0859a30 commit 68ba853

File tree

121 files changed

+2795
-2272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+2795
-2272
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/*
22
*/cmake-build-debug/**
3+
.vscode/settings.json

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ git:
2525
env:
2626
global:
2727
- ROS_REPO=ros
28+
- ADDITIONAL_DEBS=curl
2829
- CCACHE_DIR=$HOME/.ccache # enables C/C++ caching in industrial_ci
2930
- BUILDER=colcon
3031
- CATKIN_LINT=pedantic
3132
- CATKIN_LINT_ARGS='--ignore literal_project_name --ignore target_name_collision'
33+
- CI_ENV=`bash <(curl -s https://codecov.io/env)`
34+
- DOCKER_RUN_OPTS='$CI_ENV'
35+
- TARGET_CMAKE_ARGS='-DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE_TESTING=ON'
3236
- UPSTREAM_WORKSPACE='.rosinstall -march/march_data_collector -march/march_gait_scheduler -march/march_gain_scheduling -march/march_gait_selection -march/march_launch -march/march_safety -march/march_state_machine'
37+
- AFTER_RUN_TARGET_TEST='cd "$target_ws" && bash <(curl -s https://codecov.io/bash) -R src/hardware-interface -F test && bash <(curl -s https://codecov.io/bash) -R src/hardware-interface -F production'
3338

3439
jobs:
3540
include:

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
The hardware interface of the MARCH exoskeleton. This includes EtherCAT master and uses the SOEM library.
33

44
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/project-march/hardware-interface?include_prereleases)
5+
[![codecov](https://codecov.io/gh/project-march/hardware-interface/branch/develop/graph/badge.svg?flag=production)](https://codecov.io/gh/project-march/hardware-interface)
6+
57

68
| Branch | Build Status |
79
| ------ |:------------:|

codecov.yaml

-7
This file was deleted.

codecov.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
coverage:
2+
status:
3+
project:
4+
default: off
5+
production:
6+
target: auto
7+
flags:
8+
- production
9+
fixes:
10+
- "src/hardware-interface/::"
11+
flags:
12+
production:
13+
paths:
14+
- "*/src/**/*"
15+
- "*/src/*"
16+
- "*/include/march_*/*"
17+
- "*/include/march_*/**/*"
18+
test:
19+
paths:
20+
- "*/test/**/*"
21+
- "*/test/*"

march_hardware/CMakeLists.txt

+63-31
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
cmake_minimum_required(VERSION 2.8.3)
22
project(march_hardware)
33

4-
add_compile_options(-std=c++11 -Wall -Wextra)
4+
add_compile_options(-std=c++14 -Wall -Wextra -Werror)
55

66
find_package(catkin REQUIRED COMPONENTS
77
roscpp
88
soem
9+
urdf
910
)
1011

1112
catkin_package(
1213
INCLUDE_DIRS include
1314
CATKIN_DEPENDS
1415
LIBRARIES ${PROJECT_NAME}
16+
CFG_EXTRAS
17+
${PROJECT_NAME}-extras.cmake
1518
)
1619

20+
include(cmake/${PROJECT_NAME}-extras.cmake)
21+
1722
include_directories(
1823
include
1924
SYSTEM
2025
${catkin_INCLUDE_DIRS}
2126
${soem_INCLUDE_DIRS}/soem
2227
)
2328

24-
install(DIRECTORY include/${PROJECT_NAME}/
25-
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
26-
)
29+
# needed to circumvent LD_LIBRARY_PATH being emptied through ethercat_grant
30+
# in addition to not propagating march_hardware_interface RUNPATH to dependencies, in contrast to RPATH
31+
set(GCC_NEWDTAGS_LINK_FLAGS "-Wl,--disable-new-dtags")
32+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_NEWDTAGS_LINK_FLAGS}")
33+
34+
if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)
35+
find_package(code_coverage REQUIRED)
36+
# Add compiler flags for coverage instrumentation before defining any targets
37+
append_coverage_compiler_flags()
38+
endif()
2739

2840
add_library(${PROJECT_NAME}
29-
src/Encoder.cpp
41+
include/${PROJECT_NAME}/encoder/AbsoluteEncoder.h
42+
include/${PROJECT_NAME}/encoder/Encoder.h
43+
include/${PROJECT_NAME}/encoder/IncrementalEncoder.h
44+
include/${PROJECT_NAME}/error/error_type.h
45+
include/${PROJECT_NAME}/error/hardware_exception.h
46+
include/${PROJECT_NAME}/error/motion_error.h
3047
src/EtherCAT/EthercatIO.cpp
3148
src/EtherCAT/EthercatMaster.cpp
3249
src/EtherCAT/EthercatSDO.cpp
@@ -39,12 +56,26 @@ add_library(${PROJECT_NAME}
3956
src/PDOmap.cpp
4057
src/PowerDistributionBoard.cpp
4158
src/TemperatureGES.cpp
59+
src/encoder/AbsoluteEncoder.cpp
60+
src/encoder/Encoder.cpp
61+
src/encoder/IncrementalEncoder.cpp
62+
src/error/error_type.cpp
63+
src/error/motion_error.cpp
4264
)
4365

4466
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
4567

46-
add_executable(slave_count_check check/SlaveCount.cpp)
68+
add_executable(slave_count_check check/slave_count.cpp)
4769
target_link_libraries(slave_count_check ${PROJECT_NAME})
70+
ros_enable_rpath(slave_count_check)
71+
72+
install(DIRECTORY include/${PROJECT_NAME}/
73+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
74+
)
75+
76+
install(DIRECTORY include/${PROJECT_NAME}/
77+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
78+
)
4879

4980
install(TARGETS ${PROJECT_NAME}
5081
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
@@ -55,43 +86,44 @@ install(TARGETS slave_count_check
5586
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
5687
)
5788

58-
## Add gtest based cpp test target and link libraries
59-
if (CATKIN_ENABLE_TESTING)
60-
find_package(code_coverage REQUIRED)
61-
find_package(rostest REQUIRED)
62-
63-
if(ENABLE_COVERAGE_TESTING)
64-
include(CodeCoverage)
65-
append_coverage_compiler_flags()
66-
endif()
89+
install(DIRECTORY launch
90+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
91+
)
6792

68-
add_rostest_gmock(${PROJECT_NAME}-test
69-
test/march_hardware.test
70-
test/TestRunner.cpp
71-
test/TestEncoder.cpp
93+
## Add gtest based cpp test target and link libraries
94+
if(CATKIN_ENABLE_TESTING)
95+
catkin_add_gmock(${PROJECT_NAME}_test
96+
test/TestBootShutdownOffsets.cpp
97+
test/TestHighVoltage.cpp
7298
test/TestIMotionCube.cpp
73-
test/TestTemperatureGES.cpp
7499
test/TestJoint.cpp
75-
test/TestPDOmap.cpp
76-
test/TestBootShutdownOffsets.cpp
100+
test/TestLowVoltage.cpp
77101
test/TestNetDriverOffsets.cpp
78102
test/TestNetMonitorOffsets.cpp
79-
test/TestLowVoltage.cpp
80-
test/TestHighVoltage.cpp
103+
test/TestPDOmap.cpp
81104
test/TestPowerDistributionBoard.cpp
82-
test/mocks/MockTemperatureGES.cpp
83-
test/mocks/MockTemperatureSensor.cpp
105+
test/TestRunner.cpp
106+
test/TestTemperatureGES.cpp
107+
test/encoder/TestAbsoluteEncoder.cpp
108+
test/encoder/TestIncrementalEncoder.cpp
109+
test/encoder/TestEncoder.cpp
110+
test/error/test_hardware_exception.cpp
111+
test/error/test_motion_error.cpp
112+
test/mocks/MockAbsoluteEncoder.cpp
84113
test/mocks/MockEncoder.cpp
85114
test/mocks/MockIMotionCube.cpp
115+
test/mocks/MockIncrementalEncoder.cpp
86116
test/mocks/MockJoint.cpp
117+
test/mocks/MockTemperatureGES.cpp
118+
test/mocks/MockTemperatureSensor.cpp
87119
)
88-
target_link_libraries(${PROJECT_NAME}-test ${catkin_LIBRARIES} ${PROJECT_NAME} gtest)
120+
target_link_libraries(${PROJECT_NAME}_test ${catkin_LIBRARIES} ${PROJECT_NAME})
89121

90122
if(ENABLE_COVERAGE_TESTING)
91-
set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*")
123+
set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test/*" "*/${PROJECT_NAME}/check/*")
92124
add_code_coverage(
93-
NAME ${PROJECT_NAME}_coverage
94-
DEPENDS tests
125+
NAME coverage_report
126+
DEPENDENCIES ${PROJECT_NAME}_test
95127
)
96128
endif()
97-
endif ()
129+
endif()

march_hardware/check/SlaveCount.cpp march_hardware/check/slave_count.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ int main(int argc, char** argv)
1616
{
1717
ros::init(argc, argv, "slave_count_check");
1818
ros::NodeHandle nh;
19+
const std::string param = "/march/check/slave_count";
1920

2021
ROS_INFO("Trying to start EtherCAT");
2122
std::string ifname = "enp2s0";
@@ -24,7 +25,7 @@ int main(int argc, char** argv)
2425
if (!ec_init(&ifname[0]))
2526
{
2627
ROS_FATAL("No socket connection on %s. Confirm that you have selected the right ifname", ifname.c_str());
27-
nh.setParam("/check/slave_count", 0);
28+
nh.setParam(param, 0);
2829
return 1;
2930
}
3031
ROS_INFO("ec_init on %s succeeded", ifname.c_str());
@@ -34,11 +35,12 @@ int main(int argc, char** argv)
3435
{
3536
ROS_FATAL("No slaves found, shutting down. Confirm that you have selected the right ifname.");
3637
ROS_FATAL("Check that the first slave is connected properly");
37-
nh.setParam("/check/slave_count", 0);
38+
nh.setParam(param, 0);
3839
return 1;
3940
}
4041
ROS_INFO("%d slave(s) found and initialized.", ec_slavecount);
4142

42-
nh.setParam("/check/slave_count", ec_slavecount);
43+
nh.setParam(param, ec_slavecount);
44+
ros::shutdown();
4345
return 0;
4446
}

march_hardware/include/march_hardware/ActuationMode.h

+24-20
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,79 @@ class ActuationMode
1717
unknown,
1818
};
1919

20-
ActuationMode()
20+
ActuationMode() : value_(unknown)
2121
{
22-
this->value = unknown;
23-
};
22+
}
23+
24+
ActuationMode(Value value) : value_(value)
25+
{
26+
}
2427

2528
explicit ActuationMode(const std::string& actuationMode)
2629
{
2730
if (actuationMode == "position")
2831
{
29-
this->value = position;
32+
this->value_ = position;
3033
}
3134
else if (actuationMode == "unknown")
3235
{
33-
this->value = unknown;
36+
this->value_ = unknown;
3437
}
3538
else if (actuationMode == "torque")
3639
{
37-
this->value = torque;
40+
this->value_ = torque;
3841
}
3942
else
4043
{
4144
ROS_WARN("Actuation mode (%s) is not recognized, setting to unknown mode", actuationMode.c_str());
42-
this->value = ActuationMode::unknown;
45+
this->value_ = ActuationMode::unknown;
4346
}
4447
}
4548

46-
int toModeNumber()
49+
uint8_t toModeNumber()
4750
{
48-
if (value == position)
51+
switch (this->value_)
4952
{
50-
return 8;
51-
}
52-
else if (value == torque)
53-
{
54-
return 10;
53+
case position:
54+
return 8;
55+
case torque:
56+
return 10;
57+
default:
58+
return 0;
5559
}
5660
}
5761

5862
int getValue() const
5963
{
60-
return value;
64+
return this->value_;
6165
}
6266

6367
bool operator==(ActuationMode::Value a) const
6468
{
65-
return value == a;
69+
return this->value_ == a;
6670
}
6771

6872
bool operator!=(ActuationMode::Value a) const
6973
{
70-
return value != a;
74+
return this->value_ != a;
7175
}
7276

7377
std::string toString() const
7478
{
75-
switch (this->value)
79+
switch (this->value_)
7680
{
7781
case position:
7882
return "position";
7983
case torque:
8084
return "torque";
8185
default:
82-
ROS_WARN("Actuationmode (%i) is neither 'torque' or 'position", value);
86+
ROS_WARN("Actuationmode (%i) is neither 'torque' or 'position", this->value_);
8387
return "unknown";
8488
}
8589
}
8690

8791
private:
88-
Value value = unknown;
92+
Value value_ = unknown;
8993
};
9094
} // namespace march
9195

march_hardware/include/march_hardware/AngleConversions.h

-17
This file was deleted.

0 commit comments

Comments
 (0)