Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test app to test odrive can messages #436

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ add_app_subdirectory(${TEST_APPS_DIR}/test-quadrature64cpr)
add_app_subdirectory(${TEST_APPS_DIR}/test-stress-can)
add_app_subdirectory(${TEST_APPS_DIR}/test-units)
add_app_subdirectory(${TEST_APPS_DIR}/test-watchdog)
add_app_subdirectory(${TEST_APPS_DIR}/test-odrive-can)

# Ensure APP was specified
if ("$ENV{APP}" STREQUAL "")
Expand Down
5 changes: 4 additions & 1 deletion supported_build_configurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ test-stress-can:
- GIMBAL_REV2_2021
- PDB_REV2_2021
- SCIENCE_REV2_2021
- UWRT_NUCLEO
- UWRT_NUCLEO

test-odrive-can:
- UWRT_NUCLEO
13 changes: 13 additions & 0 deletions test-apps/test-odrive-can/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_executable(test-odrive-can)
target_sources(test-odrive-can PRIVATE src/main.cpp)
target_include_directories(test-odrive-can PUBLIC include)
target_link_libraries(test-odrive-can
PRIVATE
mbed-os
CANInterface
CANBus
CANMsg
uwrt-mars-rover-hw-bridge
Logger
)
mbed_set_post_build(test-odrive-can)
67 changes: 67 additions & 0 deletions test-apps/test-odrive-can/include/CANConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include "CANInterface.h"
#include "CANMsg.h"
#include "hw_bridge.h"

static mbed_error_status_t handle_test_msg_one_shot(void);

namespace CANConfig {

using namespace HWBRIDGE;

static CANMsgMap rxMsgMap = {
// Msg 1
{CANID::ODRIVE_SET_INPUT_POS_AXIS0,
{
{CANSIGNAL::ODRIVE_INPUT_POS_AXIS0, 0},
{CANSIGNAL::ODRIVE_VEL_FF_AXIS0, 0},
{CANSIGNAL::ODRIVE_TORQUE_FF_POS_AXIS0, 0}
}},

{CANID::ODRIVE_SET_AXIS_REQUESTED_STATE_AXIS0,
{
{CANSIGNAL::ODRIVE_AXIS_REQUESTED_STATE_AXIS0,8}
}},

// Msg 2
/*{CANID::COMMON_DEBUG_MESSAGE3,
{
{CANSIGNAL::COMMON_DEBUG_SIGNAL3, 0},
}},*/
};

static CANMsgMap txMsgMap = {
// Msg 1

// Msg 2*/

{CANID::ODRIVE_HEARTBEAT_MESSAGE_AXIS0,
{
// {CANSIGNAL::ODRIVE_AXIS_ERROR_AXIS0, (CANSignalValue_t)ODRIVE_AXIS_ERROR_AXIS0_VALUES},
// {CANSIGNAL::ODRIVE_AXIS_CURRENT_STATE_AXIS0, (CANSignalValue_t)ODRIVE_AXIS_CURRENT_STATE_AXIS0_VALUES},
// {CANSIGNAL::ODRIVE_CONTROLLER_STATUS_AXIS0, (CANSignalValue_t)ODRIVE_CONTROLLER_STATUS_AXIS0_VALUES},
{CANSIGNAL::ODRIVE_AXIS_ERROR_AXIS0, 0},
{CANSIGNAL::ODRIVE_AXIS_CURRENT_STATE_AXIS0, 0},
{CANSIGNAL::ODRIVE_CONTROLLER_STATUS_AXIS0, 0},
}},
};

/*const static CANMsg::CANMsgHandlerMap rxOneShotMsgHandler = {
{CANID::COMMON_DEBUG_MESSAGE3, &handle_test_msg_one_shot},
};*/

CANInterface::Config config = {
// CAN bus pins
.can1_RX = CAN1_RX,
.can1_TX = CAN1_TX,
.can2_RX = CAN2_RX,
.can2_TX = CAN2_TX,

// Message maps and handlers
.rxMsgMap = &rxMsgMap,
.txMsgMap = &txMsgMap,
//.rxOneShotMsgHandler = &rxOneShotMsgHandler,
};

} // namespace CANConfig
Loading