Society of Robots - Robot Forum

Software => Software => Topic started by: herro der panda ber on April 04, 2013, 07:53:39 PM

Title: cant connect to VRbot GUI
Post by: herro der panda ber on April 04, 2013, 07:53:39 PM
I cant seem to connect the Vrbot GUI and i have tried all the debugging strategies there are............... does anybody know how i can make this work????????
Title: Re: cant connect to VRbot GUI
Post by: Admin on April 04, 2013, 09:04:20 PM
What have you done so far? How did you set it up? What errors are you getting?

Describe to us in detail exactly what you've done so far, step by step. That way we can know which step you missed.
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on April 06, 2013, 11:37:34 AM
ok well from the very start i used project designer and that created some code files for the robot. Then in avr studios i added the files project designer created and some of your source code files. Next i built the code and it created a .hex file and i uploaded that using the mcuber bootloader and i also uploaded the usbuart0.hex file to the axon.

This is the code for the robot. (will this code work?)

#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
   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) {

   // -------- Start Switch/Button-------
   // Switch/Button - see switch.h
   
   // To test if it is pressed then
   if(SWITCH_pressed(&button)){
      // pressed
   }
   
   // To test if it is released then
   if(SWITCH_released(&button)){
      // released
   }
   // -------- End   Switch/Button-------

   // -------- Start Marquee-------
   // Marquee - see 'segled.h'
   // Before using the Marquee you need to redirect rprintf to write to it
   // This can be done using
   Writer old = rprintfInit(marqueeGetWriter(&marquee));
   
   // All rprintf output will then be sent to the marquee but will not
   // display until an end-of-line eg "\n" has been sent. Example:-
   // rprintf("Hello World\n");
   
   // If the endDelay is non-zero then the marquee will scroll
   // forever or until you call: marqueeStop(&marquee);
   
   // If the endDelay is zero then the marquee will stop once
   // the entire line has been shown ('one-shot' mode)
   
   // In 'one-shot' mode then you may want to make sure that
   // a previous line has finished before you display a second line.
   // This can be done as follows:-
   marqueeSetEndDelay(&marquee,0); // Make sure we are in one-shot mode
   if(marqueeIsActive(&marquee)==FALSE){
        if(loopCount==1){
           rprintf("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
        }else{
         rprintf("Loop=%u\n",(unsigned)loopCount); // Put the loop count
        }
   }
   
   // Restore rprintf back to its previous location
   rprintfInit(old);
   // -------- End   Marquee-------

   // -------- Start Actuators -------
   // To control your.motors/servos then see actuators.h in the manual
   // To retrieve the required speed of wheel_left use:
   // DRIVE_SPEED speed=act_getSpeed(wheel_left);
   // To set the required speed of wheel_left use:
   // act_setSpeed(wheel_left,speed);
   // This example will move the motors back and forth using the loopStart time:
   TICK_COUNT ms = loopStart / 1000;      // Get current time in ms
   int16_t now = ms % (TICK_COUNT)10000;    // 10 sec for a full swing
   if(now >= (int16_t)5000){            // Goes from 0ms...5000ms
      now = (int16_t)10000 - now;         // then 5000ms...0ms
   }
   // Map it into DRIVE_SPEED range
   DRIVE_SPEED speed = interpolate(now, 0, 5000, DRIVE_SPEED_MIN, DRIVE_SPEED_MAX);
   // Set speed for all motors/servos
   act_setSpeed(&wheel_left,speed);
   act_setSpeed(&wheel_right,speed);
   // -------- End   Actuators -------

   return 0;
}
/*
      This file has been auto-generated by WebbotLib tools V1.1
            ** DO NOT MODIFY BY HAND **
*/
#ifndef _HARDWARE_H_
#define _HARDWARE_H_

#if !defined (_LIB_HARDWARE_C_)  && !defined(_LIB_HARDWARE_CPP_)
#define BUILDING_LIBRARY
#define _LIB_HARDWARE_C_
#endif

#ifndef F_CPU
#warning No CPU speed specified - assuming running at 16000000
#define F_CPU 16000000
#endif

#if F_CPU != 16000000
# warning "Board runs at 16000000 but you have defined a different value"
#endif

#if defined (__AVR_ATmega640__)
#else
#   error You must set the device to the ATmega640
#endif

#define FLASH_SIZE 65536
#define RAM_SIZE 8192
#define EEPROM_SIZE 4096
#define _NUM_PCINT_PINS 9

// Include library files
#include <libdefs.h>
#include <core.h>
#include <timer.h>
#include <a2d.h>
#include <rprintf.h>
#include <led.h>
#include <stdlib.h>
#include <avr/eeprom.h>
#include <switch.h>
#include <errors.h>
#include <uart.h>
#include <buffer.h>
#include <segled.h>
#include <servos.h>
#include "lib/lib_timerdef.h"
#include "lib/lib_iopins.h"
#ifdef __cplusplus
extern "C" {
#endif

// ------------------- uart1 -------------------
extern MAKE_WRITER(uart1SendByte);
extern MAKE_READER( uart1GetByte);

// Create hardware UART uart1
extern HW_UART _uart1;
#define uart1 &_uart1
#define UART1 uart1

// ------------------- Voice_Recognition -------------------
extern MAKE_WRITER(Voice_RecognitionSendByte);
extern MAKE_READER( Voice_RecognitionGetByte);

// Create hardware UART Voice_Recognition
extern HW_UART _Voice_Recognition;
#define Voice_Recognition &_Voice_Recognition
#define UART0 Voice_Recognition

// ----------- Define the ADC channels ----------
#define ADC0 ADC_NUMBER_TO_CHANNEL(0)
#define ADC1 ADC_NUMBER_TO_CHANNEL(1)
#define ADC2 ADC_NUMBER_TO_CHANNEL(2)
#define ADC3 ADC_NUMBER_TO_CHANNEL(3)
#define ADC4 ADC_NUMBER_TO_CHANNEL(4)
#define ADC5 ADC_NUMBER_TO_CHANNEL(5)
#define ADC6 ADC_NUMBER_TO_CHANNEL(6)
#define ADC7 ADC_NUMBER_TO_CHANNEL(7)
#define ADC8 ADC_NUMBER_TO_CHANNEL(8)
#define ADC9 ADC_NUMBER_TO_CHANNEL(9)
#define ADC10 ADC_NUMBER_TO_CHANNEL(10)
#define ADC11 ADC_NUMBER_TO_CHANNEL(11)
#define ADC12 ADC_NUMBER_TO_CHANNEL(12)
#define ADC13 ADC_NUMBER_TO_CHANNEL(13)
#define ADC14 ADC_NUMBER_TO_CHANNEL(14)
#define ADC15 ADC_NUMBER_TO_CHANNEL(15)
extern const uint8_t NUM_ADC_CHANNELS;

// ----------- My devices -----------------------
extern SWITCH button;
extern SEGLED led_display;
extern MARQUEE marquee;
extern SERVO wheel_left;
extern SERVO wheel_right;
extern SERVO_DRIVER bank1;

void initHardware(void);
#ifdef __cplusplus
}
#endif
#endif

// undefine all ports so the user cannot change them directly
#undef PORTA
#undef DDRA
#undef PINA
#undef PORTB
#undef DDRB
#undef PINB
#undef PORTC
#undef DDRC
#undef PINC
#undef PORTD
#undef DDRD
#undef PIND
#undef PORTE
#undef DDRE
#undef PINE
#undef PORTF
#undef DDRF
#undef PINF
#undef PORTG
#undef DDRG
#undef PING
#undef PORTH
#undef DDRH
#undef PINH
#undef PORTJ
#undef DDRJ
#undef PINJ
#undef PORTK
#undef DDRK
#undef PINK
#undef PORTL
#undef DDRL
#undef PINL

// Undefine timer registers to stop users changing them
#undef TCNT0
#undef TCCR0B
#undef OCR0A
#undef OCR0B
#undef TCNT1
#undef TCCR1B
#undef OCR1A
#undef OCR1B
#undef OCR1C
#undef TCNT2
#undef TCCR2B
#undef OCR2A
#undef OCR2B
#undef TCNT3
#undef TCCR3B
#undef OCR3A
#undef OCR3B
#undef OCR3C
#undef TCNT4
#undef TCCR4B
#undef OCR4A
#undef OCR4B
#undef OCR4C
#undef TCNT5
#undef TCCR5B
#undef OCR5A
#undef OCR5B
#undef OCR5C
//allows for printing with features, but uses more memory
#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

#include "hardware.h"

#include "VR_library.h"      //voice recognition library


// Initialise the hardware
void appInitHardware(void) {
   initHardware();


}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){

   servosDisconnect(&bank1);

   delay_ms(1200);//Axon II bootup time

   rprintf("\n\nAxon Initiated\n");

   VR_Module_init();

   return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

   int8_t voice_command=-2;

   //start voice recognition (note: it times out)
   VR_Module_start_recognition(VR_group);//group B
   
   while(voice_command == -2)
      voice_command = VR_Module_get_result();

   if(voice_command >= 0)
      {
      rprintf("\nvoice command is: ");

      //turn on servos (I turn off to prevent noise interference)
      act_setConnected(&wheel_left, TRUE);
      act_setConnected(&wheel_right, TRUE);
      delay_ms(30);

      //swap languages - not used in this example, as both languages are set to do the same
      /*if(VR_group==1 && voice_command==0)
         {
         rprintf(" ENGLISH");
         VR_group=2;
         }
      else if(VR_group==2 && voice_command==0)
         {
         rprintf(" THAI");
         VR_group=1;
         }*/
      VR_group=1;//use above code instead of this, if you want to swap languages
      
      //other commands
      if(voice_command==0)
         {
         act_setSpeed(&wheel_left,DRIVE_SPEED_MAX);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MIN);
         rprintf(" LEFT");
         delay_ms(700);
         }
      else if(voice_command==1)
         {
         act_setSpeed(&wheel_left,DRIVE_SPEED_MIN);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MAX);
         rprintf(" RIGHT");
         delay_ms(700);
         }
      else if(voice_command==2)
         {
         act_setSpeed(&wheel_left,DRIVE_SPEED_MAX);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MAX);
         rprintf(" FORWARD");
         delay_ms(1500);
         }
      else if(voice_command==3)
         {
         act_setSpeed(&wheel_left,0);
         act_setSpeed(&wheel_right,0);
         rprintf(" STOP");
         delay_ms(50);
         }
      else if(voice_command==4)
         {
         act_setSpeed(&wheel_left,DRIVE_SPEED_MIN);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MIN);
         rprintf(" REVERSE");
         delay_ms(1000);
         }
      else if(voice_command==5)
         {
         rprintf(" DANCE");
         //forward
         act_setSpeed(&wheel_left,DRIVE_SPEED_MAX);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MAX);
         delay_ms(800);
         //reverse
         act_setSpeed(&wheel_left,DRIVE_SPEED_MAX);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MAX);
         delay_ms(800);
         //spin right
         act_setSpeed(&wheel_left,DRIVE_SPEED_MIN);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MAX);
         delay_ms(1200);
         //spin left
         act_setSpeed(&wheel_left,DRIVE_SPEED_MAX);
         act_setSpeed(&wheel_right,DRIVE_SPEED_MIN);
         delay_ms(1200);
         }
      else if(voice_command==6)
         {
         LED_off(&statusLED);
         rprintf(" LED");
         delay_ms(2000);
         LED_on(&statusLED);
         }
      /*
      else if(voice_command==5)
         rprintf(" WAI PRA");
      else if(voice_command==6)
         rprintf(" WORSHIP");
      else if(voice_command==7)
         rprintf(" ARM");
      else if(voice_command==8)
         rprintf(" ATTACK");
      else if(voice_command==9)
         {
         rprintf(" SHUTDOWN");
         servosDisconnect(&bank1);
         }
      else if(voice_command==10)
         {
         rprintf(" POWER_UP");
         servosConnect(&bank1);
         }
      else if(voice_command==12)
         {
         act_setSpeed(&elbow,80);
         rprintf(" UP");
         }
      else if(voice_command==13)
         {
         act_setSpeed(&elbow,-80);
         rprintf(" DOWN");
         }
      else if(voice_command==14)
         {
         act_setSpeed(&gripper,-50);
         rprintf(" GRAB");
         }
      else if(voice_command==15)
         {
         act_setSpeed(&gripper,50);
         rprintf(" RELEASE");
         }
      */

      //stop further motion and turn off servos
      act_setSpeed(&wheel_left,0);
      act_setSpeed(&wheel_right,0);
      act_setConnected(&wheel_left, FALSE);
      act_setConnected(&wheel_right, FALSE);
      }
   
   rprintf("\n");
   delay_ms(100);

   return 0;
}

