Skip to content

Commit

Permalink
Pass ROS master as hostname and port to ROSSimaulation, we will need to
Browse files Browse the repository at this point in the history
use hostname for some type of simulation control connection in the
future
  • Loading branch information
vladamatena committed Nov 4, 2015
1 parent cf91918 commit 345fa65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
34 changes: 23 additions & 11 deletions jdeeco-ros/src/cz/cuni/mff/d3s/jdeeco/ros/sim/ROSSimulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,53 @@
public class ROSSimulation implements SimulationProvider {
/**
* The ROS_MASTER_URI value.
*
* Used to connect to ROS master via ROS protocol
*/
private final String ros_master_uri;

/**
* The ROS_MASTER
*
* Used to connect to ROS master in order to start up the ROS simulation
*/
private String ros_master;
private final String ros_master;

/**
* The ROS_HOST address.
*/
private String ros_host;
private final String ros_host;

/**
* Creates ROS simulation
*
*
*
* @param ros_master
* ROS machine hostname or IP address
* @param ros_host
* Local hostname or IP address
*/
public ROSSimulation(String ros_master, String ros_host) {
public ROSSimulation(String ros_master, int ros_master_port, String ros_host) {
this.ros_master = ros_master;
this.ros_host = ros_host;
this.ros_master_uri = String.format("http://%s:%d", ros_master, ros_master_port);
}

/**
* Creates ROS services instance with parameters specific to this simulation
* @param namespace Robot namespace
*
* @param namespace
* Robot namespace
* @return RosServices instance for robot
*/
public RosServices createROSServices(String namespace) {
return new RosServices(ros_master, ros_host, namespace);
return new RosServices(ros_master_uri, ros_host, namespace);
}

/**
* TODO: Report back ROS time, for now we expect simulation to be in sync with wall time
*
* ROS simulation is not proper simulation, it simulates hardware, but not time compression. Simulated hardware
* runs at "almost" wall time and the controller (jDEECo) has to keep up with it.
* ROS simulation is not proper simulation, it simulates hardware, but not time compression. Simulated hardware runs
* at "almost" wall time and the controller (jDEECo) has to keep up with it.
*
*/
class ROSTimer extends WallTimeTimer implements SimulationTimer {
Expand All @@ -51,7 +63,7 @@ public void start(long duration) {
start();
}
};

@Override
public SimulationTimer getTimer() {
return new ROSTimer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ public static void main(String[] args) throws AnnotationProcessorException, Inte
public void testTravel() throws AnnotationProcessorException, InterruptedException, DEECoException,
InstantiationException, IllegalAccessException, IOException {

ROSSimulation rosSim = new ROSSimulation("http://192.168.56.101:11311", "192.168.56.1");
ROSSimulation rosSim = new ROSSimulation("192.168.56.101", 11311, "192.168.56.1");

// Create main application container
DEECoSimulation realm = new DEECoSimulation(rosSim.getTimer());


// Configure loop-back networking for all nodes
realm.addPlugin(Network.class);
realm.addPlugin(DefaultKnowledgePublisher.class);
Expand Down

0 comments on commit 345fa65

Please sign in to comment.