ArRobot::moveTo

Okay, I figured it out...  It was simple, but took me a couple of
hours to work out what was going on (since moveTo worked in every
other place I tried it).  moveTo is working fine (which is why its
fine without the sleep)... what was happening is that when you reset
the robot to 0, it was trying to get back to the heading it'd been
given in the delta heading (30 degrees).  I should probably make
moveTo call ArRobot::clearDirectMotion, but all you have to do is add
in the clearDirectMotion, and with that addition it takes it down to a
few degrees off on your moveto, but that is because the isHeadingDone
says its done when the robot is within a few degrees, and after the
move it finishes those last degrees, so if you put an
ArUtil::sleep(1000); to give the robot a chance to finish moving then
the clearDirectMotion.  The rest'll be fine.

I'm attaching the modified file with // MODIFIED after the lines I
added... 

You should probably put the Aria::init in too.  Also you may want to
either do locking like I do in directMotionDemo or just use user
tasks, since eventually odd things happen if you don't play thread
friendly (ie if you move the robot in the middle of its calculation
about where it is, something quite bad and unpredictable will happen
and it'll be really hard to track it down).

Matt LaFary
ActivMedia Robotics
==========================================================
Oops, I did two things at once, I commented out the
ArUtil::sleep(1000) and added the init at the same point, and it was
taking out the sleep that made it work (which of course means it
didn't solve the problem).  There's something wrong with moveTo or
some of the other code, possibly when called from another thread.  I'm
looking into it to see wy its broken.

Matt LaFary
ActivMedia Robotics

On Mon, Aug 05, 2002 at 07:15:33PM -0500, Froylan Eloy Hernandez Castro wrote:
> Yes I forgot the Aria:init(), but even I add it, there's still the same
> problem...
///
Okay, I figured out the problem.  You didn't initialize Aria, and this
caused the problem (I'm not quite sure why).  Just toss an
Aria::init(); at the top of your main and you'll be fine.
 
///
Hi, I've trying to use the ArRobot::moveTo to set the robot position to
(0,0,0) but maybe I'm doing something wrong. First the robot begins at
the origin and moves forward and turns an angle, after that I use the
moveTo(ArPose(0,0,0)) hoping that the last position would be (0,0,0) but
I don't know why I can't get this, it seems that only the position is
reset to 0,0 but not the heading. How can does moveTo must be used
correctly to obtain get what I am trying to do ?

Here's an output from the attached program:

Robot pose before motion: 0 0 0.0
Robot pose after motion: 124 10 33.9
Robot pose after moveTo: -0 0 25.5

#include "Aria.h"	
#include <iostream>

int main( int argc, char *argv[] )
{
	ArRobot robot;	
	ArDeviceConnection *con;
	ArPose robotPose;
	
	std::cerr << "Connecting to simulator through tcp" << std::endl;
	ArTcpConnection *tcpCon = new ArTcpConnection;		
	tcpCon->setPort();
	con = tcpCon;
	robot.setDeviceConnection(con);
	if ( !robot.blockingConnect() )		{
		Aria::shutdown();
		return -1;
	}
	robot.runAsync(true);

	std::cout << "Robot pose before motion: ";		(robot.getPose()).print();
	robot.move( 100 );
	while ( !robot.isMoveDone() )
		;
	robot.setDeltaHeading( 30 );
	while ( !robot.isHeadingDone() )
		;
	std::cout << "Robot pose after motion: ";		(robot.getPose()).print();
	//	movew to the origin
	robot.moveTo( ArPose(0,0,0) );
	ArUtil::sleep(1000);	
	std::cout << "Robot pose after moveTo: ";		(robot.getPose()).print();
	
	Aria::shutdown();	
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值