/*
Group 1:
0 PASA_THAI
1 LEFT
2 RIGHT
3 FORWARD
4 DANCE
5 WAI PRA
6 WORSHIP
7 ARM
8 ATTACK
9 SHUTDOWN
10 POWER_UP
11 LED
12 UP
13 DOWN
14 GRAB
15 RELEASE

Group 2:
0 PASA_ANGRIT
1 LEO_SAI
2 LEO_KWA
3 DTRONG_BAI
4 DTEN LOY
5 WAI PRA
6 KOWROP BUUCHAA
7 KAEN
8 HAA REUNG
9 BID FAI
10 BERD FAI
11 LED
12 KEUN
13 LONG
14 JAB MAN
15 BLOY MAN
*/

------ Build started: Project: VOICE_REC_ROBOT_SCI_1, Configuration: Debug AVR ------
Build started.
Project "VOICE_REC_ROBOT_SCI_1.avrgccproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Users\bhat family\Documents\MY_ROBOT\VOICE_REC_ROBOT_SCI_1\VOICE_REC_ROBOT_SCI_1\VOICE_REC_ROBOT_SCI_1.avrgccproj" (target "Build" depends on it):
   Using "RunAvrGCC" task from assembly "C:\Program Files (x86)\Atmel\AVR Studio 5.0\Vs\AvrGCCLib.dll".
   Task "RunAvrGCC"
      C:\Program Files (x86)\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe all
