Skip to content

Commit 4c9659a

Browse files
committed
Fixed DIOs settup in Drive.
1 parent 83f7d1c commit 4c9659a

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
5555
if(USE_ROS)
5656
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-int-in-bool-context" )
5757
else()
58-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-int-in-bool-context -static-libstdc++ -static-libgcc" )
58+
if(CMAKE_CROSSCOMPILING)
59+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-int-in-bool-context -static" )
60+
else()
61+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-int-in-bool-context" )
62+
endif()
5963
endif()
6064
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6165
set(THREADS_PREFER_PTHREAD_FLAG TRUE)

script/uploadBB.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fi
2121
#Check if BB is connected
2222
ping -W 1 -c 1 $SSH_IP_ADDR >/dev/null 2>&1
2323
if [ $? -ne 0 ] ; then
24-
echo "Nothing connected on ${SSH_IP_ADDR}. Exiting."
25-
exit
24+
echo "Nothing connected on ${SSH_IP_ADDR}. Exiting."
25+
exit
2626
fi
2727

2828
#set in root folder

src/core/robot/Drive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ bool Drive::initPDOs() {
208208

209209
// Calculate COB_ID. If RPDO:
210210
//int COB_ID = 0x100 * (PDO_Num+1) + NodeID;
211-
spdlog::debug("Set up CONTROL_WORD RPDO on Node {}", NodeID);
211+
spdlog::debug("Set up CONTROL_WORD and DIGITAL_OUT RPDO on Node {}", NodeID);
212212
int RPDO_Num = 1;
213213
if (sendSDOMessages(generateRPDOConfigSDO(RPDO_MappedObjects[RPDO_Num], RPDO_Num, RPDO_COBID[RPDO_Num] + NodeID, 0xff)) < 0) {
214-
spdlog::error("Set up CONTROL_WORD RPDO FAILED on node {}", NodeID);
214+
spdlog::error("Set up CONTROL_WORD and DIGITAL_OUT RPDO FAILED on node {}", NodeID);
215215
return false;
216216
}
217217
spdlog::debug("Set up TARGET_POS RPDO on Node {}", NodeID);

src/core/robot/Drive.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ class Drive {
231231
std::vector<std::string> generateTorqueControlConfigSDO();
232232

233233
/**
234-
* \brief Send a list (vector) of properly formatted SDO Messages
235-
*
236-
* \return int -number_of_unsuccesfull messages (0 means OK for all). vcan will always return 0 (no reply check).
237-
*/
234+
* \brief Send a list (vector) of properly formatted SDO Messages
235+
*
236+
* \return int -number_of_unsuccesfull messages (0 means OK for all). vcan will always return 0 (no reply check).
237+
*/
238238
int sendSDOMessages(std::vector<std::string> messages);
239239

240240

@@ -295,8 +295,8 @@ class Drive {
295295
{TARGET_POS, 4},
296296
{TARGET_VEL, 4},
297297
{TARGET_TOR, 2},
298-
{DIGITAL_IN, 2},
299-
{DIGITAL_OUT, 2}};
298+
{DIGITAL_IN, 4},
299+
{DIGITAL_OUT, 4}};
300300

301301
/**
302302
* \brief Map between the Commonly-used OD entries and their addresses and sub-index - used to generate PDO Configurations
@@ -305,16 +305,16 @@ class Drive {
305305
*/
306306
std::map<OD_Entry_t, std::array<int, 2>> OD_Addresses = {
307307
{STATUS_WORD, {0x6041, 0x00}},
308-
{ERROR_WORD, {0x2601, 0x00}},
308+
{ERROR_WORD, {0x603F, 0x00}},
309309
{ACTUAL_POS, {0x6064, 0x00}},
310310
{ACTUAL_VEL, {0x606C, 0x00}},
311311
{ACTUAL_TOR, {0x6077, 0x00}},
312312
{CONTROL_WORD, {0x6040, 0x00}},
313313
{TARGET_POS, {0x607A, 0x00}},
314314
{TARGET_VEL, {0x60FF, 0x00}},
315315
{TARGET_TOR, {0x6071, 0x00}},
316-
{DIGITAL_IN, {0x2501, 0x00}},
317-
{DIGITAL_OUT, {0x2601, 0x00}}};
316+
{DIGITAL_IN, {0x60FD, 0x00}},
317+
{DIGITAL_OUT, {0x60FE, 0x01}}};
318318

319319
std::map<OD_Entry_t, void *> OD_MappedObjectAddresses = {
320320
{STATUS_WORD, (void *)&statusWord},
@@ -343,8 +343,8 @@ class Drive {
343343
INTEGER32 targetPos=0;
344344
INTEGER32 targetVel=0;
345345
INTEGER16 targetTor=0;
346-
UNSIGNED16 digitalIn=0;
347-
UNSIGNED16 digitalOut=0;
346+
UNSIGNED32 digitalIn=0;
347+
UNSIGNED32 digitalOut=0;
348348
/**
349349
* \brief Current error state of the drive
350350
*

src/hardware/drives/CopleyDrive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include <iostream>
88

99
CopleyDrive::CopleyDrive(int NodeID) : Drive::Drive(NodeID) {
10-
this->NodeID = NodeID;
10+
OD_Addresses[DIGITAL_IN] = {0x219A, 0x00}; //Use INPUT PIN STATE instead of standard DI. Not tested.
11+
OD_Addresses[DIGITAL_OUT] = {0X2194, 0x00}; //Not tested. Need dedicated configuration before use. See Copley doc.
1112
}
1213
CopleyDrive::~CopleyDrive() {
1314
spdlog::debug("CopleyDrive Deleted");
@@ -97,7 +98,6 @@ bool CopleyDrive::setPositionOffset(int offset) {
9798

9899
}
99100

100-
101101
bool CopleyDrive::setTrackingWindow(INTEGER32 window) {
102102
spdlog::debug("NodeID {} Tracking Window", NodeID);
103103

src/hardware/drives/KincoDrive.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ KincoDrive::KincoDrive(int NodeID) : Drive::Drive(NodeID) {
66
//Remap torque reading and writting registers
77
OD_Addresses[ACTUAL_TOR] = {0x6078, 0x00};
88
OD_Addresses[TARGET_TOR] = {0x60F6, 0x08};
9-
//Weird Kinco DIOs addresses
9+
//Weird Kinco error and DIOs addresses
10+
OD_Addresses[ERROR_WORD] = {0x2601, 0x00};
1011
OD_Addresses[DIGITAL_IN] = {0x2010, 0x0B};
1112
OD_Addresses[DIGITAL_OUT] = {0x2010, 0x0E};
1213
}

0 commit comments

Comments
 (0)