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

Commit d0434ff

Browse files
authored
Merge pull request #167 from project-march/develop
Create master branch
2 parents 8c3893b + 5986270 commit d0434ff

File tree

148 files changed

+8073
-4
lines changed

Some content is hidden

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

148 files changed

+8073
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.idea/*
2-
cmake-build-debug/**
2+
*/cmake-build-debug/**

.rosinstall

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- git:
2+
local-name: march
3+
uri: https://github.com/project-march/march
4+
version: develop

.travis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
2+
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)
3+
4+
language: generic # optional, just removes the language badge
5+
6+
services:
7+
- docker
8+
9+
notifications:
10+
slack:
11+
secure: I7/Kqj/ZiaoW9bZzlDFYU2aFv1J3R0z5+6kDf9TI8AHsN9K/GYs05kG8gfpORmaBobF22AwpB/I5o8ga5nJGAP25SgX8bcP3jJaKUyfMxXj3ThkfINTMKeLhZqzh5c3ppBwHy62vdSDry4fyuIhtaWOa+8GqmI3D37/0yzFCPQLLYnSXoF5EKSFkKPytfVdwbOKE/uSgPbAy0xsPUKLEGdIhvFjyDzfj5KIHcYWFu9eus0GpuCJVJE/nGTz7PrQ9Rhuh3eVeJNn5CEXo+0Lgn8lghUY0xRH/0xn+mhjYZnxTNO18YRoiF8lUB+/phQx2E3GiDrtPd7BjtluKGIkgFMZM/dyzHN7lSeCJZ0nDhOuALNwdbhS8Hw18q5a6SanT4Kegno8ebDNwsEyHuiHy6D3XNE2PHIZ5SbSgX9MOaLBtarcHccAR19T+96mWJANS6rIKnhe0zW9+Jxl99mTCgcNjTmcm2YG5Axm8xOBmoK920I4ke1wfb9QLeMIOnQ/JM6DxkMbQGtoN49ztrg4cv+JwUOUnEn/yiLsz+p8EdaFiRLfAbww9VJ+1geDdGifv+TRq72RpTzGnNveNnRRysxBjfei3EwwoZqUFhZyVWQWqHuwSa8xFpxS3FMmDzP16oMAB/TuMV03MBTqNK/JDSMXq54Bs1pmtPJ4kvfGiKKo=
12+
email: false
13+
14+
# include the following block if the C/C++ build artifacts should get cached by Travis,
15+
# CCACHE_DIR needs to get set as well to actually fill the cache
16+
cache:
17+
directories:
18+
- $HOME/.ccache
19+
20+
git:
21+
quiet: true # optional, silences the cloning of the target repository
22+
23+
# configure the build environment(s)
24+
# https://github.com/ros-industrial/industrial_ci/blob/master/doc/index.rst#variables-you-can-configure
25+
env:
26+
global:
27+
- ROS_REPO=ros
28+
- CCACHE_DIR=$HOME/.ccache # enables C/C++ caching in industrial_ci
29+
- BUILDER=colcon
30+
- CATKIN_LINT=pedantic
31+
- UPSTREAM_WORKSPACE='.rosinstall -march/march_gait_scheduler -march/march_gait_selection -march/march_launch -march/march_rqt_launch_menu -march/march_safety -march/march_sound_scheduler -march/march_state_machine'
32+
- AFTER_SCRIPT='builder_run_build "$target_ws/install" "$target_ws" --cmake-target-skip-unavailable --cmake-target roslint'
33+
matrix:
34+
- ROS_DISTRO=kinetic
35+
- ROS_DISTRO=melodic
36+
37+
# clone and run industrial_ci
38+
install:
39+
- git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .industrial_ci -b master
40+
script:
41+
- .industrial_ci/travis.sh

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
# ethercat-master
2-
The EtherCAT master of the MARCH IV. This repository uses the SOEM library.
3-
Currently this repository is empty.
1+
# Hardware Interface
2+
The hardware interface of the MARCH exoskeleton. This includes EtherCAT master and uses the SOEM library.
3+
4+
| Branch | Build Status |
5+
| ------ |:------------:|
6+
| Master | [![Build Status](https://api.travis-ci.com/project-march/hardware-interface.svg?branch=master)](https://travis-ci.com/project-march/hardware-interface) |
7+
| Develop | [![Build Status](https://api.travis-ci.com/project-march/hardware-interface.svg?branch=develop)](https://travis-ci.com/project-march/hardware-interface) |
8+

codecov.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ignore:
2+
- "march_hardware/soem/.*"
3+
- "march_hardware/test/.*"
4+
- "march_hardware_builder/test/.*"
5+
- "march_hardware_interface/test/.*"
6+
- "march_temperature_sensor_controller/test/.*"
7+

doc.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
packages="march_hardware march_hardware_builder march_hardware_interface march_temperature_sensor_controller"
4+
5+
mkdir -p docs/html
6+
for package in $packages; do
7+
catkin document $package --no-deps
8+
mv docs/$package/html docs/html/$package
9+
done

march_hardware/CMakeLists.txt

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(march_hardware)
3+
4+
add_compile_options(-std=c++11)
5+
6+
find_package(catkin REQUIRED COMPONENTS
7+
roscpp
8+
roslint
9+
soem
10+
)
11+
12+
catkin_package(
13+
INCLUDE_DIRS include
14+
CATKIN_DEPENDS
15+
LIBRARIES ${PROJECT_NAME}
16+
)
17+
18+
set(ROSLINT_CPP_OPTS "--filter=-build/include,-build/header_guard,-runtime/references" "--linelength=120")
19+
20+
file(GLOB_RECURSE lintfiles
21+
"src/*.cpp"
22+
"include/*.h"
23+
)
24+
25+
roslint_cpp(${lintfiles})
26+
27+
28+
include_directories(
29+
include
30+
${catkin_INCLUDE_DIRS}
31+
${soem_INCLUDE_DIRS}/soem
32+
)
33+
34+
install(DIRECTORY include/${PROJECT_NAME}/
35+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
36+
)
37+
38+
add_library(${PROJECT_NAME}
39+
include/${PROJECT_NAME}/ActuationMode.h
40+
include/${PROJECT_NAME}/AngleConversions.h
41+
include/${PROJECT_NAME}/BootShutdownOffsets.h
42+
include/${PROJECT_NAME}/Encoder.h
43+
include/${PROJECT_NAME}/EtherCAT/EthercatIO.h
44+
include/${PROJECT_NAME}/EtherCAT/EthercatMaster.h
45+
include/${PROJECT_NAME}/EtherCAT/EthercatSDO.h
46+
include/${PROJECT_NAME}/HighVoltage.h
47+
include/${PROJECT_NAME}/IMotionCube.h
48+
include/${PROJECT_NAME}/IMotionCubeState.h
49+
include/${PROJECT_NAME}/IMotionCubeTargetState.h
50+
include/${PROJECT_NAME}/Joint.h
51+
include/${PROJECT_NAME}/LowVoltage.h
52+
include/${PROJECT_NAME}/MarchRobot.h
53+
include/${PROJECT_NAME}/NetDriverOffsets.h
54+
include/${PROJECT_NAME}/PDOmap.h
55+
include/${PROJECT_NAME}/PowerDistributionBoard.h
56+
include/${PROJECT_NAME}/Slave.h
57+
include/${PROJECT_NAME}/TemperatureGES.h
58+
include/${PROJECT_NAME}/TemperatureSensor.h
59+
src/Encoder.cpp
60+
src/EtherCAT/EthercatIO.cpp
61+
src/EtherCAT/EthercatMaster.cpp
62+
src/EtherCAT/EthercatSDO.cpp
63+
src/HighVoltage.cpp
64+
src/IMotionCube.cpp
65+
src/IMotionCubeTargetState.cpp
66+
src/Joint.cpp
67+
src/LowVoltage.cpp
68+
src/MarchRobot.cpp
69+
src/PDOmap.cpp
70+
src/PowerDistributionBoard.cpp
71+
src/TemperatureGES.cpp
72+
)
73+
74+
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
75+
76+
add_executable(slave_count_check check/SlaveCount.cpp)
77+
target_link_libraries(slave_count_check ${PROJECT_NAME})
78+
79+
install(TARGETS ${PROJECT_NAME}
80+
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
81+
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
82+
)
83+
84+
install(TARGETS slave_count_check
85+
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
86+
)
87+
88+
## Add gtest based cpp test target and link libraries
89+
if (CATKIN_ENABLE_TESTING)
90+
find_package(code_coverage REQUIRED)
91+
find_package(rostest REQUIRED)
92+
93+
if(ENABLE_COVERAGE_TESTING)
94+
include(CodeCoverage)
95+
append_coverage_compiler_flags()
96+
endif()
97+
98+
add_rostest_gmock(${PROJECT_NAME}-test
99+
test/march4cpp.test
100+
test/TestRunner.cpp
101+
test/TestEncoder.cpp
102+
test/TestIMotionCube.cpp
103+
test/TestTemperatureGES.cpp
104+
test/TestJoint.cpp
105+
test/TestPDOmap.cpp
106+
test/TestBootShutdownOffsets.cpp
107+
test/TestNetDriverOffsets.cpp
108+
test/TestNetMonitorOffsets.cpp
109+
test/TestLowVoltage.cpp
110+
test/TestHighVoltage.cpp
111+
test/TestPowerDistributionBoard.cpp
112+
test/mocks/MockTemperatureGES.cpp
113+
test/mocks/MockTemperatureSensor.cpp
114+
test/mocks/MockEncoder.cpp
115+
test/mocks/MockIMotionCube.cpp
116+
test/mocks/MockJoint.cpp
117+
)
118+
target_link_libraries(${PROJECT_NAME}-test ${catkin_LIBRARIES} ${PROJECT_NAME} gtest)
119+
120+
if(ENABLE_COVERAGE_TESTING)
121+
set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*")
122+
add_code_coverage(
123+
NAME ${PROJECT_NAME}_coverage
124+
DEPENDS tests
125+
)
126+
endif()
127+
endif ()
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2019 Project March.
2+
3+
#include <ros/ros.h>
4+
5+
#include <soem/ethercattype.h>
6+
#include <soem/nicdrv.h>
7+
#include <soem/ethercatbase.h>
8+
#include <soem/ethercatmain.h>
9+
#include <soem/ethercatdc.h>
10+
#include <soem/ethercatcoe.h>
11+
#include <soem/ethercatfoe.h>
12+
#include <soem/ethercatconfig.h>
13+
#include <soem/ethercatprint.h>
14+
15+
int main(int argc, char** argv)
16+
{
17+
ros::init(argc, argv, "slave_count_check");
18+
ros::NodeHandle nh;
19+
20+
ROS_INFO("Trying to start EtherCAT");
21+
std::string ifname = "enp2s0";
22+
23+
// Initialise SOEM, bind socket to ifname
24+
if (!ec_init(&ifname[0]))
25+
{
26+
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+
return 1;
29+
}
30+
ROS_INFO("ec_init on %s succeeded", ifname.c_str());
31+
32+
// Find and auto-config slaves
33+
if (ec_config_init(FALSE) <= 0)
34+
{
35+
ROS_FATAL("No slaves found, shutting down. Confirm that you have selected the right ifname.");
36+
ROS_FATAL("Check that the first slave is connected properly");
37+
nh.setParam("/check/slave_count", 0);
38+
return 1;
39+
}
40+
ROS_INFO("%d slave(s) found and initialized.", ec_slavecount);
41+
42+
nh.setParam("/check/slave_count", ec_slavecount);
43+
return 0;
44+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright 2019 Project March.
2+
3+
#ifndef MARCH_HARDWARE_INTERFACE_ACTUATIONMODE_H
4+
#define MARCH_HARDWARE_INTERFACE_ACTUATIONMODE_H
5+
6+
#include <ros/console.h>
7+
8+
namespace march4cpp
9+
{
10+
class ActuationMode
11+
{
12+
public:
13+
enum Value : int
14+
{
15+
position,
16+
torque,
17+
unknown,
18+
};
19+
20+
ActuationMode()
21+
{
22+
this->value = unknown;
23+
};
24+
25+
explicit ActuationMode(const std::string& actuationMode)
26+
{
27+
if (actuationMode == "position")
28+
{
29+
this->value = position;
30+
}
31+
else if (actuationMode == "unknown")
32+
{
33+
this->value = unknown;
34+
}
35+
else if (actuationMode == "torque")
36+
{
37+
this->value = torque;
38+
}
39+
else
40+
{
41+
ROS_WARN("Actuation mode (%s) is not recognized, setting to unknown mode", actuationMode.c_str());
42+
this->value = ActuationMode::unknown;
43+
}
44+
}
45+
46+
int toModeNumber()
47+
{
48+
if (value == position)
49+
{
50+
return 8;
51+
}
52+
else if (value == torque)
53+
{
54+
return 10;
55+
}
56+
}
57+
58+
int getValue() const
59+
{
60+
return value;
61+
}
62+
63+
bool operator==(ActuationMode::Value a) const
64+
{
65+
return value == a;
66+
}
67+
68+
bool operator!=(ActuationMode::Value a) const
69+
{
70+
return value != a;
71+
}
72+
73+
std::string toString() const
74+
{
75+
switch (this->value)
76+
{
77+
case position:
78+
return "position";
79+
case torque:
80+
return "torque";
81+
default:
82+
ROS_WARN("Actuationmode (%i) is neither 'torque' or 'position", value);
83+
return "unknown";
84+
}
85+
}
86+
87+
private:
88+
Value value = unknown;
89+
};
90+
} // namespace march4cpp
91+
92+
#endif // MARCH_HARDWARE_INTERFACE_ACTUATIONMODE_H
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2019 Project March.
2+
#ifndef PROJECT_ANGLECONVERSIONS_H
3+
#define PROJECT_ANGLECONVERSIONS_H
4+
5+
#include <cmath>
6+
7+
float DegtoRad(float deg)
8+
{
9+
return static_cast<float>(deg * M_PI / 180);
10+
}
11+
12+
float RadtoDeg(float rad)
13+
{
14+
return static_cast<float>(rad * 180 / M_PI);
15+
}
16+
17+
#endif // PROJECT_ANGLECONVERSIONS_H

0 commit comments

Comments
 (0)