Author Topic: webbotlibs gait designer  (Read 2559 times)

0 Members and 1 Guest are viewing this topic.

Offline RifRafTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
webbotlibs gait designer
« on: January 26, 2013, 05:37:30 AM »
Hello, have been using webbotlibs for a week now with great success, considering I have very basic coding abilities.  Am a little puzzled as to the setup for the gait designer on the avr side. 

Have setup the code as best I could from reading the docs, the code compiles, can connect from gait designer and see data on the rx led, but no servos move, the 3 servos are on ports PB0 PB1 and PB2 of an atmega168 .

The project was setup with project designer but the uart was the only device i added, if i added the servos in project manager would not compile. can send test text stream from avr and see it in putty at 112500 baidrate. any advice would be welcome on how to debug it.

Code: [Select]
#define UART0_RX_BUFFER_SIZE 40
#include "hardware.h"
#include <Gait/GaitDesigner.h>
#include <servos.h>
#include <rprintf.h>
 
SERVO servo1 = MAKE_SERVO(false,B0,1500,650);
SERVO servo2 = MAKE_SERVO(false,B1,1500,650);
SERVO servo3 = MAKE_SERVO(false,B2,1500,650);
static SERVO_LIST PROGMEM bank1_list[] = {&servo1,&servo2,&servo3};
SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(bank1_list);
 
ACTUATOR_LIST PROGMEM all[] = {&servo1.actuator,&servo2.actuator,&servo3.actuator };

GAIT_DESIGNER gait = MAKE_GAIT_DESIGNER(all, UART0, (BAUD_RATE)115200);

void appInitHardware(void){
  servoPWMInit(&bank1);
  gaitDesignerInit(&gait);
  rprintfInit(&myUartSendByte);
}

// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
  gaitDesignerProcess(&gait);
  //rprintf("hello "); //to test loop is working
  return 0;
}

Offline RifRafTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: webbotlibs gait designer
« Reply #1 on: January 26, 2013, 04:19:37 PM »
ok so I must have been reading to much into it, let project manager do the servos instead, and had to refer to then as _servo1_ instead of servo1 etc.  This is the working code, this is gonna be so cool to use now.

Code: [Select]
#include "hardware.h"
#include <Gait/GaitDesigner.h>
// The gait designer however expects a single list of all the servos to be controlled
ACTUATOR_LIST PROGMEM all[] = {&_servo1_.actuator,&_servo2_.actuator,&_servo3_.actuator };

// create an object that is used to talk to the Gait Designer program on the computer
// specifying the list of all the servos and the uart and baud rate
GAIT_DESIGNER gait = MAKE_GAIT_DESIGNER(all, UART0, (BAUD_RATE)115200);

// Initialise the hardware
void appInitHardware(void) {
gaitDesignerInit(&gait);  //Start Gait Designer
initHardware();
}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
    gaitDesignerProcess(&gait);

return 0;
}

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: webbotlibs gait designer
« Reply #2 on: January 27, 2013, 10:42:17 AM »
Sounds like you've been successful?

I'm not sure what the underscores accomplish, but the 2nd version of your code looks fine.  It's a fun little setup :)
I

Offline RifRafTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: webbotlibs gait designer
« Reply #3 on: February 02, 2013, 03:21:37 PM »
Getlex yes is working great now thanks, no idea why but the underscores helped.  Have made a little arm to test with and having great time testing with it.

images of arm http://imagebin.org/245098  http://imagebin.org/245167 and a short video of it working with gait designer, 6 x sg90servo arm and gripper

What I cannot work out is how to extend the length of the animation past the default 6 seconds or so? 

Is this possible because once too many movements are added the servos have to move too fast in the time allowed if that makes sense.?  Shortening the animation as well for things that might just be closing a gripper would be cool too.


Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: webbotlibs gait designer
« Reply #4 on: February 04, 2013, 01:23:12 PM »
Looks good to me.

