-
Notifications
You must be signed in to change notification settings - Fork 5
Using ImcShell.jar
IMC Shell is a simple program that allows you to listen and send IMC messages from a command line.
- For compiling you need a Java compiler version 1.7+ (JDK) and the Apache Ant build system.
- On the directory where you checked out imcjava, run the command
ant ImcShell.jar
. This will create the file dist/ImcShell.jar. - To test the generated jar file enter the command
java -jar dist/ImcShell.jar
- For running you need a Java Runtime Environment 1.7+ (JRE).
- The file ImcShell.jar is an executable Java ARchive (jar). To run it just type
java -jar path/to/ImcShell.jar
.
While running you can access a list of available commands by using the command ?list
. Also you can get details about a specific command by using the command ?help
. To give an example, if you would like to know the arguments and description of the command bind, you would type:
?> ?help bind
When you start the shell you are given a clean environment with no messages stored. In order to add messages to your environment (for later composing other messages or sending them to the network) you should use the command create. Examples:
In order to create a message named myState of type EstimatedState and initializing it with default values:
?> create myState EstimatedState
To create a message named pc of type PlanControl and initializing it with given values. Any field values not specified will be initialized defaults. Also note that the value of field arg is assumed to be message previously stored in the environment:
?> create pc PlanControl type=REQUEST op=START arg=m1
You can also initialize messages by specifying valid (Java Script) expressions (escaping them with `):
?> create state EstimatedState lat=`3.1458+java.lang.Math.toRadians(41)`
After creation messages can still be changed by using the command change. To change the field lat of a message named m1 you could use:
?> change m1 lat=0.712399
You can replicate messages in the environment simply using the command copy. The following command will replicate an existing message (named m1) into a new message named newMsg:
?> copy m1 newMsg
When you create messages or you receive messages from the network these will get stored in the shell's environment. In order to access the current environment you can use the commands env and print. Printing all the currently available messages (in the environment):
?> env
Getting the value of a message named pc in the environment:
?> print pc
Getting the value of a field of a message in the environment:
?> print pc/arg
Getting the value of a field of a field of a message in the environment:
?> print pc/arg/lat
You can also use the environment when creating or changing messages like in the following (assuming there is a message named go1 with a field lat in the environment):
?> create go2 Goto lat=`${go1/lat}+0.5`
After a message is created, it can be sent to the network via UDP using the command send. If you know the port and hostname of the destination you can use the following command to send an existing pc message:
?> send localhost 6002 pc
You can also specify an IP address instead of the host name:
?> send 127.0.0.1 6002 pc
Moreover if you previously received an Announce message from the system you want to send the message to, you can send to it directly (you must have activated discovery as described in the following section):
?> send lauv-xtreme-2 pc