Skip to content

Commit

Permalink
Add --movi support (WiimoteSensor)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed May 16, 2019
1 parent b23dfec commit e4dc75b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion programs/streamingDeviceController/StreamingDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ StreamingDevice * StreamingDeviceFactory::makeDevice(const std::string & deviceN
}
else if (deviceName == "WiimoteSensor")
{
return new WiimoteSensorDevice(deviceConfig);
return new WiimoteSensorDevice(deviceConfig, usingMovi);
}
else
{
Expand Down
36 changes: 33 additions & 3 deletions programs/streamingDeviceController/WiimoteSensorDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

#include <ColorDebug.h>

roboticslab::WiimoteSensorDevice::WiimoteSensorDevice(yarp::os::Searchable & config, bool usingMovi)
: StreamingDevice(config),
iAnalogSensor(NULL),
mode(NONE),
usingMovi(usingMovi),
step(0.0)
{
data.resize(3); // already called by base constructor
buffer.resize(5);
step = config.check("step", yarp::os::Value(DEFAULT_STEP), "").asDouble();
}

bool roboticslab::WiimoteSensorDevice::acquireInterfaces()
{
bool ok = true;
Expand All @@ -22,12 +34,23 @@ bool roboticslab::WiimoteSensorDevice::acquireInterfaces()

bool roboticslab::WiimoteSensorDevice::initialize(bool usingStreamingPreset)
{
if (usingStreamingPreset && !iCartesianControl->setParameter(VOCAB_CC_CONFIG_STREAMING, VOCAB_CC_TWIST))
if (usingMovi && step <= 0.0)
{
CD_WARNING("Unable to preset streaming command.\n");
CD_WARNING("Invalid step: %f.\n", step);
return false;
}

if (usingStreamingPreset)
{
int cmd = usingMovi ? VOCAB_CC_MOVI : VOCAB_CC_TWIST;

if (!iCartesianControl->setParameter(VOCAB_CC_CONFIG_STREAMING, cmd))
{
CD_WARNING("Unable to preset streaming command.\n");
return false;
}
}

if (!iCartesianControl->setParameter(VOCAB_CC_CONFIG_FRAME, ICartesianSolver::TCP_FRAME))
{
CD_WARNING("Unable to set TCP reference frame.\n");
Expand Down Expand Up @@ -123,7 +146,14 @@ void roboticslab::WiimoteSensorDevice::sendMovementCommand()
return;
}

iCartesianControl->twist(xdot);
if (usingMovi)
{
iCartesianControl->movi(xdot);
}
else
{
iCartesianControl->twist(xdot);
}
}

void roboticslab::WiimoteSensorDevice::stopMotion()
Expand Down
12 changes: 2 additions & 10 deletions programs/streamingDeviceController/WiimoteSensorDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ class WiimoteSensorDevice : public StreamingDevice
public:

//! Constructor
WiimoteSensorDevice(yarp::os::Searchable & config)
: StreamingDevice(config),
iAnalogSensor(NULL),
mode(NONE),
step(0.0)
{
data.resize(3); // already called by base constructor
buffer.resize(5);
step = config.check("step", yarp::os::Value(DEFAULT_STEP), "").asDouble();
}
WiimoteSensorDevice(yarp::os::Searchable & config, bool usingMovi);

virtual bool acquireInterfaces();

Expand All @@ -59,6 +50,7 @@ class WiimoteSensorDevice : public StreamingDevice

std::vector<double> buffer;

bool usingMovi;
double step;
};

Expand Down

0 comments on commit e4dc75b

Please sign in to comment.