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

gDisk 0.6.1

Today, I try to use new gDisk version 0.6.1. Before version, I cannot see what files are on the server side. But current version I could do it. I think it is better than before version and it began to useful for backup software. But it has one problem.... When I uploaded more than 10 files at same time, it was clash down. I try to do it at 2-3 times but result was same..... I think it is one of the bag or the documents said about it (Actuary I read no document about it for this version)

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 ...

Pocket WiFi + Nexus One

Last a month, I used PocketWiFi with B-Mobile SIM + Google Nexus One with Softbank mobile SIM. I used this combination for a month because the softbank mobile had problem for 3G data communication due to the wrong parameter written by staff. The communication speed was too slow. So, I try to use B-Mobile for data communication. I wanted to use b-mobile but I didn't want to change the phone plan from softbank. Then, I try to use Pocket WiFi. The largest merit of using PocketWiFi is that we can use 3G network at most 6 devices at a same time. When we are starbacks, some coffee stand, or some other places we can use 3G network through the wifi. The speed was enough for web browser. However, for the data communicating through the android application, some of them didn't work. And, the buttery power also had problem. I need to charge the buttery every 1-2 days, even if i didn't use it. And, I had some situation that I wanted to use it however I forgot to bring it with me or to c...