Skip to content

Commit

Permalink
Working on examples
Browse files Browse the repository at this point in the history
git-svn-id: http://web.barrett.com/svn/btclient/trunk@379 3eb8b4e9-0710-d544-b5f2-d3973d62577e
  • Loading branch information
bz committed Oct 4, 2007
1 parent 5316104 commit b58ba90
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 277 deletions.
9 changes: 8 additions & 1 deletion doc/readme.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
This directory is for documentation.

(This file is really so tar won't optimize out this directory)
To generate the source code documentation, use doxygen:
http://www.stack.nl/~dimitri/doxygen/

If you want doxygen to generate nifty code-relationship visual
graphs (optional), install graphviz:
http://www.graphviz.org/

Point doxygen to the ../src/config.dox and let it run!
9 changes: 9 additions & 0 deletions examples/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This is the 'examples' directory.

Start by reviewing Example 1 (ex1). It documents the basic structure of a WAM
program. Later examples build on ex1's structure, but their comments serve to
highlight the particular features being presented instead of repeating the
description of the program structure.

Happy coding!

2 changes: 1 addition & 1 deletion examples/ex1-jointposition/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int main(int argc, char **argv)
printf("\nPress Ctrl-C to exit...\n");
while(1) {
/* Display the WAM's joint angles on-screen (see **NOTE below) */
printf("\rPosition = %s\t",sprint_vn(buf,(vect_n*)wam->Jpos));
printf("\rPosition (rad) = %s\t",sprint_vn(buf,(vect_n*)wam->Jpos));
fflush(stdout);
usleep(100000); // Wait a moment
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ex2-gcomp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int main(int argc, char **argv)

/* Spin off the RT task to set up the CAN Bus */
startDone = FALSE;
btrt_thread_create(&rt_thd,"rtt", 45, (void*)rt_thread, NULL);
btrt_thread_create(&rt_thd, "rtt", 45, (void*)rt_thread, NULL);
while(!startDone)
usleep(10000);

Expand All @@ -189,9 +189,9 @@ int main(int argc, char **argv)
line = 2;

mvprintw(line, 0, "Robot name = %s Degrees of Freedom = %d", wam->name, wam->dof); line += 2;
mvprintw(line, 0, "Joint Position: %s", sprint_vn(buf, wam->Jpos)); ++line;
mvprintw(line, 0, "Joint Torque : %s", sprint_vn(buf, wam->Jtrq)); ++line;
mvprintw(line, 0, "Cartesian XYZ : %s", sprint_vn(buf, (vect_n*)wam->Cpos)); ++line;
mvprintw(line, 0, "Joint Position (rad): %s", sprint_vn(buf, wam->Jpos)); ++line;
mvprintw(line, 0, "Joint Torque (Nm) : %s", sprint_vn(buf, wam->Jtrq)); ++line;
mvprintw(line, 0, "Cartesian XYZ (m) : %s", sprint_vn(buf, (vect_n*)wam->Cpos)); ++line;
mvprintw(line, 0, "Jacobian Matrix\n%s", sprint_mn(buf, wam->robot.J)); line += 7;
mvprintw(line, 0, "Mass Matrix\n%s", sprint_mn(buf, wam->robot.M)); line += wam->dof + 1;

Expand Down
22 changes: 13 additions & 9 deletions examples/ex3-datalogging/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
*==============================*/
#include "btwam.h"

/*==============================*
* PRIVATE DEFINED constants *
*==============================*/
/* Define the control loop period */
#define Ts (0.002)

/*==============================*
Expand Down Expand Up @@ -231,8 +235,11 @@ int main(int argc, char **argv)
while(!startDone)
usleep(10000);

/* Register the control loop's local callback routine */
registerWAMcallback(wam, WAMcallback);

/* Initialize a WAM state evaluator */
init_state_btg(&pstate, Ts , 30.0);
init_state_btg(&pstate, Ts, 30.0);

/* Commanded Cartesian forces and torques are applied about Cpoint, which is
* defined as an offset from the kinematic endpoint of the robot.
Expand Down Expand Up @@ -279,9 +286,6 @@ int main(int argc, char **argv)
while(getch()==ERR)
usleep(5000);

/* Register the control loop's local callback routine */
registerWAMcallback(wam, WAMcallback);

/* Clear the screen (ncurses) */
clear(); refresh();

Expand All @@ -298,11 +302,11 @@ int main(int argc, char **argv)
line = 2;

mvprintw(line, 0, "Robot name = %s Degrees of Freedom = %d", wam->name, wam->dof); line += 2;
mvprintw(line, 0, "Joint Position (m) : %s", sprint_vn(buf, wam->Jpos)); ++line;
mvprintw(line, 0, "Joint Torque (Nm) : %s", sprint_vn(buf, wam->Jtrq)); ++line;
mvprintw(line, 0, "Cartesian XYZ (m) : %s", sprint_vn(buf, (vect_n*)wam->Cpos)); ++line;
mvprintw(line, 0, "Cartesian Force (N): %s", sprint_vn(buf, (vect_n*)wam->Cforce)); ++line;
mvprintw(line, 0, "Callback Time (ns) : %ld", callbackTime); ++line;
mvprintw(line, 0, "Joint Position (rad): %s", sprint_vn(buf, wam->Jpos)); ++line;
mvprintw(line, 0, "Joint Torque (Nm) : %s", sprint_vn(buf, wam->Jtrq)); ++line;
mvprintw(line, 0, "Cartesian XYZ (m) : %s", sprint_vn(buf, (vect_n*)wam->Cpos)); ++line;
mvprintw(line, 0, "Cartesian Force (N) : %s", sprint_vn(buf, (vect_n*)wam->Cforce)); ++line;
mvprintw(line, 0, "Callback Time (ns) : %ld", callbackTime); ++line;

++line;
mvprintw(line, 0, "To exit, press Shift-Idle on pendant, then hit Ctrl-C");
Expand Down
28 changes: 17 additions & 11 deletions examples/ex4-haptics/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
OBJS = main.o
TARG = ex4
CC = gcc
PATH_INCLUDE = -I/usr/realtime/include -I../../include

CFLAGS = -g -DUSE_RTAI31 -static ${PATH_INCLUDE}
#CFLAGS = -g -DUSE_RTAI31 -static ${PATH_INCLUDE} -DBTOLDCONFIG
### Makefile for Barrett Software (examples)

LDFLAGS = -L/usr/realtime/lib -L/usr/lib -L../../lib -lpthread -llxrt \
-lncurses -lm -lbtwam -lbtsystem -lntcan
# Be sure to edit config.mk to match your installation
include ../../config.mk
include ../../common.mk

OBJS = main.o
TARG = ex4

# Done with defines, now for the real work
default: ex4

ex4: ${OBJS}
$(CC) -o ${TARG} ${OBJS} ${LDFLAGS}

clean:
clean:
rm *.o ${TARG}

system:
$(MAKE) -C ../../src/btsystem lib
$(MAKE) -C ../../src/btsystem install

wam:
$(MAKE) -C ../../src/btwam lib
$(MAKE) -C ../../src/btwam install

all: system wam ex4

Loading

0 comments on commit b58ba90

Please sign in to comment.