Skip to content

Commit

Permalink
Update documentation and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
drdanz committed May 8, 2018
1 parent d2b5e5d commit 928e2a4
Show file tree
Hide file tree
Showing 71 changed files with 239 additions and 244 deletions.
4 changes: 2 additions & 2 deletions doc/note_devices.dox
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public:
virtual bool open(yarp::os::Searchable& config) {
// extract width and height configuration, if present
// otherwise use 128x128
int desiredWidth = config.check("w",Value(128)).asInt();
int desiredHeight = config.check("h",Value(128)).asInt();
int desiredWidth = config.check("w",Value(128)).asInt32();
int desiredHeight = config.check("h",Value(128)).asInt32();
return open(desiredWidth,desiredHeight);
}

Expand Down
28 changes: 14 additions & 14 deletions doc/port_expert.dox
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public:
NetInt32 x;
NetInt32 y;
Target() {
tag = BOTTLE_TAG_LIST + BOTTLE_TAG_INT;
tag = BOTTLE_TAG_LIST + BOTTLE_TAG_INT32;
len = 2;
}
};
Expand All @@ -348,13 +348,13 @@ public:
int x;
int y;
virtual bool write(ConnectionWriter& connection) {
connection.appendInt(x);
connection.appendInt(y);
connection.appendInt32(x);
connection.appendInt32(y);
return true;
}
virtual bool read(ConnectionReader& connection) {
x = connection.expectInt();
y = connection.expectInt();
x = connection.expectInt32();
y = connection.expectInt32();
return !connection.isError();
}
};
Expand All @@ -377,10 +377,10 @@ rpc"), or a web-browser, etc. For example, we could make Target's
write method be:
\code
virtual bool write(ConnectionWriter& connection) {
connection.appendInt(BOTTLE_TAG_LIST+BOTTLE_TAG_INT);
connection.appendInt(2); // two elements
connection.appendInt(x);
connection.appendInt(y);
connection.appendInt32(BOTTLE_TAG_LIST+BOTTLE_TAG_INT32);
connection.appendInt32(2); // two elements
connection.appendInt32(x);
connection.appendInt32(y);
connection.convertTextMode(); // if connection is text-mode, convert!
return true;
}
Expand All @@ -398,12 +398,12 @@ The corresponding read method would be:
\code
virtual bool read(ConnectionReader& connection) {
connection.convertTextMode(); // if connection is text-mode, convert!
int tag = connection.expectInt();
if (tag!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT) return false;
int ct = connection.expectInt();
int tag = connection.expectInt32();
if (tag!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT32) return false;
int ct = connection.expectInt32();
if (ct!=2) return false;
x = connection.expectInt();
y = connection.expectInt();
x = connection.expectInt32();
y = connection.expectInt32();
return !connection.isError();
}
\endcode
Expand Down
2 changes: 1 addition & 1 deletion doc/port_monitor/coder_decoder.dox
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Notice that codec.lua acts as coder or decoder depending to which side of the co
<span style="color:#00b418">-- @return Boolean</span>
<span style="color:#00b418">--</span>
PortMonitor.create <span style="color:#0100b6;font-weight:700">=</span> <span style="color:#0100b6;font-weight:700">function</span>(options)
isCoder <span style="color:#0100b6;font-weight:700">=</span> (options:find(<span style="color:#d80800">"sender_side"</span>):asInt() <span style="color:#0100b6;font-weight:700">==</span> <span style="color:#cd0000;font-style:italic">1</span>)
isCoder <span style="color:#0100b6;font-weight:700">=</span> (options:find(<span style="color:#d80800">"sender_side"</span>):asInt32() <span style="color:#0100b6;font-weight:700">==</span> <span style="color:#cd0000;font-style:italic">1</span>)
<span style="color:#0100b6;font-weight:700">if</span> isCoder <span style="color:#0100b6;font-weight:700">==</span> <span style="color:#585cf6;font-style:italic">true</span> <span style="color:#0100b6;font-weight:700">then</span>
<span style="color:#3c4c72;font-weight:700">print</span>(<span style="color:#d80800">"codec.lua: I will encode whatever i get!"</span>)
<span style="color:#0100b6;font-weight:700">else</span>
Expand Down
24 changes: 12 additions & 12 deletions doc/port_monitor/image_modification.dox
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ PortMonitor.setparam <span style="color:#0100b6;font-weight:700">=</span> <span
bt <span style="color:#0100b6;font-weight:700">=</span> property:findGroup(<span style="color:#d80800">"bg"</span>, <span style="color:#d80800">"background color"</span>)
<span style="color:#0100b6;font-weight:700">if</span> bt:isNull() <span style="color:#0100b6;font-weight:700">~=</span> <span style="color:#585cf6;font-style:italic">true</span> <span style="color:#0100b6;font-weight:700">then</span>
<span style="color:#0100b6;font-weight:700">if</span> bt:size() <span style="color:#0100b6;font-weight:700">>=</span><span style="color:#cd0000;font-style:italic">4</span> <span style="color:#0100b6;font-weight:700">then</span>
PortMonitor.bg.r <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt()
PortMonitor.bg.g <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">2</span>):asInt()
PortMonitor.bg.b <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">3</span>):asInt()
PortMonitor.bg.r <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt32()
PortMonitor.bg.g <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">2</span>):asInt32()
PortMonitor.bg.b <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">3</span>):asInt32()
<span style="color:#0100b6;font-weight:700">end</span>
<span style="color:#0100b6;font-weight:700">end</span>
bt <span style="color:#0100b6;font-weight:700">=</span> property:findGroup(<span style="color:#d80800">"fg"</span>, <span style="color:#d80800">"forground color"</span>)
<span style="color:#0100b6;font-weight:700">if</span> bt:isNull() <span style="color:#0100b6;font-weight:700">~=</span> <span style="color:#585cf6;font-style:italic">true</span> <span style="color:#0100b6;font-weight:700">then</span>
<span style="color:#0100b6;font-weight:700">if</span> bt:size() <span style="color:#0100b6;font-weight:700">>=</span><span style="color:#cd0000;font-style:italic">4</span> <span style="color:#0100b6;font-weight:700">then</span>
PortMonitor.fg.r <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt()
PortMonitor.fg.g <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">2</span>):asInt()
PortMonitor.fg.b <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">3</span>):asInt()
PortMonitor.fg.r <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt32()
PortMonitor.fg.g <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">2</span>):asInt32()
PortMonitor.fg.b <span style="color:#0100b6;font-weight:700">=</span> bt:get(<span style="color:#cd0000;font-style:italic">3</span>):asInt32()
<span style="color:#0100b6;font-weight:700">end</span>
<span style="color:#0100b6;font-weight:700">end</span>
<span style="color:#0100b6;font-weight:700">end</span>
Expand All @@ -171,14 +171,14 @@ PortMonitor.getparam <span style="color:#0100b6;font-weight:700">=</span> <span
bt <span style="color:#0100b6;font-weight:700">=</span> yarp.Bottle()
bg <span style="color:#0100b6;font-weight:700">=</span> bt:addList()
bg:addString(<span style="color:#d80800">"bg"</span>)
bg:addInt(PortMonitor.bg.r)
bg:addInt(PortMonitor.bg.g)
bg:addInt(PortMonitor.bg.b)
bg:addInt32(PortMonitor.bg.r)
bg:addInt32(PortMonitor.bg.g)
bg:addInt32(PortMonitor.bg.b)
fg <span style="color:#0100b6;font-weight:700">=</span> bt:addList()
fg:addString(<span style="color:#d80800">"fg"</span>)
fg:addInt(PortMonitor.fg.r)
fg:addInt(PortMonitor.fg.g)
fg:addInt(PortMonitor.fg.b)
fg:addInt32(PortMonitor.fg.r)
fg:addInt32(PortMonitor.fg.g)
fg:addInt32(PortMonitor.fg.b)
property:fromString(bt:toString())
<span style="color:#0100b6;font-weight:700">return</span> property
<span style="color:#0100b6;font-weight:700">end</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/port_monitor/type_modification.dox
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ PortMonitor.update <span style="color:#0100b6;font-weight:700">=</span> <span st
bt <span style="color:#0100b6;font-weight:700">=</span> thing:asBottle()
th <span style="color:#0100b6;font-weight:700">=</span> yarp.Things()
vec <span style="color:#0100b6;font-weight:700">=</span> yarp.Vector()
<span style="color:#0100b6;font-weight:700">for</span> i<span style="color:#0100b6;font-weight:700">=</span><span style="color:#cd0000;font-style:italic">1</span>,bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt() <span style="color:#0100b6;font-weight:700">do</span>
<span style="color:#0100b6;font-weight:700">for</span> i<span style="color:#0100b6;font-weight:700">=</span><span style="color:#cd0000;font-style:italic">1</span>,bt:get(<span style="color:#cd0000;font-style:italic">1</span>):asInt32() <span style="color:#0100b6;font-weight:700">do</span>
vec:push_back(<span style="color:#3c4c72;font-weight:700">math.random</span>())
<span style="color:#0100b6;font-weight:700">end</span>
th:setPortWriter(vec)
Expand Down
2 changes: 1 addition & 1 deletion doc/resource_finder_basic.dox
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This creates an instance of the ResourceFinder, and configures it using data fro
\code
ConstString robotName=rf.find("robot").asString();
ConstString partName=rf.find("part").asString();
int joint=rf.find("joint").asInt();
int joint=rf.find("joint").asInt32();

