Skip to content

Commit

Permalink
Merge branch 'unbreak-yarp-devel' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed May 17, 2018
2 parents cbea5ad + 4d50a6f commit e28a984
Show file tree
Hide file tree
Showing 54 changed files with 1,106 additions and 3,562 deletions.
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ set_property(GLOBAL PROPERTY ROBOTICSLAB_YARP_DEVICES_TARGETS)
include(CMakeDependentOption)

# Find YARP (main dependency).
find_package(YARP REQUIRED)

# Load YARP modules.
if(YARP_VERSION_SHORT VERSION_LESS 2.3.70)
list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})
include(YarpPlugin)
include(YarpInstallationHelpers)
endif()
find_package(YARP 2.3.70 REQUIRED)

# Configure installation paths for YARP resources.
yarp_configure_external_installation(roboticslab-yarp-devices WITH_PLUGINS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ make -j3
#include <stdio.h>
#include <stdlib.h>

#include <vector>

#include <yarp/os/all.h>
#include <yarp/dev/all.h>

Expand Down Expand Up @@ -61,10 +63,10 @@ int main(int argc, char *argv[]) {
return 1;
}

IPositionControl *pos;
IVelocityControl *vel;
IEncoders *enc;
IControlMode *mode;
IPositionControl2 *pos;
IVelocityControl2 *vel;
IEncodersTimed *enc;
IControlMode2 *mode;

bool ok = true;
ok &= dd.view(pos);
Expand All @@ -80,17 +82,17 @@ int main(int argc, char *argv[]) {
int axes;
pos->getAxes(&axes);

for (unsigned int i = 0; i < axes; i++)
mode->setPositionMode(i);
std::vector<int> posModes(axes, VOCAB_CM_POSITION);
mode->setControlModes(posModes.data());

printf("test positionMove(1,35)\n");
pos->positionMove(1, 35);

printf("Delaying 5 seconds...\n");
Time::delay(5);

for (unsigned int i = 0; i < axes; i++)
mode->setVelocityMode(i);
std::vector<int> velModes(axes, VOCAB_CM_VELOCITY);
mode->setControlModes(velModes.data());

printf("test velocityMove(0,10)\n");
vel->velocityMove(0,10);
Expand All @@ -102,5 +104,3 @@ int main(int argc, char *argv[]) {

return 0;
}


4 changes: 2 additions & 2 deletions examples/cpp/exampleTechnosoftIpos/exampleTechnosoftIpos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int main(int argc, char *argv[])
}
else std::printf("[success] Viewing IVelocityControlRaw.\n");

yarp::dev::IControlModeRaw *mode;
yarp::dev::IControlMode2Raw *mode;
ok = dd.view(mode);
if (!ok)
{
Expand All @@ -146,7 +146,7 @@ int main(int argc, char *argv[])
iCanBusSharer->enable();

//-- Commands on TechnosoftIpos.
ok = mode->setPositionModeRaw(0);
ok = mode->setControlModeRaw(0, VOCAB_CM_POSITION);
if (!ok)
{
std::printf("[error] Problems in setPositionModeRaw.\n");
Expand Down
200 changes: 101 additions & 99 deletions examples/matlab/testRemoteRaveBot.m
Original file line number Diff line number Diff line change
@@ -1,99 +1,101 @@
% MATLAB example

%> @ingroup asibot_examples_m
%> \defgroup testRemoteRaveBotM testRemoteRaveBot.m
%>
%> @brief This example connects to a running \ref testRaveBot or \ref cartesianServer module to move in Joint space.
%>
%> <b>Legal</b>
%>
%> Copyright: (C) 2012 Universidad Carlos III de Madrid
%>
%> Author: Juan G Victores
%>
%> CopyPolicy: Released under the terms of the LGPLv2.1 or later, see license/LGPL.TXT
%>
%> <b>Running</b> (assuming correct installation)
%>
%> From within MATLAB, navigate to the ASIBOT MATLAB examples path and run the program:
%>
%>\verbatim [MATLAB console] testRemoteRaveBot.m \endverbatim
%> <b>Modify</b>
%>
%> This file can be edited at repos/asibot-main/example/matlab/testRemoteRaveBot.m
%>

disp 'WARNING: requires a running instance of RaveBot (i.e. testRaveBot or cartesianServer)'

LoadYarp(); % imports YARP and connects to YARP network

options = yarp.Property(); % create an instance of Property, a nice YARP class for storing name-value (key-value) pairs
options.put('device','remote_controlboard'); % we add a name-value pair that indicates the YARP device
options.put('remote','/ravebot'); % we add info on to whom we will connect
options.put('local','/matlab'); % we add info on how we will call ourselves on the YARP network

dd = yarp.PolyDriver(options); % create a YARP multi-use driver with the given options
if isequal(dd.isValid(),1)
disp '[success] robot available';
else
disp '[warning] robot NOT available, does it exist?';
end

pos = dd.viewIPositionControl(); % make a position controller object we call 'pos'
if isequal(pos,[])
disp '[warning] position interface NOT available, does it exist?';
else
disp '[success] position interface available';
end

vel = dd.viewIVelocityControl(); % make a velocity controller object we call 'vel'
if isequal(vel,[])
disp '[warning] velocity interface NOT available, does it exist?';
else
disp '[success] velocity interface available';
end

enc = dd.viewIEncoders(); % make an encoder controller object we call 'enc'
if isequal(enc,[])
disp '[warning] encoder interface NOT available, does it exist?';
else
disp '[success] encoder interface available';
end

mode = dd.viewIControlMode(); % make a mode controller object we call 'mode'
if isequal(mode,[])
disp '[warning] control mode interface NOT available, does it exist?';
else
disp '[success] control mode interface available';
end

axes = enc.getAxes();
for i = 1:axes
mode.setPositionMode(i-1); % use the object to set the device to position mode (as opposed to velocity mode) (note: stops the robot)
end

disp 'test positionMove(1,35) -> moves motor 1 (start count at motor 0) to 35 degrees';
pos.positionMove(1,35);

disp 'test delay(5)';
yarp.Time.delay(5);

v = yarp.DVector(axes); % create a YARP vector of doubles the size of the number of elements read by enc, call it 'v'
enc.getEncoders(v); % read the encoder values and put them into 'v'
disp (strcat('v[1] is: ',num2str(v.get(1)))); % print element 1 of 'v', note that motors and encoders start at 0

for i = 1:axes
mode.setVelocityMode(i-1); % use the object to set the device to velocity mode (as opposed to position mode)
end

disp 'test velocityMove(0,10) -> moves motor 0 (start count at motor 0) at 10 degrees per second';
vel.velocityMove(0,10);

disp 'test delay(5)';
yarp.Time.delay(5);

vel.velocityMove(0,0);
dd.close();
disp 'bye!';
yarp.Network.fini(); % disconnect from the YARP network

% MATLAB example

%> @ingroup asibot_examples_m
%> \defgroup testRemoteRaveBotM testRemoteRaveBot.m
%>
%> @brief This example connects to a running \ref testRaveBot or \ref cartesianServer module to move in Joint space.
%>
%> <b>Requires YARP 2.3.72.</b>
%>
%> <b>Legal</b>
%>
%> Copyright: (C) 2012 Universidad Carlos III de Madrid
%>
%> Author: Juan G Victores
%>
%> CopyPolicy: Released under the terms of the LGPLv2.1 or later, see license/LGPL.TXT
%>
%> <b>Running</b> (assuming correct installation)
%>
%> From within MATLAB, navigate to the ASIBOT MATLAB examples path and run the program:
%>
%>\verbatim [MATLAB console] testRemoteRaveBot.m \endverbatim
%> <b>Modify</b>
%>
%> This file can be edited at repos/asibot-main/example/matlab/testRemoteRaveBot.m
%>

disp 'WARNING: requires a running instance of RaveBot (i.e. testRaveBot or cartesianServer)'

LoadYarp(); % imports YARP and connects to YARP network

options = yarp.Property(); % create an instance of Property, a nice YARP class for storing name-value (key-value) pairs
options.put('device','remote_controlboard'); % we add a name-value pair that indicates the YARP device
options.put('remote','/ravebot'); % we add info on to whom we will connect
options.put('local','/matlab'); % we add info on how we will call ourselves on the YARP network

dd = yarp.PolyDriver(options); % create a YARP multi-use driver with the given options
if isequal(dd.isValid(),1)
disp '[success] robot available';
else
disp '[warning] robot NOT available, does it exist?';
end

pos = dd.viewIPositionControl(); % make a position controller object we call 'pos'
if isequal(pos,[])
disp '[warning] position interface NOT available, does it exist?';
else
disp '[success] position interface available';
end

vel = dd.viewIVelocityControl(); % make a velocity controller object we call 'vel'
if isequal(vel,[])
disp '[warning] velocity interface NOT available, does it exist?';
else
disp '[success] velocity interface available';
end

enc = dd.viewIEncoders(); % make an encoder controller object we call 'enc'
if isequal(enc,[])
disp '[warning] encoder interface NOT available, does it exist?';
else
disp '[success] encoder interface available';
end

mode = dd.viewIControlMode(); % make a mode controller object we call 'mode'
if isequal(mode,[])
disp '[warning] control mode interface NOT available, does it exist?';
else
disp '[success] control mode interface available';
end

axes = enc.getAxes();
for i = 1:axes
mode.setControlMode(i-1, yarp.Vocab_encode('pos')); % use the object to set the device to position mode (as opposed to velocity mode) (note: stops the robot)
end

disp 'test positionMove(1,35) -> moves motor 1 (start count at motor 0) to 35 degrees';
pos.positionMove(1,35);

disp 'test delay(5)';
yarp.Time.delay(5);

v = yarp.DVector(axes); % create a YARP vector of doubles the size of the number of elements read by enc, call it 'v'
enc.getEncoders(v); % read the encoder values and put them into 'v'
disp (strcat('v[1] is: ',num2str(v.get(1)))); % print element 1 of 'v', note that motors and encoders start at 0

for i = 1:axes
mode.setControlMode(i-1, yarp.Vocab_encode('vel')); % use the object to set the device to velocity mode (as opposed to position mode)
end

disp 'test velocityMove(0,10) -> moves motor 0 (start count at motor 0) at 10 degrees per second';
vel.velocityMove(0,10);

disp 'test delay(5)';
yarp.Time.delay(5);

vel.velocityMove(0,0);
dd.close();
disp 'bye!';
yarp.Network.fini(); % disconnect from the YARP network

10 changes: 5 additions & 5 deletions examples/python/exampleRemoteControlboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
# This example connects to a running \ref controlboardWrapper to move in Joint space.
#
# <b>Requires YARP 2.3.72.</b>
#
# <b>Legal</b>
#
# Copyright: (C) 2017 Universidad Carlos III de Madrid
Expand Down Expand Up @@ -47,14 +49,13 @@
pos = dd.viewIPositionControl() # make a position controller object we call 'pos'
vel = dd.viewIVelocityControl() # make a velocity controller object we call 'vel'
enc = dd.viewIEncoders() # make an encoder controller object we call 'enc'
mode = dd.viewIControlMode() # make a operation mode controller object we call 'mode'
mode = dd.viewIControlMode2() # make a operation mode controller object we call 'mode'
ll = dd.viewIControlLimits() # make a limits controller object we call 'll'

axes = enc.getAxes() # retrieve number of joints

# use the object to set the device to position mode (as opposed to velocity mode)(note: stops the robot)
for j in range(axes):
mode.setPositionMode(j)
mode.setControlModes(yarp.IVector(axes, yarp.Vocab_encode('pos')))

print 'test positionMove(1,-35) -> moves motor 1 (start count at motor 0) to -35 degrees'
pos.positionMove(1,-35)
Expand All @@ -71,8 +72,7 @@
ll.getLimits(0,min,max)

# use the object to set the device to velocity mode (as opposed to position mode)
for j in range(axes):
mode.setVelocityMode(j)
mode.setControlModes(yarp.IVector(axes, yarp.Vocab_encode('vel')))

print 'test velocityMove(0,10) -> moves motor 0 (start count at motor 0) at 10 degrees per second'
vel.velocityMove(0,10)
Expand Down
Loading

0 comments on commit e28a984

Please sign in to comment.