VOICE_REC_ROBOT_SCI_1.c
      Invoking: AVR/GNU C Compiler
      "C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe" -funsigned-char -funsigned-bitfields -O0 -fpack-struct -fshort-enums -g2 -Wall -c -std=gnu99  -mmcu=atmega640   -MD -MP -MF"VOICE_REC_ROBOT_SCI_1.d" -MT"VOICE_REC_ROBOT_SCI_1.d" -o"VOICE_REC_ROBOT_SCI_1.o" ".././VOICE_REC_ROBOT_SCI_1.c"
      Finished building: .././VOICE_REC_ROBOT_SCI_1.c
      Building target: VOICE_REC_ROBOT_SCI_1.elf
      Invoking: AVR/GNU C/C++ Linker
      "C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe"  -mmcu=atmega640   -o VOICE_REC_ROBOT_SCI_1.elf  VOICE_REC_ROBOT_SCI_1.o 
      Finished building target: VOICE_REC_ROBOT_SCI_1.elf
      "C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature  "VOICE_REC_ROBOT_SCI_1.elf" "VOICE_REC_ROBOT_SCI_1.hex"
      AVR Memory Usage
      ----------------
      Device: atmega640
      Program:     266 bytes (0.4% Full)
      (.text + .data + .bootloader)
      Data:          0 bytes (0.0% Full)
      (.data + .bss + .noinit)
   Done executing task "RunAvrGCC".