When you play the animation there is a DRIVE_SPEED parameter - this should change the duration of the animation. (Haven't looked back at my code for a while so please be patient if I'm wrong).
 
Don't forget that you can string animations together - ie have a different animation for closing the gripper, opening the gripper etc.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline RifRafTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: webbotlibs gait designer
« Reply #5 on: February 06, 2013, 02:22:38 AM »
hi Webbot, firstly thanks for some great libraries, lost interest with robots a few years back due to not being able to code well and returned to find these great libs, and going to learn to code this time too.

It appears the DRIVE_SPEED parameter is for gaitrunner and currently am limited to gait designer, the pc interface, as the code will not compile for gait runner (have posted this already in another thread so won't go on too much) have used all the default settings and not modified the exported gait file. 

Things will be much better when gait runner can be used standalone on the avr, looking forward to being able to call individual gaits and use them with input from sensors.  If you or anyone would have a working example of code that compiles with gait runner and the gait file should be able to see what I am doing wrong. 

Will have another go now and see how it goes

the current code that is not compiling

Code: [Select]
#include "hardware.h"
#include "sweep.h" //exported file from gait designer, is read only and have not modified
#include <Gait/GaitRunner.h>

ACTUATOR_LIST PROGMEM all[] = {&_servo1_.actuator,&_servo2_.actuator,&_servo3_.actuator,&_servo4_.actuator,&_servo5_.actuator,&_servo6_.actuator,&_servo7_.actuator };

//The first parameter is the ACTUATOR_LIST containing all of the servos you want to control.
//The second parameter is the list of possible animations in the gait file exported from Gait Designer. This is called 'animations' - unless you have modified the file by hand.
G8_RUNNER gait = MAKE_G8_RUNNER(all, animations);

void appInitHardware(void) {
gaitRunnerInit(&gait);
initHardware();
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    //gaitRunnerPlay(G8_RUNNER* runner, uint8_t animation, int16_t loopSpeed, DRIVE_SPEED speed, int16_t repeatCount
gaitRunnerPlay(&gait, 0, 1000, 100, 10);
return 0;
}

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
gaitRunnerProcess(&gait);
return 0;
}

with the errors..
MT gait.o -MF dep/gait.o.d -fno-threadsafe-statics -O0 -c -o gait.o gait.cpp
sweep.h:47: error: animations causes a section type conflict
sweep.h:43: error: frames_0 causes a section type conflict
sweep.h:21: error: limbs_0_0 causes a section type conflict
sweep.h:32: error: limbs_0_1 causes a section type conflict
make: *** [gait.o] Error 1

line 47 of sweep.h is..
Code: [Select]
const PROGMEM G8_ANIMATION PROGMEM animations[1] = {


Offline RifRafTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: webbotlibs gait designer
« Reply #6 on: February 06, 2013, 12:14:40 PM »
Made progress, after generating from project manager as C rather than C++ everything working and animation playing standalone, used the same code basically and had to rename the servos back from _servo1_ to just servo1 . so can only imagine there might be an issue when generating as C++ . for now can continue to make progress though, cheers.

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: webbotlibs gait designer
« Reply #7 on: February 07, 2013, 10:23:50 AM »
I too have had lesser success with the gait tools in C++, but have been satisfied working in C.
I

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: webbotlibs gait designer
« Reply #8 on: February 07, 2013, 12:45:10 PM »
Gertlex beat me to it - but the GaitDesigner was originally written when WebbotLib only supported C. I never got around to modifying it for C++ syntax.
The underscores you need to add in C++ are to access the 'C version' of the servo from your C++, hence when generating for just C you don't need to have them.
The other C++ issues to do with 'section type conflict' are a very bizarre problem caused by the C++ compiler.
I will get around to fixing it at some time - but am still working on WebbotLibStudio which initially will ignore all the gait stuff (as its not used as much as everything else), but eventually the GaitDesigner will become an integral part of WebbotLibStudio which only generates C++ and so will require me to sort out the issues anyway.

But in the meantime - enjoy it in 'C' !
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here