Skip to content

Commit

Permalink
refactor: Rename Driver class to Actuator
Browse files Browse the repository at this point in the history
  • Loading branch information
2b-t committed Feb 18, 2024
1 parent 45fd12e commit 32572c5
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 209 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ add_library(myactuator_rmd SHARED
src/can/utilities.cpp
src/protocol/requests.cpp
src/protocol/responses.cpp
src/driver.cpp
src/actuator.cpp
)
target_include_directories(myactuator_rmd PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -88,8 +88,8 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
test/protocol/responses_test.cpp
test/mock/actuator_adaptor.cpp
test/mock/actuator_mock.cpp
test/mock/driver_actuator_test.cpp
test/driver_test.cpp
test/mock/actuator_actuator_mock_test.cpp
test/actuator_test.cpp
test/run_tests.cpp
)
target_compile_definitions(run_tests PUBLIC NDEBUG)
Expand Down
16 changes: 8 additions & 8 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ A minimal example for the `main.cpp` can be found below:


int main() {
myactuator_rmd::Driver driver {"can0", 1};
std::cout << driver.getVersionDate() << std::endl;
myactuator_rmd::Actuator actuator {"can0", 1};
std::cout << actuator.getVersionDate() << std::endl;
return EXIT_SUCCESS;
}
```
Expand All @@ -110,15 +110,15 @@ int main() {
$ python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from myactuator_rmd_py import Driver
>>> driver = Driver("can0", 1)
>>> driver.getVersionDate()
>>> from myactuator_rmd_py import Actuator
>>> actuator = Actuator("can0", 1)
>>> actuator.getVersionDate()
2023020601
>>> driver.sendPositionAbsoluteSetpoint(180.0, 500.0)
>>> driver.shutdownMotor()
>>> actuator.sendPositionAbsoluteSetpoint(180.0, 500.0)
>>> actuator.shutdownMotor()
```

In case you installed the package through ROS 2 the shared library will be inside the `myactuator_rmd` package so you need to import with `from myactuator_rmd.myactuator_rmd_py import Driver`.
In case you installed the package through ROS 2 the shared library will be inside the `myactuator_rmd` package so you need to import with `from myactuator_rmd.myactuator_rmd_py import Actuator`.

For more information you might also inspect the contents of the module inside Python 3 with `help(myactuator_rmd_py)`.

Expand Down
74 changes: 37 additions & 37 deletions bindings/myactuator_rmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "myactuator_rmd/can/frame.hpp"
#include "myactuator_rmd/can/node.hpp"
#include "myactuator_rmd/actuator_constants.hpp"
#include "myactuator_rmd/driver.hpp"
#include "myactuator_rmd/actuator.hpp"
#include "myactuator_rmd/exceptions.hpp"
#include "myactuator_rmd/io.hpp"

Expand Down Expand Up @@ -62,43 +62,43 @@ namespace myactuator_rmd {

PYBIND11_MODULE(myactuator_rmd_py, m) {

m.doc() = "MyActuator RMD driver main module";
pybind11::class_<myactuator_rmd::Driver>(m, "Driver")
m.doc() = "MyActuator RMD main module";
pybind11::class_<myactuator_rmd::Actuator>(m, "Actuator")
.def(pybind11::init<std::string const&, std::uint32_t>())
.def("getAcceleration", &myactuator_rmd::Driver::getAcceleration)
.def("getCanId", &myactuator_rmd::Driver::getCanId)
.def("getControllerGains", &myactuator_rmd::Driver::getControllerGains)
.def("getControlMode", &myactuator_rmd::Driver::getControlMode)
.def("getMotorModel", &myactuator_rmd::Driver::getMotorModel)
.def("getMotorPower", &myactuator_rmd::Driver::getMotorPower)
.def("getMotorStatus1", &myactuator_rmd::Driver::getMotorStatus1)
.def("getMotorStatus2", &myactuator_rmd::Driver::getMotorStatus2)
.def("getMotorStatus3", &myactuator_rmd::Driver::getMotorStatus3)
.def("getMultiTurnAngle", &myactuator_rmd::Driver::getMultiTurnAngle)
.def("getMultiTurnEncoderPosition", &myactuator_rmd::Driver::getMultiTurnEncoderPosition)
.def("getMultiTurnEncoderOriginalPosition", &myactuator_rmd::Driver::getMultiTurnEncoderOriginalPosition)
.def("getMultiTurnEncoderZeroOffset", &myactuator_rmd::Driver::getMultiTurnEncoderZeroOffset)
.def("getRuntime", &myactuator_rmd::Driver::getRuntime)
.def("getSingleTurnAngle", &myactuator_rmd::Driver::getSingleTurnAngle)
.def("getSingleTurnEncoderPosition", &myactuator_rmd::Driver::getSingleTurnEncoderPosition)
.def("getVersionDate", &myactuator_rmd::Driver::getVersionDate)
.def("lockBrake", &myactuator_rmd::Driver::lockBrake)
.def("releaseBrake", &myactuator_rmd::Driver::releaseBrake)
.def("reset", &myactuator_rmd::Driver::reset)
.def("sendCurrentSetpoint", &myactuator_rmd::Driver::sendCurrentSetpoint)
.def("sendPositionAbsoluteSetpoint", &myactuator_rmd::Driver::sendPositionAbsoluteSetpoint)
.def("sendTorqueSetpoint", &myactuator_rmd::Driver::sendTorqueSetpoint)
.def("sendVelocitySetpoint", &myactuator_rmd::Driver::sendVelocitySetpoint)
.def("setAcceleration", &myactuator_rmd::Driver::setAcceleration)
.def("setBaudRate", &myactuator_rmd::Driver::setBaudRate)
.def("setCanId", &myactuator_rmd::Driver::setCanId)
.def("setControllerGains", &myactuator_rmd::Driver::setControllerGains)
.def("setCurrentPositionAsEncoderZero", &myactuator_rmd::Driver::setCurrentPositionAsEncoderZero)
.def("setEncoderZero", &myactuator_rmd::Driver::setEncoderZero)
.def("setTimeout", &myactuator_rmd::Driver::setTimeout)
.def("shutdownMotor", &myactuator_rmd::Driver::shutdownMotor)
.def("stopMotor", &myactuator_rmd::Driver::stopMotor);
pybind11::register_exception<myactuator_rmd::Exception>(m, "DriverException");
.def("getAcceleration", &myactuator_rmd::Actuator::getAcceleration)
.def("getCanId", &myactuator_rmd::Actuator::getCanId)
.def("getControllerGains", &myactuator_rmd::Actuator::getControllerGains)
.def("getControlMode", &myactuator_rmd::Actuator::getControlMode)
.def("getMotorModel", &myactuator_rmd::Actuator::getMotorModel)
.def("getMotorPower", &myactuator_rmd::Actuator::getMotorPower)
.def("getMotorStatus1", &myactuator_rmd::Actuator::getMotorStatus1)
.def("getMotorStatus2", &myactuator_rmd::Actuator::getMotorStatus2)
.def("getMotorStatus3", &myactuator_rmd::Actuator::getMotorStatus3)
.def("getMultiTurnAngle", &myactuator_rmd::Actuator::getMultiTurnAngle)
.def("getMultiTurnEncoderPosition", &myactuator_rmd::Actuator::getMultiTurnEncoderPosition)
.def("getMultiTurnEncoderOriginalPosition", &myactuator_rmd::Actuator::getMultiTurnEncoderOriginalPosition)
.def("getMultiTurnEncoderZeroOffset", &myactuator_rmd::Actuator::getMultiTurnEncoderZeroOffset)
.def("getRuntime", &myactuator_rmd::Actuator::getRuntime)
.def("getSingleTurnAngle", &myactuator_rmd::Actuator::getSingleTurnAngle)
.def("getSingleTurnEncoderPosition", &myactuator_rmd::Actuator::getSingleTurnEncoderPosition)
.def("getVersionDate", &myactuator_rmd::Actuator::getVersionDate)
.def("lockBrake", &myactuator_rmd::Actuator::lockBrake)
.def("releaseBrake", &myactuator_rmd::Actuator::releaseBrake)
.def("reset", &myactuator_rmd::Actuator::reset)
.def("sendCurrentSetpoint", &myactuator_rmd::Actuator::sendCurrentSetpoint)
.def("sendPositionAbsoluteSetpoint", &myactuator_rmd::Actuator::sendPositionAbsoluteSetpoint)
.def("sendTorqueSetpoint", &myactuator_rmd::Actuator::sendTorqueSetpoint)
.def("sendVelocitySetpoint", &myactuator_rmd::Actuator::sendVelocitySetpoint)
.def("setAcceleration", &myactuator_rmd::Actuator::setAcceleration)
.def("setBaudRate", &myactuator_rmd::Actuator::setBaudRate)
.def("setCanId", &myactuator_rmd::Actuator::setCanId)
.def("setControllerGains", &myactuator_rmd::Actuator::setControllerGains)
.def("setCurrentPositionAsEncoderZero", &myactuator_rmd::Actuator::setCurrentPositionAsEncoderZero)
.def("setEncoderZero", &myactuator_rmd::Actuator::setEncoderZero)
.def("setTimeout", &myactuator_rmd::Actuator::setTimeout)
.def("shutdownMotor", &myactuator_rmd::Actuator::shutdownMotor)
.def("stopMotor", &myactuator_rmd::Actuator::stopMotor);
pybind11::register_exception<myactuator_rmd::Exception>(m, "ActuatorException");
pybind11::register_exception<myactuator_rmd::ProtocolException>(m, "ProtocolException");
pybind11::register_exception<myactuator_rmd::ValueRangeException>(m, "ValueRangeException");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* \file driver.hpp
* \file actuator.hpp
* \mainpage
* Contains the main driver
* \author
* Tobit Flatscher (github.com/2b-t)
*/

#ifndef MYACTUATOR_RMD__DRIVER
#define MYACTUATOR_RMD__DRIVER
#ifndef MYACTUATOR_RMD__ACTUATOR
#define MYACTUATOR_RMD__ACTUATOR
#pragma once

#include <chrono>
Expand All @@ -28,13 +28,13 @@

namespace myactuator_rmd {

/**\class Driver
/**\class Actuator
* \brief
* Driver for commanding the MyActuator RMD actuator series
* Actuator for commanding the MyActuator RMD actuator series
*/
class Driver: protected Node<AddressOffset::request,AddressOffset::response> {
class Actuator: protected Node<AddressOffset::request,AddressOffset::response> {
public:
/**\fn Driver
/**\fn Actuator
* \brief
* Class constructor
*
Expand All @@ -43,12 +43,12 @@ namespace myactuator_rmd {
* \param[in] actuator_id
* The actuator id [1, 32]
*/
Driver(std::string const& ifname, std::uint32_t const actuator_id);
Driver() = delete;
Driver(Driver const&) = delete;
Driver& operator = (Driver const&) = default;
Driver(Driver&&) = default;
Driver& operator = (Driver&&) = default;
Actuator(std::string const& ifname, std::uint32_t const actuator_id);
Actuator() = delete;
Actuator(Actuator const&) = delete;
Actuator& operator = (Actuator const&) = default;
Actuator(Actuator&&) = default;
Actuator& operator = (Actuator&&) = default;

/**\fn getAcceleration
* \brief
Expand Down Expand Up @@ -377,4 +377,4 @@ namespace myactuator_rmd {

}

#endif // MYACTUATOR_RMD__DRIVER
#endif // MYACTUATOR_RMD__ACTUATOR
2 changes: 1 addition & 1 deletion include/myactuator_rmd/myactuator_rmd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#pragma once

#include "myactuator_rmd/actuator_constants.hpp"
#include "myactuator_rmd/driver.hpp"
#include "myactuator_rmd/actuator.hpp"
#include "myactuator_rmd/exceptions.hpp"
#include "myactuator_rmd/io.hpp"
#include "myactuator_rmd/version.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/myactuator_rmd/protocol/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace myactuator_rmd {

/**\class Node
* \brief
* Base class for the driver as well as the actuator mock
* Base class for the actuator as well as the actuator mock
*/
template <std::uint32_t SEND_ID_OFFSET, std::uint32_t RECEIVE_ID_OFFSET>
class Node: protected can::Node {
Expand Down
Loading

0 comments on commit 32572c5

Please sign in to comment.