Done building target "CoreBuild" in project "VOICE_REC_ROBOT_SCI_1.avrgccproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files (x86)\Atmel\AVR Studio 5.0\Vs\Avr.common.targets" from project "C:\Users\bhat family\Documents\MY_ROBOT\VOICE_REC_ROBOT_SCI_1\VOICE_REC_ROBOT_SCI_1\VOICE_REC_ROBOT_SCI_1.avrgccproj" (entry point):
Done building target "Build" in project "VOICE_REC_ROBOT_SCI_1.avrgccproj".
Done building project "VOICE_REC_ROBOT_SCI_1.avrgccproj".

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on April 06, 2013, 11:41:30 AM
oh ya and then i opened the vrbot gui and when i try and connect it says cannot connect to device in com 4.

(also when i was playing around with the hyperterminal whenever i used to connect nothing used to happen the screen was blank is this normal?)
Title: Re: cant connect to VRbot GUI
Post by: Admin on April 06, 2013, 02:25:01 PM
oh ya and then i opened the vrbot gui and when i try and connect it says cannot connect to device in com 4.

(also when i was playing around with the hyperterminal whenever i used to connect nothing used to happen the screen was blank is this normal?)
Tell us all the steps you took, in detail. You missed a step, but it's hard to know which one without knowing what you did.

Are you sure your Axon is connected to COM 4?
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on April 07, 2013, 08:34:06 PM
what do yiu mean by in "detail" and yes im 100 percent sure that the axon is connected to com 4 and btw is my code correct cause it dosent seem like much?
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on April 08, 2013, 06:35:48 PM
thats basically what i did just one extra part was i tried changing the baud rates................

Please reply ASAP
Title: Re: cant connect to VRbot GUI
Post by: Admin on April 11, 2013, 02:18:26 PM
By 'in detail', I mean tell me exactly what you did step by step. Tell me how things are wired up, what hex files you are using, baud rates, operating system, etc. . . . in detail. Describe it step by step.
Title: Re: cant connect to VRbot GUI
Post by: Duane Degn on April 20, 2013, 09:02:06 PM
Did you get this working?

It looks like you have code to use the VRbot independent of a PC. To use the PC GUI with the VRbot you just need an USB to serial device to allow the PC to communicate with the VRbot.

If you don't have a separate USB to serial device, you could use your microcontroller as a bridge between the two devices but the code you posted does not look like a simple bridge program.

Do you have a way to communicate with the VRbot independent of your microcontroller?

Edit: I hadn't seen the tutorial on using the VRbot prior to writing the above post.
http://www.societyofrobots.com/sensors_voice_recognition_robot.shtml (http://www.societyofrobots.com/sensors_voice_recognition_robot.shtml)

If you changed the baud of the VRbot, the code loaded to the Axon would also need to have this new baud setting. It might be easier if you use a USB to serial device to start with.
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on April 26, 2013, 03:18:19 PM
Well the wirings are exactly the same as you showed in the video and i ussaly work with the 115200 baud rate but i have tried changing it. Also now whenever i try uploading the usbuart0 i always seem to get an error but when i upload the code for the axon that uploads properly. I also bought a usb to ttl connection and a new vrbot but i still can seem to connect with the gui. Im using the voice rec hex files that you have offered ofr my code and the hex file that webbot created for me. Also whenever i connect to hyper terminal by using the usb and the right com port and baud rate (115200)nothing happens it just stays blank, so why is this happening and what am i supposed to expect and sometimes the green led light on my axon dosent work is this normal??????

Thanks a lot reply ASAP
Did you get this working?

It looks like you have code to use the VRbot independent of a PC. To use the PC GUI with the VRbot you just need an USB to serial device to allow the PC to communicate with the VRbot.

If you don't have a separate USB to serial device, you could use your microcontroller as a bridge between the two devices but the code you posted does not look like a simple bridge program.

Do you have a way to communicate with the VRbot independent of your microcontroller?

Edit: I hadn't seen the tutorial on using the VRbot prior to writing the above post.
http://www.societyofrobots.com/sensors_voice_recognition_robot.shtml (http://www.societyofrobots.com/sensors_voice_recognition_robot.shtml)

If you changed the baud of the VRbot, the code loaded to the Axon would also need to have this new baud setting. It might be easier if you use a USB to serial device to start with.
By 'in detail', I mean tell me exactly what you did step by step. Tell me how things are wired up, what hex files you are using, baud rates, operating system, etc. . . . in detail. Describe it step by step.
 
Title: Re: cant connect to VRbot GUI
Post by: Admin on April 28, 2013, 04:11:52 PM
It's not really clear to me what you are doing, so it's not possible for me to determine the mistake you are making. I really need a step by step list of what you did, and details on the errors.

Quote
I also bought a usb to ttl connection and a new vrbot but i still can seem to connect with the gui.
Without using the Axon, use your USB to serial connection connected directly to VRbot to program voice commands. Getting this to work will likely help you identify the mistakes you're making.
Title: Re: cant connect to VRbot GUI
Post by: herro der panda ber on May 05, 2013, 01:48:01 PM
ya but thats not working as well when i try using the usb to serial device and ill try to tell you what i did step by step as best as i can.