help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave/C++


From: Stefan van der Walt
Subject: Re: Octave/C++
Date: Mon, 25 Jul 2005 15:01:04 +0200
User-agent: Mutt/1.5.9i

Hi Mike

The function to access the robot could look something like (from the
top of my head)

DEFUN_DLD(robot_cmd, args, argv,
"Send a cmd to the robot\n\
\n\
usage: robot_cmd(robot, cmd)")
{
  octave_value_list retval;

  if (args.length() != 2) {
    print_usage("robot");
    return retval;
  }

  if (args(0).type_id() != Bot::static_type_id()) {
    print_usage("robot");
    return retval;
  }

  robot_command rbc;
  rbc.opcode = args(1).int_value(); 

  if (error_state) {
    error("robot_cmd: expected integer command");
    return retval;
  }

  Bot *b = (Bot*)args(0).internal_rep();
  b->get_link() << rbc;

  return retval;
}

You'll have to add the get_link() method to the Bot class.  Also, I
didn't make provision for parameters above.

Regards
Stéfan

On Mon, Jul 25, 2005 at 10:50:45AM +0100, Mike Morley wrote:
> I tried the code you provided this morning linking to the header files, and 
> it appears to work.
> 
> The problem I now have is how do I run commands to the robot?
> 
> I've looked at make_int.cc but I don't really understand the syntax I need 
> to use to make things work.
> 
> Ideally, what I need is some way of issuing a command in octave like:
> 
> robotcommand (robot, motor1go, speed) that would run the C++ command 
> robot.command (MOTOR_1_GO, speed)
> 
> So what I guess I need is some switch statement to convert the string into 
> the appropriate robot command statement, and then pick up the other 
> variable to pass to the robot. However, I'm not sure how to implement this.
> 
> Mike



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]