Skip to main content

[player/stage: javaclient2] sample

This 2 days, I could not understand about the player/stage. javaclient2 is one of the client tool for player.

Official site (player/stage)
http://playerstage.sourceforge.net/wiki/Main_Page

Official page(javaclient2 for player/stgage)
http://java-player.sourceforge.net/index.php

The following url is community for javaclient2 for player/stage.
http://www.nabble.com/Javaclient-for-Player-Stage-f3213.html

I try to write sample program same behavior as laserobstacleavoid.cc.

========================================================================
import javaclient2.*;
import javaclient2.structures.PlayerConstants;
import javaclient2.structures.laser.*;

public class TestClassBasic
{
private String hName = "localhost";
private int port = 6664;
private double lLimit = 2;

public TestClassBasic()
{
PlayerClient robot = new PlayerClient(hName, port);
Position2DInterface p2d = robot.requestInterfacePosition2D(1, PlayerConstants.PLAYER_OPEN_MODE);

LaserInterface laser = robot.requestInterfaceLaser(0, PlayerConstants.PLAYER_OPEN_MODE);
PlayerLaserData pld = null;

double speed = 3;
double turn = 0;

int minCounter = 0;

while(true)
{
double newspeed = 0;
double newturnrate = 0;
double minR = 1e9;
double minL = 1e9;

robot.readAll();
pld = laser.getData();

for(int i=0; i pld.getRanges()[i])
{
minR = pld.getRanges()[i];
}
}
for(int i=pld.getIntensity_count()/2; i< minl =" pld.getRanges()[i];" l =" (1e5" r =" (1e5"> 100)
l = 100;
if(r > 100)
r = 100;

newspeed = (r+l)/1e3;

newturnrate = (r-l);
newturnrate = limit(newturnrate);
newturnrate = Math.toRadians(newturnrate);

p2d.setSpeed((float)newspeed, (float)newturnrate);
}// while
}

private double limit(double newturnrate)
{
if(newturnrate < -40) { return(-40); } else if(newturnrate > 40)
{
return(40);
}

return(newturnrate);
}

public static void main(String[] args)
{
TestClassBasic tcb = new TestClassBasic();
}
}

Comments

I tried to use your example from the post but I had some problems. Can you send my by email, please?

bren [at] juanantonio [dot] info

Cheers
daikihi said…
Hello
Thank you for your comment.
What kind of problem did you see?
I think some of other person also have same problem. So I would like to ask here about it, if you can do it. Is it possible?

Popular posts from this blog

Bicycle insurance in japan

Long time, I was considering about bicycle insurance. Many japanese are not consider about insurance for bicycle in japan. Because japan is weak country for insurance. Many people considered about when they are attacked by car. They didn't have an idea what they may be going to be individual at fault. However, road bikes are faster than my MTB. And, many of city bikes do not turn on a head light after sunset. The old person has also no idea what the bicycles can ride so fast as 50cc motar bike. Then they easy enter in front of bicycles. Such kind of accident is not few in japan. And, the worst case of such accident, the road bike rider needed to pay 40 millions yen to attacked person. Bicycle ride's bad manner have begun to social issues. Some bicycle riders do not follow the traffic lights or traffic signs. In such background, sometime, I have risks what I will be attacked by such bicycle riders when I ride my MTB. However, as above reason, many riders have no insurance ...

TokyoWalking :PhotoBlog : Natures in Tokyo

 

Babahera Ice cream @ Akita, Japan

 Akita city is a capital city at Akita prefecture. Akita city has castles. Sensyu park is just in front of Akita station. Around Akita castle and other main streets, some old woman sell ice creams.  They make instant shop around castle at summer. You can see several shop around it. A special thing is a shape of ice cream like as following photo.    A women makes this shape of ice cream in front of you. This shape is rose flower. Pink color is strawberry flavor taste and yellow one is banana flavor taste. Actually this taste is not as such natural one. In my image, it taste is soda flavor taste. But I did not feel bad when I took it. Actually, basically, I do not like banana taste of foods. But I did not make image of banana when I ate it. So, I can repeat to buy this ice cream. This taste is good for hot summer.   As I wrote, we can buy it around city from old woman, but i found it in convenience store. I did not have any hesitation to buy it or not wh...