Go to Post It's often not the code you are focused on that causes problems, but the code you dismiss out of hand as "unrelated". - Mark McLeod [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-06-2008, 18:23
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Control a vex with a laptop?

Have any of you ever tried controlling a vex with a laptop? I'm digging through the default vex code right now, but is it possible to receive commands from the computer's serial interface as well as send messages to it? I wonder if it's as simple as a scanf function, but unfortunately I don't have a vex on me to try it at the moment.

I ask this because I realized that my laptop, an Asus EeePC, is the perfect size for the job. That brings up another question... is it possible to use the serial interface under Linux? My laptop is running Kubuntu. I've interfaced with Cisco routers under Linux, which use the rollover cables and serial adapter, so I don't think it'll be any different...

Anyway, if I get this working, my laptop has wifi and a webcam, not to mention a screen, speakers, and USB interfaces. This might be fun.

Now I just gotta steal my brother's vex kit while he's not around...
  #2   Spotlight this post!  
Unread 20-06-2008, 18:42
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Hmmm... a bit more searching through the forums and I think I've answered my question.

Quote:
Originally Posted by Foster View Post
You can write code on the Vex that sends sensor status down the primary serial port, use the orange cable to connect it to the laptop.

The serial link runs at 115K baud, so you should get a pretty good data stream down from the Vex sensor array. Two ways would be a continuous stream of all the values from all the sensors. With 8 digital inputs and 4 analog ports its a 20 character message.

Or you could just send the sensors that change value, so it would be less data transfer.
Thought so... I'll post some pictures when I get this thing working.
  #3   Spotlight this post!  
Unread 21-06-2008, 01:52
dtengineering's Avatar
dtengineering dtengineering is online now
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,832
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Control a vex with a laptop?

Well, I happen to think you're on to a great idea here... mainly because I've got something pretty similar running on my VEX bot right now. It carries the laptop around, has a webcam mounted to a servo on the arm, and connects over wifi using Skype.

I have lots of fun driving the robot from another room using the live video feed and have been waiting to fix up a few little things before posting the video link here.

Then I was going to ask a question similar to yours, but a bit different... Does anyone have any suggestions on how to interface the laptop on the robot to the rest of the internet, so that I can control the data feed down the serial port TO the robot using any computer on the planet?

Skype will take care of the video feedback for the operator... I just need to get data... preferably from a joystick but I'll settle fo the keyboard or mouse for now... across a few firewalls and down a serial port.

And that is something I could do with a few suggestions on how to implement!

Jason
  #4   Spotlight this post!  
