How to stop the polaris_ranger immediately?
How can I stop the polaris_ranger immediately ,so that when it detects the object it should stop. can anyone plz suggest . Thanks!
Asked by anonymous on 2014-11-20 08:34:15 UTC
Answers
Hi, I am using hukuyo sensor on polaris and I am using Tutorials/1.2/control robot/mobile base laser. The code is given below
public: void OnUpdate()
{
if(key is pressed)
{
joint1->SetForce(0,15);
joint2->SetForce(0,15);
}
unsigned int n = this->laser->GetRangeCount();
double min_dist = 1e6;
for(unsigned int i = 0; i < n; i++)
{
if(this->sicksensor->GetRange(i) < min_dist)
min_dist = this->sicksensor->GetRange(i);
}
if(min_dist < this->sicksensor->GetRangeMax())
{
printf("obstacle is detected");
this->joint1->SetForce(0,0);
this->joint2->SetForce(0,0);
}
}
whenever the obstacle is placed it is printing obstacle is detected but it is not setting the force 0. I also tried giving it reverse force then set to 0 , but then also it is not working.It is going in reverse direction but not stoping .
this->joint1->SetForce(0,-20);
this->joint2->SetForce(0,-20);
this->joint1->SetForce(0,0);
this->joint2->SetForce(0,0);
I want that when it detects the object it should stop at certain distance and hukuyo range is 10. Please help .Basically how can we apply brake on polaris. i think brake is not working of Polaris ranger. Thanks!
Asked by anonymous on 2014-11-25 00:28:50 UTC
Comments
Take a look at this example vehicle control plugin. It should have a good solution for you.
Asked by nkoenig on 2014-11-25 10:51:11 UTC
Comments
Hi, Thanks for the tutorial. It helped me a lot but still now the problem has not been resolved , it stops the polaris immediately when obstacle is detected but when i remove the obstacle and give it negative force it doesnt move reverse. And also sometimes it is changing the steering angle hence the polaris stops with tiltd tires , which is I thnk wrong. plz suggest what should i do . Thanks!
Asked by anonymous on 2014-11-26 04:13:19 UTC
You'll have to control the angle of the front wheels, in addition to the rotational velocity. I think the two steering joints are front_left_steering_joint
and front_right_steering_joint
.
Asked by nkoenig on 2014-11-26 11:46:34 UTC
Hi, Here in my code joint1 is front_left_wheel and joint2 is front_right_wheel. I am able to control the steering joints angle as in if suppose I am giving 45 degrees angle then it will move 45 degrees,. But I am not able to understand controlling the angle of front wheels. can you please give some guidance realted to it. If you want I can mail you my whole code . Thanks!
Asked by anonymous on 2014-11-27 07:47:04 UTC
I just want it to be lyk a real simulation, that when it detects it should apply brake and stops , and then it should take a reverse and then decide the direction accordingly whether to move right or left. By using vehicle control plugin I am able to stop the vehicle because of wheel angle but I am not able to take reverse when key2 is pressed.
Asked by anonymous on 2014-11-27 07:51:08 UTC
here is my code:
int min_dist = 1e6;
if(key1 pressed)
{
joint1->SetForce(0,15);
joint2->SetForce(0,15);
}
else if(key2 pressed)
{
joint1->SetForce(0,-40);
joint2->SetForce(0,-40);
}
for(unsigned int i = 0; i < n; i++)
{
if(this->sicksensor->GetRange(i) < min_dist)
min_dist = this->sicksensor->GetRange(i);
}
if(min_dist < this->sicksensor->GetRangeMax())
{
printf("object is detected");
double velocity=this->joint1->GetForce(0);
int t=1;
double acceleration=(velocity/t);
double target_dist=((velocity*velocity)/(2*acceleration));
if(min_dist<=target_dist)
{
double steeringRange=this->steering_joint->GetHighStop(0).Radian()-this->steering_joint->GetLowStop(0).Radian();
double steeringRatio= steeringRange / tireAngleRange;
double steeringAngle=this->steering_joint->GetAngle(0).Radian();
double wheelAngle=steeringAngle/steeringRatio;
this->joint1->SetLowStop(0,wheelAngle);
this->joint1->SetHighStop(0,wheelAngle);
this->joint1->SetLowStop(0,wheelAngle);
this->joint1->SetHighStop(0,wheelAngle);
this->joint2->SetHighStop(0,wheelAngle);
this->joint2->SetLowStop(0,wheelAngle);
this->joint2->SetHighStop(0,wheelAngle);
this->joint2->SetLowStop(0,wheelAngle);
}
}
Asked by anonymous on 2014-11-26 04:18:42 UTC
Comments
Here is code that can control the polaris ranger. Please refer to the aforementioned for moving and stopping the polaris.
Asked by nkoenig on 2014-12-01 13:00:52 UTC
Comments
ohk .. Thanks a lot.
Asked by anonymous on 2014-12-02 00:12:18 UTC
Comments
Can you add some more detail to your question? Please include how you are controlling the polaris, and how it is detecting an object?
Asked by nkoenig on 2014-11-24 16:55:25 UTC