cout<<"Running with:"<<endl;
cout<<"robot: "<<robotName.c_str()<<endl;
Expand Down
9 changes: 2 additions & 7 deletions doc/yarp_build_structure.dox
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,10 @@ will affect the implementation of the yarp::os::NetInt32 type.
On little endian systems, NetInt32 maps straight onto native integers.
On big endian systems, NetInt32 is a class that simulates little endian
integers.
\li We figure out an appropriate native type for 16-bit integers,
32-bit integers, and 64-bit floating point numbers. The types are stored
in YARP_INT16, YARP_INT32, and YARP_FLOAT64 respectively.
\li If the YARP_ADMIN environment flag is set, we turn on some more
aggressive warnings and errors in the compiler. YARP developers should
generally have this flag set if possible.
\li We define YARP_PRESENT for compilation. This definition is unused.
\li We define BUILDING_YARP for compilation.
\li We define _REENTRANT, for thread-safe C library calls.
\li Compiler flags that may also be needed by users are recorded in a
global property "YARP_DEFS" for later export.
Expand Down Expand Up @@ -536,9 +533,7 @@ configuration.
It is placed in <CMAKE_BINARY_DIR>/src/conf/libYARP_conf/include/yarp/conf/system.h,
and should be accessed as "#include <yarp/conf/system.h>".
It is intended to store some facts about the system upon which YARP
is built: the types YARP_INT32, YARP_INT16, YARP_FLOAT64,
whether the system is big- or little-endian, and whether to use ACE strings
or STL strings
is built: whether the system is big- or little-endian.
\sa \ref yarp_build_structure_conf
\sa \ref yarp_build_structure_system_check

Expand Down
10 changes: 5 additions & 5 deletions doc/yarp_config_files.dox
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ yarp::os::Property::find to get the second element of a group directly.
It returns a yarp::os::Value object which can easily be converted to
regular C types.
\code
prop.find("width").asInt() // gives the int 10
prop.find("height").asInt() // gives the int 15
prop.find("width").asInt32() // gives the int 10
prop.find("height").asInt32() // gives the int 15
\endcode

\section yarp_config_file_add_section A config file with sections
Expand All @@ -99,7 +99,7 @@ the Property object we read in code will now contain the
two groups "SIZE" and "APPEARANCE", which will have "width", "height",
and "color" nested within them. In other words:
\code
prop.findGroup("SIZE").find("width").asInt() // gives 10
prop.findGroup("SIZE").find("width").asInt32() // gives 10
prop.findGroup("APPEARANCE").find("color").asString() // gives "red"
\endcode

Expand Down Expand Up @@ -357,8 +357,8 @@ And the program is called with these arguments:
\endverbatim
In this case, we get:
\code
prop.find("width").asInt() // gives the int 200
prop.find("height").asInt() // gives the int 15
prop.find("width").asInt32() // gives the int 200
prop.find("height").asInt32() // gives the int 15
\endcode
This can be handy to override one or two values in a long config file
without needing to copy it and modify it. One wrinkle remains -- how
Expand Down
4 changes: 2 additions & 2 deletions doc/yarp_with_ros_parameters.dox
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ From code, you could use a Bottle:
cmd.addString("setParam");
cmd.addString("/demo");
cmd.addString("foo");
cmd.addInt(15);
cmd.addInt32(15);
Network::write(ros,cmd,reply);
printf("reply to setParam is: %s\n", reply.toString().c_str());

Expand All @@ -39,7 +39,7 @@ From code, you could use a Bottle:
cmd.addString("foo");
Network::write(ros,cmd,reply);
printf("reply to getParam is: %s\n", reply.toString().c_str());
printf("Stored value is hopefully %d\n", reply.get(2).asInt());
printf("Stored value is hopefully %d\n", reply.get(2).asInt32());
return 0;
\endcode

Expand Down
8 changes: 4 additions & 4 deletions example/bottle/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {

Bottle b2;
b2.addString("height");
b2.addInt(15);
b2.addInt32(15);
printf("Bottle b2 is: %s\n", b2.toString().c_str());
// should give: height 15

Expand All @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
// should give: (color red) (height 15)

printf("color check: %s\n", b3.find("color").asString().c_str());
printf("height check: %d\n", b3.find("height").asInt());
printf("height check: %d\n", b3.find("height").asInt32());

Bottle b4;
b4.addString("nested");
Expand All @@ -55,13 +55,13 @@ int main(int argc, char *argv[]) {
printf("Bottle b6 is: %s\n", b6.toString().c_str());
// should give: (pos left top) (size 10) (nested ((color red) (height 5))

printf("size check: %d\n", b6.find("size").asInt());
printf("size check: %d\n", b6.find("size").asInt32());
printf("pos check: %s\n", b6.find("pos").asString().c_str());
// find assumes key->value pairs; for lists, use findGroup
printf("pos group check: %s\n", b6.findGroup("pos").toString().c_str());
// see documentation for Bottle::findGroup
printf("nested check: %s\n", b6.find("nested").toString().c_str());
printf("nested height check: %d\n", b6.find("nested").find("height").asInt());
printf("nested height check: %d\n", b6.find("nested").find("height").asInt32());


printf("\n");
Expand Down
2 changes: 1 addition & 1 deletion example/cmake/hello/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
Bottle&out = outPort.prepare();
out.clear();
out.addString("Hello");
out.addInt(i);
out.addInt32(i);
printf("Sending %s\n", out.toString().c_str());

// send the message
Expand Down
4 changes: 2 additions & 2 deletions example/dev/FakeFrameGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class FakeFrameGrabber : public yarp::dev::IFrameGrabberImage,
virtual bool open(yarp::os::Searchable& config) {
// extract width and height configuration, if present
// otherwise use 128x128
int desiredWidth = config.check("w",yarp::os::Value(128)).asInt();
int desiredHeight = config.check("h",yarp::os::Value(128)).asInt();
int desiredWidth = config.check("w",yarp::os::Value(128)).asInt32();
int desiredHeight = config.check("h",yarp::os::Value(128)).asInt32();
return open(desiredWidth,desiredHeight);
}

Expand Down
4 changes: 2 additions & 2 deletions example/dev/FakeFrameGrabber2.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class FakeFrameGrabber : public yarp::dev::IFrameGrabberImage,
virtual bool open(yarp::os::Searchable& config) {
// extract width and height configuration, if present
// otherwise use 128x128
int desiredWidth = config.check("w",yarp::os::Value(128)).asInt();
int desiredHeight = config.check("h",yarp::os::Value(128)).asInt();
int desiredWidth = config.check("w",yarp::os::Value(128)).asInt32();
int desiredHeight = config.check("h",yarp::os::Value(128)).asInt32();
return open(desiredWidth,desiredHeight);
}

Expand Down
4 changes: 2 additions & 2 deletions example/dev/FileFrameGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class FileFrameGrabber : public yarp::dev::IFrameGrabberImage,
virtual bool open(yarp::os::Searchable& config) {
yarp::os::ConstString pattern =
config.check("pattern",yarp::os::Value("%d.ppm")).asString();
int first = config.check("first",yarp::os::Value(0)).asInt();
int last = config.check("last",yarp::os::Value(-1)).asInt();
int first = config.check("first",yarp::os::Value(0)).asInt32();
int last = config.check("last",yarp::os::Value(-1)).asInt32();
return open(pattern.c_str(),first,last);
}

Expand Down
2 changes: 1 addition & 1 deletion example/dev/motortest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) {
options.put("device", "SerialServoBoard");
options.put("board", config.check("board", yarp::os::Value("ssc32")).asString().c_str());
options.put("comport", config.check("comport", yarp::os::Value("/dev/ttyS0")).asString().c_str());
options.put("baudrate", config.check("baudrate", yarp::os::Value(38400)).asInt());
options.put("baudrate", config.check("baudrate", yarp::os::Value(38400)).asInt32());


PolyDriver dd(options);
Expand Down
Loading

0 comments on commit 928e2a4

Please sign in to comment.