Unread 21-06-2008, 07:41
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Quote:
Originally Posted by dtengineering View Post
Then I was going to ask a question similar to yours, but a bit different... Does anyone have any suggestions on how to interface the laptop on the robot to the rest of the internet, so that I can control the data feed down the serial port TO the robot using any computer on the planet?
Well, I knew exactly how I was going to control the robot remotely from the start. I'm a hardcore Linux user, so I use secure shell (SSH) regularly. SSH is basically like secure telnet, for those who don't know. With SSH I can remote into my laptop from any computer in my house. With some port forwarding magic on my router (or tunneling; there's a million ways it can be done), I can SSH into my laptop from anywhere in the world. Now, if I use a shell based terminal emulator app like minicom or kermit, I can control the bot with SSH and effectively from anywhere around the world.

There's a port of Open SSH server to Windows, but I don't know if there are any CLI based terminal emulators for Windows. It might be a pain to set up so it might be worth dual booting Linux, I don't know...

Oh, and btw, after an all nighter of coding I've gotten the basic command interface working. It doesn't do anything right now... I still need to actually parse the commands. I'm a total parsing noob (in perl, I often just split() the strings and simply assume which pieces are which), so this should be a good learning experience for me.

Anyway, I guess we're in this thing together. Good luck!
  #5   Spotlight this post!  
Unread 21-06-2008, 10:35
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Okay, I've almost got this working, but I've reached a stumbling block. I'm using Kevin's latest FRC code with this Vex because it comes with serial port functions. However, once I got to the part where I set the PWMs, I found that setting the PWM values doesn't do anything! Has anyone else tried to run Kevin's code on the Vex? Or, has anyone gotten serial input to work on the default vex code? I hate getting stuck on silly problems like this... I just want to see the robot move.
  #6   Spotlight this post!  
Unread 21-06-2008, 12:34
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

A bit more experimenting, and I think this particular Vex controller is dead. The serial interface works well enough, but the PWMs don't work even with the default Vex code. It forgets the code loaded on it the instant I turn it off. That's disappointing. I might be able to get my hands on another controller later, but it looks like I'm grounded for now.

Let me know how that remote controlling goes. Interfacing with the robot through the serial port is really easy with Kevin's serial_ports.c/h code.

*yawn* it's 10:32 and I've yet to get any sleep... enough messing with this thing...
  #7   Spotlight this post!  
Unread 21-06-2008, 22:42
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Control a vex with a laptop?

Before chunking it, try reloading the master code (the .bin file). Our annual summer camp was this week and there was a robot that would not connect to the OI at all, and after downloading the master code and the user code, it worked fine. I'm not sure why it went bad, but it did. Also some controllers would forget their code as well.

You sound pretty smart with programming and computers, so you have probably already done this, but I thought I would give a shot at helping you.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #8   Spotlight this post!  
Unread 21-06-2008, 23:46
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Quote:
Originally Posted by RyanN View Post
You sound pretty smart with programming and computers, so you have probably already done this, but I thought I would give a shot at helping you.
Hehe, I'm not /that/ smart. I never even thought of that. I'll try that...
  #9   Spotlight this post!  
Unread 22-06-2008, 00:27
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Thanks. I loaded the latest firmware and the controller is working now, at least with the default code. Unfortunately, I wasn't able to control the PWMs using Kevin's code. I've read on the forum somewhere that components of Kevin's FRC code can be dropped into the regular Vex code easily enough, so I'll try that next.

Unrelated, I'm having trouble using mplab 8.10 with the 2.40 compiler... I guess I'll start another thread to fix that issue. Looks like another long night of delicious code.
  #10   Spotlight this post!  
Unread 22-06-2008, 02:55
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

I tried using Kevin's serial_ports.c/h with the default Vex code and I got it to compile and run, but whenever I call Read_Serial_Port_One(), the bot stops working, the "PGRM STATUS" LED flashes red, and the serial port doesn't work at all.

So right now it looks like I get to choose between either being able to move the bot by using the default Vex code, or being able to communicate with it by using Kevin's FRC code. I haven't gotten moving and communication working at the same time yet.

Oh, and btw, when running Kevin's FRC code, the program LED is always flashing red, but at least the serial port works. Maybe that will help to diagnose the problem.
  #11   Spotlight this post!  
Unread 22-06-2008, 12:22
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Control a vex with a laptop?

Quote:
Originally Posted by antiNeo View Post
I tried using Kevin's serial_ports.c/h with the default Vex code and I got it to compile and run, but whenever I call Read_Serial_Port_One(), the bot stops working, the "PGRM STATUS" LED flashes red, and the serial port doesn't work at all.

So right now it looks like I get to choose between either being able to move the bot by using the default Vex code, or being able to communicate with it by using Kevin's FRC code. I haven't gotten moving and communication working at the same time yet.

Oh, and btw, when running Kevin's FRC code, the program LED is always flashing red, but at least the serial port works. Maybe that will help to diagnose the problem.
I really don't think Kevin's' latest code will work with Vex, unless he has released the Vex version he rumored he was working on a few months ago.

Now as for adding his serial port drivers, yes it is possible. In fact, I highly recommend it. I currently have his: Interrupt, ADC, Gyro, IR receiver and serial port code added into the default 2007 FVC code. It is not that difficult to do and it really adds some great functionality. For one, I can now get real-time telemetry from the Vex via Serial port 2 and my BlueSMiRF from Sparkfun. I also have an adapter that allows the same from Serial port 1, but it is not as convenient to use.

I do not believe Kevin's PWM code will work with Vex without some major modifications. Vex only has 8 PWMs while FRC has 16. Kevin's code is written to work with PWM's 13-16 and use the CCP hardware to generate the PWM signals, bypassing the need to use interrupts.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #12   Spotlight this post!  
Unread 22-06-2008, 22:30
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Okay, I was working on my idea of controlling the robot over SSH with kermit and I hacked up a Perl script that can control the PWMs with my joystick. Disclaimer: this code is a dirty hack. First of all, I wrote it. Secondly, using Expect to control a robot through a makeshift Perl script is probably not the most ideal solution.

Code:
#!/usr/bin/perl

# Copyright 2008 Jonathan Glines
# auntieNeo@gmail.com
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use Expect;
use Linux::Input::Joystick;

my $login = "myLogin";
my $password = "myPassword";
my $address = "192.168.1.106";  # the address of my laptop connected to the Vex via serial

# connect via ssh
my $exp = Expect->spawn("ssh -l $login $address");

my $patidx = $exp->expect(20, 'password:');
if($patidx == 1)
{
  $exp->send("$password\n");  # ssh password
}

# open the serial interface with kermit
$patidx = $exp->expect(10, '~$ ');  # '~$ ' is the prompt my laptop happens to give
if($patidx == 1)
{
  $exp->send("sudo kermit ~/code/scripts/vex\n");  # ~/code/scripts/vex is a simple kermit script that sets the serial connection settings
}


# enter the sudo password
$patidx = $exp->expect(5, "password for $login:");
if($patidx == 1)
{
  $exp->send("$password\n");  # sudo password
}

sleep(2);
$exp->send("\r");  # send the vex a return so that we get a prompt

my $js = Linux::Input::Joystick->new('/dev/input/js0');
my $jsConstant = 0.003875;  # constant that reduces Linux joystick values (32767 through -32767) to Vex joystick values (127 through -127)
while(true)
{
  my @event = $js->poll(0.01);
  foreach(@event)
  {
    my %test = %{ $_ };
    if($test{'type'} == 2)  # if it's a joystick axis event
    {
      if($test{'number'} == 1)  # if the axis in question is y of the left stick (on my PSX controller)
      {
        $patidx = $exp->expect(5, '>');  # wait for a prompt from the Vex
        if($patidx == 1)
        {
          $exp->send('p01' . round(($test{'value'} * $jsConstant) + 127) . "\r");  # set pwm01 to the left joystick
        }
      }
      elsif($test{'number'} == 2)  # if the axis in question is y of the right stick (on my PSX controller)
      {
        $patidx = $exp->expect(2, '>');  # wait for a prompt from the Vex
        if($patidx == 1)
        {
          $exp->send('p02' . round(($test{'value'} * $jsConstant) + 127) . "\r");  # set pwm02 to the right joystick
        }
      }
    }
  }
}

$exp->soft_close();

sub round {
  my($number) = shift;
  return int($number + .5 * ($number <=> 0));
}
Basically what this does is it uses Perl's Expect module to control SSH and kermit like its puppets and then Perl's joystick module to send joystick values to the robot. I wrote a rudimentary command interface on the Vex to control the PWMs. Basically the command to set pwm01 to 25 would be "p0125". So, if I can get these PWMs to actually work, I would probably have the worlds first Vex programmed in Perl.

Btw, this thing actually works. Here's a screenshot of my desktop (which the joystick is connected to) sending messages to my laptop (which the vex is connected to). My laptop is connected to the network with wifi, so this is all wireless.

  #13   Spotlight this post!  
Unread 23-06-2008, 01:09
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

I've been trying for a few hours to get the serial drivers working with the 04-23-08 Vex code, but I always wind up with the blinkey red light of death. Can anyone give me any insight into what this red light implies? And are there any tricks to getting the serial drivers working with this code? I've just been commenting out blocks of code trying to see what breaks it. This embedded stuff is confusing; I'm really in the dark here...
  #14   Spotlight this post!  
Unread 23-06-2008, 06:47
antiNeo antiNeo is offline
Registered User
FRC #1569
 
Join Date: Jan 2008
Location: Pocatell, Idaho
Posts: 17
antiNeo has a spectacular aura aboutantiNeo has a spectacular aura about
Re: Control a vex with a laptop?

Haha! I just discovered something totally by accident that I should have checked before. When using Kevin's FRC code with the Vex, motor ports 1 through 4 are controlled by pwms 13 through 16. That solves my problem. I still don't know how to control ports 5 through 8, but four motors is enough for now.

Oh, and it works perfectly. I'm controlling the Vex with the PSX controller attached to my desktop, over wifi. Now I just need to mount my laptop to the robot... Only I'm not that good with the mechanical aspect of robotics. Ah well... I'll have pictures and a video up soon.
  #15   Spotlight this post!  
Unread 23-06-2008, 13:55
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Control a vex with a laptop?

Quote:
Originally Posted by dtengineering View Post
Well, I happen to think you're on to a great idea here... mainly because I've got something pretty similar running on my VEX bot right now. It carries the laptop around, has a webcam mounted to a servo on the arm, and connects over wifi using Skype.

I have lots of fun driving the robot from another room using the live video feed and have been waiting to fix up a few little things before posting the video link here.

Then I was going to ask a question similar to yours, but a bit different... Does anyone have any suggestions on how to interface the laptop on the robot to the rest of the internet, so that I can control the data feed down the serial port TO the robot using any computer on the planet?

Skype will take care of the video feedback for the operator... I just need to get data... preferably from a joystick but I'll settle fo the keyboard or mouse for now... across a few firewalls and down a serial port.

And that is something I could do with a few suggestions on how to implement!

Jason
This is the way I would do it. Maybe it will give you a starting point. I would build it out in three parts. I use .NET, but you can probably do it in any language.

1) A serial IO component to provide an interface between the onboard laptop and the vex controller. The easiest protocol would be a 4-byte packet with the camera PWM, left motor PWM, right motor PWM, and 0xFF delimiter. The PWM values should be in the range 0-254. The Vex controller will need to listen and parse data from the serial port. The Vex controller will also want to stop the motors if no data is coming in, in case the link to the laptop is broken.

2) A Windows service to manage the connection to the Vex controller. The service will keep the current PWM command in memory and resend then on a fixed schedule. The service will expose a method to update the motor values. The service itself would be implemented as a WCF web service.

3) An ASP.NET application running on the laptop to collect inputs and call into the service to update the motor values. You can configure your WAP to route traffic on a non-standard port (ex. 8085) to the laptop. You would access the web application at your router's public IP address and the port you configured in the WAP settings. You can get the public IP by hitting http://ipchicken.com from behind the router, or through the router settings.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a VEX Receiver with Non-Vex Equipment akaria VEX 26 06-09-2008 00:55
The poor serial port less laptop owners with a ExpressCard Slot Kingofl337 Programming 8 11-03-2008 22:25
Laptop Controlled VEX robot John Gutmann Technical Discussion 0 11-04-2007 00:51
PC Control of Vex processor tacman1123 Programming 1 06-06-2006 10:47
What to do with an old Windows 3.10 laptop? Elgin Clock IT / Communications 13 14-07-2005 17:45


All times are GMT -5. The time now is 19:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi