To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Search Results: psksvp
 Results 1 – 5 of about 10.
Search took 0.00 CPU seconds. 

Messages:  Full | Brief | Compact
Sort:  Prefer Newer | Prefer Older | Best Match

Subject: 
Thread class
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 5 Jun 2002 14:04:26 GMT
Viewed: 
2134 times
  
// Thread Class for Legos
// By Pongsak Suvanpong
// psksvp@ccs.neu.edu
// use it anyway you'd like as long as this comment is here

#ifndef __THREAD_CLASS___
#define __THREAD_CLASS___

#include <unistd.h>
#include <sys/dsensor.h>
#include <sys/battery.h>
#include <dmotor.h>
#include <dsound.h>
#include <dbutton.h>
#include <c++/Sound.H>
#include <c++/TouchSensor.H>
#include <c++/LightSensor.H>
#include <c++/RotationSensor.H>

class Thread;
class Runable
{
  friend Thread;
  bool m_bIsRunning;
public:
  Runable(void)
  {
    m_bIsRunning = false;
  }

  virtual ~Runable(void)
  {
  }

  bool IsRunning(void)
  {
    return m_bIsRunning;
  }

  virtual int Run(void)=0;

private:
  int CallBack(void)
  {
    m_bIsRunning = true;
    Run();
    m_bIsRunning = false;
  }
};

class Thread
{
protected:
  pid_t m_id;
  Runable *m_pHandler;
  bool m_bCreated;

public:
  Thread(void)
  {
    m_pHandler = (Runable *)NULL;
    m_id = 0;
    m_bCreated = false;
  }
  Thread(Runable *pHandler)
  {
    m_pHandler = pHandler;
    m_id = 0;
    m_bCreated = false;
  }

  ~Thread(void)
  {
    Stop();
  }

  pid_t Id(void)
  {
    return m_id;
  }

  void SetRunable(Runable *pHandler)
  {
    m_pHandler = pHandler;
  }

  bool Start(priority_t priority = PRIO_NORMAL, size_t stackSize =
DEFAULT_STACK_SIZE)
  {
    if(NULL != m_pHandler)
    {
      char *argv[2];
      argv[0] = (char *)m_pHandler;
      argv[1] = (char *)NULL;
      m_id = ::execi(Proc, 2, argv, priority, stackSize);
      m_bCreated = ( m_id == -1 ? false : true);
      return m_bCreated;
    }
    else
    {
      return false;
    }
  }

  void Stop(void)
  {
    if(true == m_bCreated)
    {
      ::kill(m_id);
      m_bCreated = false;
    }
  }

  bool IsRunning(void)
  {
    return m_pHandler->IsRunning();
  }

private:
  static int Proc(int argc, char **argv)
  {
    Runable *pcHandler = reinterpret_cast<Runable*>(argv[0]);
    return pcHandler->CallBack();
  }
};


class SensorMonitor :public Runable
{
protected:
  unsigned char m_iFreq; //millisec
  Thread m_myThread;
public:
  SensorMonitor(void) :Runable()
  {
    m_myThread.SetRunable(this);
  }

  ~SensorMonitor(void)
  {
    StopMonitor();
  }

  virtual bool StartMonitor(unsigned char iFreq=100)
  {
    m_iFreq = iFreq;
    return m_myThread.Start();
  }

  virtual void StopMonitor(void)
  {
    m_myThread.Stop();
  }

  int Run(void)
  {
    while(true)
    {
      if(false == Monitor())
        return 1;
      else
        ::msleep(m_iFreq);
    }
  }

protected:
  virtual bool Monitor(void) = 0;
};

class BatteryMonitor :public SensorMonitor
{
  int m_iLow;
public:
  BatteryMonitor(const int iLowThreadhold=300) :SensorMonitor()
  {
    m_iLow = iLowThreadhold;
  }

  int CurrentValue(void)
  {
    ::battery_refresh();
    return ::get_battery_mv();
  }

  virtual bool OnLow(void)
  {
    return true;
  }

protected:
  bool Monitor(void)
  {
    if(m_iLow >= CurrentValue())
      return OnLow();
    else
      return true;
  }
};

class TouchSensorMonitor :public SensorMonitor
{
  TouchSensor *m_pTheSensor;
public:
  TouchSensorMonitor(const Sensor::Port port):SensorMonitor()
  {
    m_pTheSensor = new TouchSensor(port);
  }

  ~TouchSensorMonitor(void)
  {
    delete m_pTheSensor;
  }

  virtual bool OnPressed(void)
  {
    return true;
  }

protected:
  bool Monitor(void)
  {
    if(true == m_pTheSensor->pressed())
      return OnPressed();
    else
      return true;
  }

};

class LightSensorMonitor :public SensorMonitor
{
  LightSensor *m_pTheSensor;
  unsigned int m_iCurValue;
public:
  LightSensorMonitor(const Sensor::Port port) :SensorMonitor()
  {
    m_iCurValue = 0;
    m_pTheSensor = new LightSensor(port);
  }

  ~LightSensorMonitor(void)
  {
    delete m_pTheSensor;
  }

  unsigned int CurrentValue(void)
  {
    return m_pTheSensor->get();
  }

  virtual bool OnChange(const unsigned int iNewValue)
  {
    return true;
  }

protected:
  bool Monitor(void)
  {
    unsigned int iNewValue = m_pTheSensor->get();
    if(m_iCurValue != iNewValue)
    {
      m_iCurValue = iNewValue;
      return OnChange(m_iCurValue);
    }
    else
      return true;
  }

};

class RotationSensorMonitor :public SensorMonitor
{
  RotationSensor *m_pTheSensor;
  int m_iCurValue;
protected:
  RotationSensorMonitor(const Sensor::Port port, const int pos=0)
:SensorMonitor()
  {
    m_iCurValue = 0;
    m_pTheSensor = new RotationSensor(port, pos);
  }

  ~RotationSensorMonitor(void)
  {
    delete m_pTheSensor;
  }

  int CurrentValue(void)
  {
    return m_pTheSensor->pos() % 16;
  }

  virtual bool OnRotate(const int iNewValue)
  {
    return true;
  }

  bool Monitor(void)
  {
    int iNewValue = CurrentValue();
    if(m_iCurValue != iNewValue)
    {
      m_iCurValue = iNewValue;
      return OnRotate(m_iCurValue);
    }
    else
      return true;
  }
};

#endif


///////////////////////////////////////////////
//// example
//////////////////////////////////////////////
#include <c++/Thread.H>

/////////////////////////////////////////////////
class MyTouchMonitor :public TouchSensorMonitor
{
public:
  MyTouchMonitor(const Sensor::Port port)
    :TouchSensorMonitor(port)
  {
  }

  bool OnPressed(void)
  {
    Sound::beep();
    return true;
  }
};

/////////////////////////////////////////////////
class MyLightMonitor :public LightSensorMonitor
{
public:
  MyLightMonitor(const Sensor::Port port)
    :LightSensorMonitor(port)
  {
  }

  bool OnChange(const unsigned int iNewValue)
  {
    ::cputw(iNewValue);
    return true;
  }
};

/////////////////////////////////////////////////
class MyRotMonitor :public RotationSensorMonitor
{
public:
  MyRotMonitor(const Sensor::Port port, const int pos=0)
    :RotationSensorMonitor(port, pos)
  {
  }

  virtual bool OnRotate(const int iNewValue)
  {
    ::cputw(iNewValue);
    return true;
  }
};



int main(int argc, char *argv[])
{
  //MyLightMonitor mon1(TouchSensor::S3);
  //mon1.StartMonitor();
  MyRotMonitor mon1(Sensor::S3);
  mon1.StartMonitor();
  MyTouchMonitor mon(Sensor::S1);
  mon.StartMonitor();
  ::getchar();

  return 0;
}

 

psksvp
(score: 0.256)

Subject: 
NQC functions in C???
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 5 Jun 2002 14:34:21 GMT
Viewed: 
2092 times
  
Hello all

I am looking for C code for legos, to do the same as the below in NQC

psksvp

      SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_DUTY25|SERIAL_COMM_76KHZ);
      SetSerialPacket(SERIAL_PACKET_DEFAULT);

      // Set the first unit two message bytes and send them

      SetSerialData(0,MANAS_1*0x10+em1);
      SetSerialData(1,em2*0x10+0x10-((MANAS_1+em1+em2)&0xf));
      SendSerial(0,2);

 

psksvp
(score: 0.256)

Subject: 
Re: Robotic Vision (was: Video image analisys)
Newsgroups: 
lugnet.robotics
Date: 
Thu, 6 Jun 2002 11:20:22 GMT
Viewed: 
1170 times
  
Hello

I am planing on building stero-head using rcx, and 2 webcam from lego
studio. All ImageProcessing will be done on PC, RCX will be used to control
til, pan, etc...


psksvp



In lugnet.robotics, Marco Correia writes:
Hi :)

(recovering a "very" old lugnet.robotics thread about Robotic Vision
software for Mindstorms, predating the release of LEGO Vision Command)

I'm assuming that you're the same psksvp that made the Robotic Vision dll's
at
http://www.ccs.neu.edu/home/psksvp/

(Try making a search on "Robotic Vision" or "psksvp" on the lugnet.robotics
and you'll see how old these threads are :)

Sorry but I can't resist making this question, since I "saw" you on
lugnet.robotics.rcx.legos:

Did you, or are you planning on using your vision library with LEGO bots ?
If so, are you planning on releasing working example code of it ?

Thxs ! :)

mc.

PS: Oh, and thxs for http://www.ccs.neu.edu/home/psksvp/download.htm !

-----Original Message-----
From: news-gateway@lugnet.com
[mailto:news-gateway@lugnet.com]On Behalf
Of psksvp
Sent: Wednesday, June 05, 2002 2:04 PM
To: lugnet.robotics.rcx.legos@lugnet.com
Subject: Thread class


// Thread Class for Legos
// By Pongsak Suvanpong
// psksvp@ccs.neu.edu
// use it anyway you'd like as long as this comment is here
[...]

 

psksvp
(score: 0.256)

Subject: 
RE: Robotic Vision (was: Video image analisys)
Newsgroups: 
lugnet.robotics
Date: 
Wed, 5 Jun 2002 17:02:52 GMT
Original-From: 
Marco Correia <MARCO@SOPORCEL.PTnomorespam>
Reply-To: 
<marco@soporcel.=spamcake=pt>
Viewed: 
1119 times
  
Hi :)

(recovering a "very" old lugnet.robotics thread about Robotic Vision
software for Mindstorms, predating the release of LEGO Vision Command)

I'm assuming that you're the same psksvp that made the Robotic Vision dll's
at
http://www.ccs.neu.edu/home/psksvp/

(Try making a search on "Robotic Vision" or "psksvp" on the lugnet.robotics
and you'll see how old these threads are :)

Sorry but I can't resist making this question, since I "saw" you on
lugnet.robotics.rcx.legos:

Did you, or are you planning on using your vision library with LEGO bots ?
If so, are you planning on releasing working example code of it ?

Thxs ! :)

mc.

PS: Oh, and thxs for http://www.ccs.neu.edu/home/psksvp/download.htm !

-----Original Message-----
From: news-gateway@lugnet.com
[mailto:news-gateway@lugnet.com]On Behalf
Of psksvp
Sent: Wednesday, June 05, 2002 2:04 PM
To: lugnet.robotics.rcx.legos@lugnet.com
Subject: Thread class


// Thread Class for Legos
// By Pongsak Suvanpong
// psksvp@ccs.neu.edu
// use it anyway you'd like as long as this comment is here
[...]

 

psksvp
(score: 0.244)

Subject: 
Re: cybermaster
Newsgroups: 
lugnet.robotics
Date: 
Thu, 3 Aug 2000 15:55:28 GMT
Original-From: 
Marco C. <MARCO@SOPORCEL.PTstopspam>
Viewed: 
991 times
  
Hi Laurentino :)

As you know (if you remember) I also have a CyberMaster.

I prefered the RF-link to the IR-link, primarily because of the mobility
and freedom it would give to the robot, and the processing power of the PC.

My current (looong) project is exactly that, of using Robotic Vision as a
component to the robot guidance system. Landmark recognition by vision,
crude obstacle detection by analising the glare intensity and distance
between a pair of small flash lights mounted on the robot and everything
else I might come up to, in the process.

As we all know, these "complex" projects have to be done one step after
another.

I don't know if you ever saw any of my postings about this, but, since
you're using MS VC++ and dealing with realtime image processing, have you
ever used a very good image/video-processing lib by Pong Suvan ?
http://www.ccs.neu.edu/home/psksvp/download.htm

The movingblob() was one I planed to use on a sub-project: "Target"
following, with the robot simply controlling the up/down, left/right
rotation of the cam.

If you didn't already, check this list:
http://www.cs.cmu.edu/afs/cs/project/cil/ftp/html/vision.html

My main problem right know: the european (PAL) version of XCam I was
planing to use for wireless color feedback to the PC (through my video-in
card), costs 249.00 EUR (www.edentronic.com) = $225.25 USD = 56000$00 PTE
(at www.xkt.pt) instead of the original NTSC version, $88 USD (www.x10.com)

:(

Guess I'll have to go for a cheaper option instead... an USB webcam. :/


At 11:27 03-08-2000 +0100, Laurentino Martins wrote:
At 10:47 03-08-2000 Thursday, KovacsJ@olajterv.hu wrote:
Hi! I've read the article you wrote the robotics list!
I also have cybermaster and want to design something similar. My question
is, do you lost everything? DOn't have a description or something else?
It's long time to do it from start! Cybermaster is much better then rcx,
because of communicating with radio.
Do you have a suggest how can i start this project!

Here some advices:
3. Know how to use the tachometers. Know how to rotate the bot any angle
using only the motors and monitoring the tachometers. It's very precise,
but has to be done in the bot side.
As a bonus you should know how to calculate speed and how to detect • impacts even without a single touch sensor. It works very well.
It can even detect when the bot tries to climb something too steep.
4. Read about odometry. I can't find the link, but there is a nice PDF in
the net that explains everything you need to know about odometry. Is
someone knows the link, please post.
The implementation is linear. You have to use the two odometers to know
the rotation the bot is describing. You'll have to average the last two or
tree reading to have a precise reading due to fluctuations the readings
sometimes display.
5. Be prepared to deal with odometry errors and how they accumulate thru
time. You can do little to improve the accuracy. The type of the floor
influences greatly the accuracy.
You better concentrate your efforts on how to auto-correct the PC routines
instead: I mean, if an impact was detected at point X and a previous impact
was detected at point Z which is beyond the X, that means that probably the
X is the same as Z (or otherwise the obstacle moved).
This was my most rewarding project ever done with the CyberMaster.
Good luck! :-)
......
My current project:
I've mounted a web camera in the CyberMaster. I've bought a 5m cable (USB) • and have let it free.
The tracks have lots of traction and can keep up dragging the cable after • the bot without (much) influence in the bot direction.
I've managed to capture the camera image in the PC (in M$ Visual C++) and • right now I'm working in an image recognition algorithm.
The idea was not to use odometry, but to use the camera image to track • landmarks, like a line drawn in the floor, walls, etc.
I'm stuck in the recognition algorithm - out of ideas.

____________________
Marco C. aka McViper

 

psksvp
(score: 0.180)

More:  Next Page >>


©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR