Skip to content

Commit

Permalink
Rename ForceTorqueCan to Jr3Mbed
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Sep 19, 2023
1 parent 4ad7ff6 commit 40990d7
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 75 deletions.
2 changes: 1 addition & 1 deletion libraries/YarpPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ add_subdirectory(DextraCanControlBoard)
add_subdirectory(DextraSerialControlBoard)
add_subdirectory(EmulatedControlBoard)
add_subdirectory(FakeJoint)
add_subdirectory(ForceTorqueCan)
add_subdirectory(JointCalibrator)
add_subdirectory(Jr3Mbed)
add_subdirectory(Jr3Pci)
add_subdirectory(LacqueyFetch)
add_subdirectory(LeapMotionSensor)
Expand Down
30 changes: 0 additions & 30 deletions libraries/YarpPlugins/ForceTorqueCan/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions libraries/YarpPlugins/ForceTorqueCan/LogComponent.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions libraries/YarpPlugins/ForceTorqueCan/LogComponent.hpp

This file was deleted.

29 changes: 29 additions & 0 deletions libraries/YarpPlugins/Jr3Mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
yarp_prepare_plugin(Jr3Mbed
CATEGORY device
TYPE roboticslab::Jr3Mbed
INCLUDE Jr3Mbed.hpp
DEFAULT ON)

if(NOT SKIP_Jr3Mbed)

yarp_add_plugin(Jr3Mbed Jr3Mbed.hpp
DeviceDriverImpl.cpp
ISixAxisForceTorqueSensorsImpl.cpp
CanReadThread.hpp
CanReadThread.cpp
LogComponent.hpp
LogComponent.cpp)

target_link_libraries(Jr3Mbed YARP::YARP_os
YARP::YARP_dev)

yarp_install(TARGETS Jr3Mbed
LIBRARY DESTINATION ${ROBOTICSLAB-YARP-DEVICES_DYNAMIC_PLUGINS_INSTALL_DIR}
ARCHIVE DESTINATION ${ROBOTICSLAB-YARP-DEVICES_STATIC_PLUGINS_INSTALL_DIR}
YARP_INI DESTINATION ${ROBOTICSLAB-YARP-DEVICES_PLUGIN_MANIFESTS_INSTALL_DIR})

else()

set(ENABLE_Jr3Mbed OFF CACHE BOOL "Enable/disable Jr3Mbed device" FORCE)

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void CanReadThread::run()

if ((msg.getId() & 0x07F) == 0x001)
{
yCDebug(FTC, "Received from id %d: %s", msg.getId(), msgToStr(msg.getLen(), msg.getData()).c_str());
yCDebug(JR3M, "Received from id %d: %s", msg.getId(), msgToStr(msg.getLen(), msg.getData()).c_str());

std::memcpy(&data, msg.getData(), sizeof(data));

Expand Down Expand Up @@ -110,7 +110,7 @@ void CanReadThread::interpretMessage(std::uint8_t op, std::int16_t val1, std::in
mz = val3 * 61.0 / 16384;
break;
default:
yCWarning(FTC, "Unknown operation %d", op);
yCWarning(JR3M, "Unknown operation %d", op);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace roboticslab
{

/**
* @ingroup ForceTorqueCan
* @ingroup Jr3Mbed
* @brief A thread for reading incoming CAN messages.
*/
class CanReadThread : public yarp::os::Thread
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "ForceTorqueCan.hpp"
#include "Jr3Mbed.hpp"

#include <vector>

Expand All @@ -14,23 +14,23 @@ using namespace roboticslab;

// -----------------------------------------------------------------------------

bool ForceTorqueCan::open(yarp::os::Searchable & config)
bool Jr3Mbed::open(yarp::os::Searchable & config)
{
yarp::os::Property robotConfig;
auto & rf = yarp::os::ResourceFinder::getResourceFinderSingleton();
auto configPath = rf.findFileByName("config.ini"); // set YARP_ROBOT_NAME first

if (configPath.empty() || !robotConfig.fromConfigFile(configPath))
{
yCError(FTC) << "Robot config file not found or insufficient permissions:" << configPath;
yCError(JR3M) << "Robot config file not found or insufficient permissions:" << configPath;
return false;
}

const auto * canBuses = config.find("canBuses").asList();

if (!canBuses)
{
yCError(FTC) << "Missing key \"canBuses\" or not a list";
yCError(JR3M) << "Missing key \"canBuses\" or not a list";
return false;
}

Expand All @@ -44,7 +44,7 @@ bool ForceTorqueCan::open(yarp::os::Searchable & config)

if (filtersList->size() != canBuses->size())
{
yCError(FTC) << "Number of filters does not match number of CAN buses";
yCError(JR3M) << "Number of filters does not match number of CAN buses";
return false;
}

Expand All @@ -65,15 +65,15 @@ bool ForceTorqueCan::open(yarp::os::Searchable & config)

if (!robotConfig.check(canBus))
{
yCError(FTC) << "Missing CAN bus key:" << canBus;
yCError(JR3M) << "Missing CAN bus key:" << canBus;
return false;
}

const auto & canBusGroup = robotConfig.findGroup(canBus);

if (canBusGroup.isNull())
{
yCError(FTC) << "Missing CAN bus device group:" << canBus;
yCError(JR3M) << "Missing CAN bus device group:" << canBus;
return false;
}

Expand All @@ -88,7 +88,7 @@ bool ForceTorqueCan::open(yarp::os::Searchable & config)

if (!canBusDevice->open(canBusOptions))
{
yCError(FTC) << "Failed to open CAN device:" << canBus;
yCError(JR3M) << "Failed to open CAN device:" << canBus;
return false;
}

Expand All @@ -97,7 +97,7 @@ bool ForceTorqueCan::open(yarp::os::Searchable & config)

if (!canBusDevice->view(iCanBus) || !canBusDevice->view(iCanBufferFactory))
{
yCError(FTC) << "Failed to acquire CAN device interfaces:" << canBus;
yCError(JR3M) << "Failed to acquire CAN device interfaces:" << canBus;
return false;
}

Expand All @@ -106,19 +106,19 @@ bool ForceTorqueCan::open(yarp::os::Searchable & config)

if (!canReadThread->start())
{
yCError(FTC) << "Failed to start CAN read thread:" << canBus;
yCError(JR3M) << "Failed to start CAN read thread:" << canBus;
return false;
}

yCInfo(FTC) << "Started CAN read thread:" << canBus;
yCInfo(JR3M) << "Started CAN read thread:" << canBus;
}

return true;
}

// -----------------------------------------------------------------------------

bool ForceTorqueCan::close()
bool Jr3Mbed::close()
{
bool ok = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "ForceTorqueCan.hpp"
#include "Jr3Mbed.hpp"

#include <yarp/os/LogStream.h>
#include <yarp/os/SystemClock.h>
Expand All @@ -11,35 +11,35 @@ using namespace roboticslab;

// -----------------------------------------------------------------------------

std::size_t ForceTorqueCan::getNrOfSixAxisForceTorqueSensors() const
std::size_t Jr3Mbed::getNrOfSixAxisForceTorqueSensors() const
{
return 1;
}

// -----------------------------------------------------------------------------

yarp::dev::MAS_status ForceTorqueCan::getSixAxisForceTorqueSensorStatus(std::size_t sens_index) const
yarp::dev::MAS_status Jr3Mbed::getSixAxisForceTorqueSensorStatus(std::size_t sens_index) const
{
return yarp::dev::MAS_OK;
}

// -----------------------------------------------------------------------------

bool ForceTorqueCan::getSixAxisForceTorqueSensorName(std::size_t sens_index, std::string & name) const
bool Jr3Mbed::getSixAxisForceTorqueSensorName(std::size_t sens_index, std::string & name) const
{
return true;
}

// -----------------------------------------------------------------------------

bool ForceTorqueCan::getSixAxisForceTorqueSensorFrameName(std::size_t sens_index, std::string & name) const
bool Jr3Mbed::getSixAxisForceTorqueSensorFrameName(std::size_t sens_index, std::string & name) const
{
return getSixAxisForceTorqueSensorName(sens_index, name);
}

// -----------------------------------------------------------------------------

bool ForceTorqueCan::getSixAxisForceTorqueSensorMeasure(std::size_t sens_index, yarp::sig::Vector & out, double & timestamp) const
bool Jr3Mbed::getSixAxisForceTorqueSensorMeasure(std::size_t sens_index, yarp::sig::Vector & out, double & timestamp) const
{
out = canReadThreads[sens_index]->getMeasurements();
timestamp = yarp::os::SystemClock::nowSystem();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#ifndef __FORCE_TORQUE_CAN_HPP__
#define __FORCE_TORQUE_CAN_HPP__
#ifndef __JR3_MBED_HPP__
#define __JR3_MBED_HPP__

#include <vector>

Expand All @@ -16,22 +16,22 @@ namespace roboticslab

/**
* @ingroup YarpPlugins
* @defgroup ForceTorqueCan
* @brief Contains roboticslab::ForceTorqueCan.
* @defgroup Jr3Mbed
* @brief Contains roboticslab::Jr3Mbed.
*/

/**
* @ingroup ForceTorqueCan
* @brief Implementation of a CAN node that publishes data from a force-torque sensor.
* @ingroup Jr3Mbed
* @brief Implementation of a CAN node on an Mbed board that publishes data from a JR3 sensor.
*/
class ForceTorqueCan : public yarp::dev::DeviceDriver,
public yarp::dev::ISixAxisForceTorqueSensors
class Jr3Mbed : public yarp::dev::DeviceDriver,
public yarp::dev::ISixAxisForceTorqueSensors
{
public:
ForceTorqueCan()
Jr3Mbed()
{ }

~ForceTorqueCan() override
~Jr3Mbed() override
{ close(); }

// --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
Expand All @@ -52,4 +52,4 @@ class ForceTorqueCan : public yarp::dev::DeviceDriver,

} // namespace roboticslab

#endif // __FORCE_TORQUE_CAN_HPP__
#endif // __JR3_MBED_HPP__
3 changes: 3 additions & 0 deletions libraries/YarpPlugins/Jr3Mbed/LogComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "LogComponent.hpp"

YARP_LOG_COMPONENT(JR3M, "rl.Jr3Mbed")
8 changes: 8 additions & 0 deletions libraries/YarpPlugins/Jr3Mbed/LogComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __JR3_MBED_LOG_COMPONENT_HPP__
#define __JR3_MBED_LOG_COMPONENT_HPP__

#include <yarp/os/LogComponent.h>

YARP_DECLARE_LOG_COMPONENT(JR3M)

#endif // __JR3_MBED_LOG_COMPONENT_HPP__
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# ForceTorqueCan
# Jr3Mbed

The firmware this device interfaces with is located at: https://github.com/roboticslab-uc3m/jr3-mbed-firmware.

0 comments on commit 40990d7

Please sign in to comment.