-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actuators and Sensors are no longer singletons.
- Loading branch information
Showing
6 changed files
with
122 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 31 additions & 23 deletions
54
jdeeco-ros/src/cz/cuni/mff/d3s/jdeeco/ros/test/TestApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 35 additions & 35 deletions
70
jdeeco-ros/src/cz/cuni/mff/d3s/jdeeco/ros/test/TestComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
package cz.cuni.mff.d3s.jdeeco.ros.test; | ||
|
||
import cz.cuni.mff.d3s.jdeeco.ros.datatypes.Sound; | ||
import cz.cuni.mff.d3s.deeco.annotations.Component; | ||
import cz.cuni.mff.d3s.deeco.annotations.InOut; | ||
import cz.cuni.mff.d3s.deeco.annotations.In; | ||
import cz.cuni.mff.d3s.deeco.annotations.Local; | ||
import cz.cuni.mff.d3s.deeco.annotations.PeriodicScheduling; | ||
import cz.cuni.mff.d3s.deeco.annotations.Process; | ||
import cz.cuni.mff.d3s.deeco.task.ParamHolder; | ||
import cz.cuni.mff.d3s.jdeeco.ros.Actuators; | ||
import cz.cuni.mff.d3s.jdeeco.ros.Sensors; | ||
import cz.cuni.mff.d3s.jdeeco.ros.datatypes.Bumper; | ||
import cz.cuni.mff.d3s.jdeeco.ros.datatypes.LedColor; | ||
import cz.cuni.mff.d3s.jdeeco.ros.datatypes.LedId; | ||
import cz.cuni.mff.d3s.jdeeco.ros.datatypes.Sound; | ||
|
||
@Component | ||
public class TestComponent { | ||
|
||
public String id; | ||
|
||
public String msg; | ||
|
||
@Local | ||
public Sensors sensors; | ||
|
||
public TestComponent(final String id) { | ||
@Local | ||
public Actuators actuators; | ||
|
||
public TestComponent(final String id, Sensors sensors, Actuators actuators) { | ||
this.id = id; | ||
msg = "initial msg"; | ||
this.sensors = sensors; | ||
this.actuators = actuators; | ||
} | ||
|
||
@Process | ||
@PeriodicScheduling(period = 200) | ||
public static void checkMessage(@InOut("msg") ParamHolder<String> message) { | ||
/*System.out.println(message.value); | ||
if (Sensors.getInstance().getPosition() != null) { | ||
message.value = String.format("[%f, %f]", Sensors.getInstance() | ||
.getPosition().getX(), Sensors.getInstance().getPosition() | ||
.getY()); | ||
}*/ | ||
public static void checkMessage(@In("sensors") Sensors sensors, | ||
@In("actuators") Actuators actuators) { | ||
/* | ||
* System.out.println(message.value); if | ||
* (Sensors.getInstance().getPosition() != null) { message.value = | ||
* String.format("[%f, %f]", Sensors.getInstance() | ||
* .getPosition().getX(), Sensors.getInstance().getPosition() .getY()); | ||
* } | ||
*/ | ||
|
||
//Actuators.getInstance().setVelocity(0.5,0); | ||
Bumper bumper = Sensors.getInstance().getBumper(); | ||
//System.out.println(bumper); | ||
switch(bumper){ | ||
actuators.setVelocity(0.5, 0); | ||
Bumper bumper = sensors.getBumper(); | ||
// System.out.println(bumper); | ||
switch (bumper) { | ||
case CENTER: | ||
Actuators.getInstance().setLed(LedId.LED1, LedColor.RED); | ||
Actuators.getInstance().setLed(LedId.LED2, LedColor.RED); | ||
Actuators.getInstance().playSound(Sound.RECHARGE); | ||
actuators.setLed(LedId.LED1, LedColor.RED); | ||
actuators.setLed(LedId.LED2, LedColor.RED); | ||
actuators.playSound(Sound.RECHARGE); | ||
break; | ||
case LEFT: | ||
Actuators.getInstance().setLed(LedId.LED1, LedColor.RED); | ||
Actuators.getInstance().setLed(LedId.LED2, LedColor.BLACK); | ||
Actuators.getInstance().playSound(Sound.CLEANING_END); | ||
actuators.setLed(LedId.LED1, LedColor.RED); | ||
actuators.setLed(LedId.LED2, LedColor.BLACK); | ||
actuators.playSound(Sound.CLEANING_END); | ||
break; | ||
case RIGHT: | ||
Actuators.getInstance().setLed(LedId.LED1, LedColor.BLACK); | ||
Actuators.getInstance().setLed(LedId.LED2, LedColor.RED); | ||
Actuators.getInstance().playSound(Sound.CLEANING_START); | ||
actuators.setLed(LedId.LED1, LedColor.BLACK); | ||
actuators.setLed(LedId.LED2, LedColor.RED); | ||
actuators.playSound(Sound.CLEANING_START); | ||
break; | ||
default: | ||
Actuators.getInstance().setLed(LedId.LED1, LedColor.BLACK); | ||
Actuators.getInstance().setLed(LedId.LED2, LedColor.BLACK); | ||
actuators.setLed(LedId.LED1, LedColor.BLACK); | ||
actuators.setLed(LedId.LED2, LedColor.BLACK); | ||
break; | ||
} | ||
try { | ||
Thread.sleep(200); | ||
} catch (InterruptedException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |