<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.cognimbus.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Irebot</id>
		<title>cogniteam - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.cognimbus.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Irebot"/>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php/Special:Contributions/Irebot"/>
		<updated>2026-04-29T00:52:27Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.28.2</generator>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=599</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=599"/>
				<updated>2017-07-24T08:47:37Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// define pose like get pose from the robot and print it&lt;br /&gt;
		HamsterAPI::Pose pose = hamster.getPose();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,pose.toString());&lt;br /&gt;
			}&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
			std::stringstream stream;&lt;br /&gt;
			stream &amp;lt;&amp;lt; &amp;quot;Pose: &amp;quot; &amp;lt;&amp;lt; message_error.what();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, stream.str());&lt;br /&gt;
			}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Pose pose;&lt;br /&gt;
pose.setX(7.03);&lt;br /&gt;
pose.setY(1.35);&lt;br /&gt;
pose.setHeading(-135.0);&lt;br /&gt;
hamster.setInitialPose(pose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Goal goal;&lt;br /&gt;
goal.setX(3.0);&lt;br /&gt;
goal.setY(-2.0);&lt;br /&gt;
goal.setHeading(-135.0);&lt;br /&gt;
goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
//print all information about the goal&lt;br /&gt;
HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
// Thread --&amp;gt; sleep 1s&lt;br /&gt;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
// ask to the hamster  to navigate forward the goal&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
*&lt;br /&gt;
* HamsterAPIClientDataMessageReceiver.cpp&lt;br /&gt;
*&lt;br /&gt;
*  Created on: jun 21, 2016&lt;br /&gt;
*      Author: Ilan&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef RECEIVER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8108;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
					// Thread --&amp;gt; sleep 1&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
&lt;br /&gt;
				// define message of receiver : receiver_msg&lt;br /&gt;
				HamsterAPI::DataMessage receiver_msg(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, receiver_msg.toString());//print the receiver_msg&lt;br /&gt;
				// send the message from the receiver to the sender&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
				catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * HamsterAPIClientDataMessageSender.cpp&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: jun 21, 2016&lt;br /&gt;
 *      Author: Ilan&lt;br /&gt;
 *&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef SENDER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8107;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				// define the message from the sender : sender_msg&lt;br /&gt;
				HamsterAPI::DataMessage sender_msg(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print sender_msg&lt;br /&gt;
				hamster.sendDataMessage(sender_msg); // send message&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				// Thread --&amp;gt; sleep&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For launch correctly our communication between two Hamster we create a file IFDEF.h to launch the receiver before the sender.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
*&lt;br /&gt;
 * IFDEF.h&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: Jun 21, 2017&lt;br /&gt;
 *      Author: cogniteam&lt;br /&gt;
 *&lt;br /&gt;
&lt;br /&gt;
#ifndef IFDEF_H_&lt;br /&gt;
#define IFDEF_H_&lt;br /&gt;
&lt;br /&gt;
#define RECEIVER 1&lt;br /&gt;
#define SENDER 1&lt;br /&gt;
&lt;br /&gt;
#endif /* IFDEF_H_ */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * 2Goal2HamsterGlobal.cpp&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: Jun 22, 2017&lt;br /&gt;
 *      Author: Ilan&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	try{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
		params7.port = 8107;&lt;br /&gt;
		params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
		// Init the agent ID and the port&lt;br /&gt;
		HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params8;&lt;br /&gt;
		params8.port = 8108;&lt;br /&gt;
		params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
		// Init the agent ID and the port&lt;br /&gt;
		HamsterAPI::Hamster hamster8(8,params8);&lt;br /&gt;
&lt;br /&gt;
		// Define a new position and set X, Y, and heading&lt;br /&gt;
		HamsterAPI::Pose pose;&lt;br /&gt;
		pose.setX(7.03);&lt;br /&gt;
		pose.setY(1.35);&lt;br /&gt;
		pose.setHeading(-135.0);&lt;br /&gt;
		// Def pose like the initial position for hamster 7&lt;br /&gt;
		hamster7.setInitialPose(pose);&lt;br /&gt;
		pose.setX(6.02);&lt;br /&gt;
		pose.setY(1.98);&lt;br /&gt;
		// set new X, and Y and define the new pose like the initial position of hamster 8&lt;br /&gt;
		hamster8.setInitialPose(pose);&lt;br /&gt;
&lt;br /&gt;
		// thread --&amp;gt; sleep during 2s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(2000));&lt;br /&gt;
&lt;br /&gt;
		// define new goal and set X, Y, heading and goal Type&lt;br /&gt;
		HamsterAPI::Goal goal;&lt;br /&gt;
		goal.setX(3.0);&lt;br /&gt;
		goal.setY(-2.0);&lt;br /&gt;
		goal.setHeading(-135.0);&lt;br /&gt;
		goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
		//print all information about the goal&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
		// Thread --&amp;gt; sleep 1s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
		// ask to the hamster 7 to navigate forward the goal&lt;br /&gt;
		hamster7.navigateTo(goal);&lt;br /&gt;
&lt;br /&gt;
		while(hamster7.isConnected()){&lt;br /&gt;
			// during Hamster 7 is connected&lt;br /&gt;
			// define state like the navigation state all the time&lt;br /&gt;
			// if the status is still in progress so we continue&lt;br /&gt;
			// if the status is reach so we break the loop&lt;br /&gt;
			// if the status is fail so we return 1&lt;br /&gt;
			HamsterAPI::NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
							if(state.getStatus() == HamsterAPI::NS_IN_PROGRESS)&lt;br /&gt;
									continue;&lt;br /&gt;
							else if(state.getStatus() == HamsterAPI::NS_REACHED_GOAL)&lt;br /&gt;
								{&lt;br /&gt;
								HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal!&amp;quot;);&lt;br /&gt;
									break;&lt;br /&gt;
								}&lt;br /&gt;
							else&lt;br /&gt;
							{&lt;br /&gt;
								HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed.&amp;quot;);&lt;br /&gt;
								return 1;&lt;br /&gt;
							}&lt;br /&gt;
		}&lt;br /&gt;
		// hamster 7 is disconnect&lt;br /&gt;
		hamster7.disconnect();&lt;br /&gt;
&lt;br /&gt;
		// Thread --&amp;gt; sleep 1s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
		if(!hamster7.isConnected()){&lt;br /&gt;
			// if the hamster 7 is disconnect&lt;br /&gt;
			// define a new goal and we set X, Y, Heading and goal type&lt;br /&gt;
			HamsterAPI::Goal goal1;&lt;br /&gt;
			goal1.setX(4.76);&lt;br /&gt;
			goal1.setY(-2.46);&lt;br /&gt;
			goal1.setHeading(-135.0);&lt;br /&gt;
			goal1.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
&lt;br /&gt;
			// we print all information about goal1&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal1.toString());&lt;br /&gt;
&lt;br /&gt;
			//Thread --&amp;gt; 1s&lt;br /&gt;
			boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
			// and ask to hamster 8 to navigate forward goal1&lt;br /&gt;
			hamster8.navigateTo(goal1);&lt;br /&gt;
&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		while(hamster8.isConnected()){&lt;br /&gt;
			// during Hamster 8 is connected&lt;br /&gt;
			// define state like the navigation state all the time&lt;br /&gt;
			// if the status is still in progress so we continue&lt;br /&gt;
			// if the status is reach so we break the loop&lt;br /&gt;
			// if the status is fail so we return 1&lt;br /&gt;
&lt;br /&gt;
			HamsterAPI::NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
					if(state.getStatus() == HamsterAPI::NS_IN_PROGRESS)&lt;br /&gt;
						continue;&lt;br /&gt;
					else if(state.getStatus() == HamsterAPI::NS_REACHED_GOAL)&lt;br /&gt;
					{&lt;br /&gt;
						HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal!&amp;quot;);&lt;br /&gt;
						break;&lt;br /&gt;
					}&lt;br /&gt;
					else&lt;br /&gt;
					{&lt;br /&gt;
						HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed.&amp;quot;);&lt;br /&gt;
						return 1;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
		// disconnect hamster 8&lt;br /&gt;
				hamster8.disconnect();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error){&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=598</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=598"/>
				<updated>2017-07-24T08:44:34Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// define pose like get pose from the robot and print it&lt;br /&gt;
		HamsterAPI::Pose pose = hamster.getPose();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,pose.toString());&lt;br /&gt;
			}&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
			std::stringstream stream;&lt;br /&gt;
			stream &amp;lt;&amp;lt; &amp;quot;Pose: &amp;quot; &amp;lt;&amp;lt; message_error.what();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, stream.str());&lt;br /&gt;
			}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Pose pose;&lt;br /&gt;
pose.setX(7.03);&lt;br /&gt;
pose.setY(1.35);&lt;br /&gt;
pose.setHeading(-135.0);&lt;br /&gt;
hamster.setInitialPose(pose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Goal goal;&lt;br /&gt;
goal.setX(3.0);&lt;br /&gt;
goal.setY(-2.0);&lt;br /&gt;
goal.setHeading(-135.0);&lt;br /&gt;
goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
//print all information about the goal&lt;br /&gt;
HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
// Thread --&amp;gt; sleep 1s&lt;br /&gt;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
// ask to the hamster  to navigate forward the goal&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
*&lt;br /&gt;
* HamsterAPIClientDataMessageReceiver.cpp&lt;br /&gt;
*&lt;br /&gt;
*  Created on: jun 21, 2016&lt;br /&gt;
*      Author: Ilan&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef RECEIVER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8108;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
					// Thread --&amp;gt; sleep 1&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
&lt;br /&gt;
				// define message of receiver : receiver_msg&lt;br /&gt;
				HamsterAPI::DataMessage receiver_msg(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, receiver_msg.toString());//print the receiver_msg&lt;br /&gt;
				// send the message from the receiver to the sender&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
				catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * HamsterAPIClientDataMessageSender.cpp&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: jun 21, 2016&lt;br /&gt;
 *      Author: Ilan&lt;br /&gt;
 *&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef SENDER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8107;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				// define the message from the sender : sender_msg&lt;br /&gt;
				HamsterAPI::DataMessage sender_msg(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print sender_msg&lt;br /&gt;
				hamster.sendDataMessage(sender_msg); // send message&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				// Thread --&amp;gt; sleep&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * 2Goal2HamsterGlobal.cpp&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: Jun 22, 2017&lt;br /&gt;
 *      Author: Ilan&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	try{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
		params7.port = 8107;&lt;br /&gt;
		params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
		// Init the agent ID and the port&lt;br /&gt;
		HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params8;&lt;br /&gt;
		params8.port = 8108;&lt;br /&gt;
		params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
		// Init the agent ID and the port&lt;br /&gt;
		HamsterAPI::Hamster hamster8(8,params8);&lt;br /&gt;
&lt;br /&gt;
		// Define a new position and set X, Y, and heading&lt;br /&gt;
		HamsterAPI::Pose pose;&lt;br /&gt;
		pose.setX(7.03);&lt;br /&gt;
		pose.setY(1.35);&lt;br /&gt;
		pose.setHeading(-135.0);&lt;br /&gt;
		// Def pose like the initial position for hamster 7&lt;br /&gt;
		hamster7.setInitialPose(pose);&lt;br /&gt;
		pose.setX(6.02);&lt;br /&gt;
		pose.setY(1.98);&lt;br /&gt;
		// set new X, and Y and define the new pose like the initial position of hamster 8&lt;br /&gt;
		hamster8.setInitialPose(pose);&lt;br /&gt;
&lt;br /&gt;
		// thread --&amp;gt; sleep during 2s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(2000));&lt;br /&gt;
&lt;br /&gt;
		// define new goal and set X, Y, heading and goal Type&lt;br /&gt;
		HamsterAPI::Goal goal;&lt;br /&gt;
		goal.setX(3.0);&lt;br /&gt;
		goal.setY(-2.0);&lt;br /&gt;
		goal.setHeading(-135.0);&lt;br /&gt;
		goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
		//print all information about the goal&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
		// Thread --&amp;gt; sleep 1s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
		// ask to the hamster 7 to navigate forward the goal&lt;br /&gt;
		hamster7.navigateTo(goal);&lt;br /&gt;
&lt;br /&gt;
		while(hamster7.isConnected()){&lt;br /&gt;
			// during Hamster 7 is connected&lt;br /&gt;
			// define state like the navigation state all the time&lt;br /&gt;
			// if the status is still in progress so we continue&lt;br /&gt;
			// if the status is reach so we break the loop&lt;br /&gt;
			// if the status is fail so we return 1&lt;br /&gt;
			HamsterAPI::NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
							if(state.getStatus() == HamsterAPI::NS_IN_PROGRESS)&lt;br /&gt;
									continue;&lt;br /&gt;
							else if(state.getStatus() == HamsterAPI::NS_REACHED_GOAL)&lt;br /&gt;
								{&lt;br /&gt;
								HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal!&amp;quot;);&lt;br /&gt;
									break;&lt;br /&gt;
								}&lt;br /&gt;
							else&lt;br /&gt;
							{&lt;br /&gt;
								HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed.&amp;quot;);&lt;br /&gt;
								return 1;&lt;br /&gt;
							}&lt;br /&gt;
		}&lt;br /&gt;
		// hamster 7 is disconnect&lt;br /&gt;
		hamster7.disconnect();&lt;br /&gt;
&lt;br /&gt;
		// Thread --&amp;gt; sleep 1s&lt;br /&gt;
		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
		if(!hamster7.isConnected()){&lt;br /&gt;
			// if the hamster 7 is disconnect&lt;br /&gt;
			// define a new goal and we set X, Y, Heading and goal type&lt;br /&gt;
			HamsterAPI::Goal goal1;&lt;br /&gt;
			goal1.setX(4.76);&lt;br /&gt;
			goal1.setY(-2.46);&lt;br /&gt;
			goal1.setHeading(-135.0);&lt;br /&gt;
			goal1.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
&lt;br /&gt;
			// we print all information about goal1&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal1.toString());&lt;br /&gt;
&lt;br /&gt;
			//Thread --&amp;gt; 1s&lt;br /&gt;
			boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
			// and ask to hamster 8 to navigate forward goal1&lt;br /&gt;
			hamster8.navigateTo(goal1);&lt;br /&gt;
&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		while(hamster8.isConnected()){&lt;br /&gt;
			// during Hamster 8 is connected&lt;br /&gt;
			// define state like the navigation state all the time&lt;br /&gt;
			// if the status is still in progress so we continue&lt;br /&gt;
			// if the status is reach so we break the loop&lt;br /&gt;
			// if the status is fail so we return 1&lt;br /&gt;
&lt;br /&gt;
			HamsterAPI::NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
					if(state.getStatus() == HamsterAPI::NS_IN_PROGRESS)&lt;br /&gt;
						continue;&lt;br /&gt;
					else if(state.getStatus() == HamsterAPI::NS_REACHED_GOAL)&lt;br /&gt;
					{&lt;br /&gt;
						HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal!&amp;quot;);&lt;br /&gt;
						break;&lt;br /&gt;
					}&lt;br /&gt;
					else&lt;br /&gt;
					{&lt;br /&gt;
						HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed.&amp;quot;);&lt;br /&gt;
						return 1;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
		// disconnect hamster 8&lt;br /&gt;
				hamster8.disconnect();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error){&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=597</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=597"/>
				<updated>2017-07-24T08:43:45Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// define pose like get pose from the robot and print it&lt;br /&gt;
		HamsterAPI::Pose pose = hamster.getPose();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,pose.toString());&lt;br /&gt;
			}&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
			std::stringstream stream;&lt;br /&gt;
			stream &amp;lt;&amp;lt; &amp;quot;Pose: &amp;quot; &amp;lt;&amp;lt; message_error.what();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, stream.str());&lt;br /&gt;
			}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Pose pose;&lt;br /&gt;
pose.setX(7.03);&lt;br /&gt;
pose.setY(1.35);&lt;br /&gt;
pose.setHeading(-135.0);&lt;br /&gt;
hamster.setInitialPose(pose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Goal goal;&lt;br /&gt;
goal.setX(3.0);&lt;br /&gt;
goal.setY(-2.0);&lt;br /&gt;
goal.setHeading(-135.0);&lt;br /&gt;
goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
//print all information about the goal&lt;br /&gt;
HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
// Thread --&amp;gt; sleep 1s&lt;br /&gt;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
// ask to the hamster  to navigate forward the goal&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
*&lt;br /&gt;
* HamsterAPIClientDataMessageReceiver.cpp&lt;br /&gt;
*&lt;br /&gt;
*  Created on: jun 21, 2016&lt;br /&gt;
*      Author: Ilan&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef RECEIVER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8108;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
					// Thread --&amp;gt; sleep 1&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
&lt;br /&gt;
				// define message of receiver : receiver_msg&lt;br /&gt;
				HamsterAPI::DataMessage receiver_msg(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, receiver_msg.toString());//print the receiver_msg&lt;br /&gt;
				// send the message from the receiver to the sender&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
				catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * HamsterAPIClientDataMessageSender.cpp&lt;br /&gt;
 *&lt;br /&gt;
 *  Created on: jun 21, 2016&lt;br /&gt;
 *      Author: Ilan&lt;br /&gt;
 *&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef SENDER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8107;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				// define the message from the sender : sender_msg&lt;br /&gt;
				HamsterAPI::DataMessage sender_msg(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print sender_msg&lt;br /&gt;
				hamster.sendDataMessage(sender_msg); // send message&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				// Thread --&amp;gt; sleep&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=596</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=596"/>
				<updated>2017-07-24T08:41:20Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// define pose like get pose from the robot and print it&lt;br /&gt;
		HamsterAPI::Pose pose = hamster.getPose();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,pose.toString());&lt;br /&gt;
			}&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
			std::stringstream stream;&lt;br /&gt;
			stream &amp;lt;&amp;lt; &amp;quot;Pose: &amp;quot; &amp;lt;&amp;lt; message_error.what();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, stream.str());&lt;br /&gt;
			}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Pose pose;&lt;br /&gt;
pose.setX(7.03);&lt;br /&gt;
pose.setY(1.35);&lt;br /&gt;
pose.setHeading(-135.0);&lt;br /&gt;
hamster.setInitialPose(pose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Goal goal;&lt;br /&gt;
goal.setX(3.0);&lt;br /&gt;
goal.setY(-2.0);&lt;br /&gt;
goal.setHeading(-135.0);&lt;br /&gt;
goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
//print all information about the goal&lt;br /&gt;
HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
// Thread --&amp;gt; sleep 1s&lt;br /&gt;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
// ask to the hamster  to navigate forward the goal&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
*&lt;br /&gt;
* HamsterAPIClientDataMessageReceiver.cpp&lt;br /&gt;
*&lt;br /&gt;
*  Created on: jun 21, 2016&lt;br /&gt;
*      Author: Ilan&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;hamster_api_client_cpp/Hamster.h&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/date_time.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/thread.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;IFDEF.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef RECEIVER&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::HamsterClientParameters params;&lt;br /&gt;
		params.port = 8108;&lt;br /&gt;
		params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Init hamster with the agent id number&lt;br /&gt;
		HamsterAPI::Hamster hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
		while(hamster.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			try&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);// print&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
					// Thread --&amp;gt; sleep 1&lt;br /&gt;
					boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print&lt;br /&gt;
&lt;br /&gt;
				HamsterAPI::DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, boost::lexical_cast&amp;lt;std::string&amp;gt;(msg.getSourceAgentID()) + &amp;quot;=&amp;quot; + msg.getStringData());&lt;br /&gt;
&lt;br /&gt;
				// define message of receiver : receiver_msg&lt;br /&gt;
				HamsterAPI::DataMessage receiver_msg(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);//print&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, receiver_msg.toString());//print the receiver_msg&lt;br /&gt;
				// send the message from the receiver to the sender&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
			}&lt;br /&gt;
			// Message Issue or Connection Issue&lt;br /&gt;
				catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
				HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, message_error.what());&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(const HamsterAPI::HamsterError &amp;amp; connection_error)&lt;br /&gt;
	{&lt;br /&gt;
		HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=595</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=595"/>
				<updated>2017-07-24T08:38:35Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// define pose like get pose from the robot and print it&lt;br /&gt;
		HamsterAPI::Pose pose = hamster.getPose();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;,pose.toString());&lt;br /&gt;
			}&lt;br /&gt;
			catch(const HamsterAPI::HamsterError &amp;amp; message_error)&lt;br /&gt;
			{&lt;br /&gt;
			std::stringstream stream;&lt;br /&gt;
			stream &amp;lt;&amp;lt; &amp;quot;Pose: &amp;quot; &amp;lt;&amp;lt; message_error.what();&lt;br /&gt;
			HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, stream.str());&lt;br /&gt;
			}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Pose pose;&lt;br /&gt;
pose.setX(7.03);&lt;br /&gt;
pose.setY(1.35);&lt;br /&gt;
pose.setHeading(-135.0);&lt;br /&gt;
hamster.setInitialPose(pose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::Goal goal;&lt;br /&gt;
goal.setX(3.0);&lt;br /&gt;
goal.setY(-2.0);&lt;br /&gt;
goal.setHeading(-135.0);&lt;br /&gt;
goal.setGoalType(HamsterAPI::GT_GLOBAL_GOAL);&lt;br /&gt;
//print all information about the goal&lt;br /&gt;
HamsterAPI::Log::i(&amp;quot;Client&amp;quot;, goal.toString());&lt;br /&gt;
&lt;br /&gt;
// Thread --&amp;gt; sleep 1s&lt;br /&gt;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));&lt;br /&gt;
&lt;br /&gt;
// ask to the hamster  to navigate forward the goal&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=594</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=594"/>
				<updated>2017-07-24T08:33:18Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterAPI::HamsterClientParameters params7;&lt;br /&gt;
params7.port = 8107;&lt;br /&gt;
params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
// Init the agent ID and the port&lt;br /&gt;
HamsterAPI::Hamster hamster7(7,params7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=593</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=593"/>
				<updated>2017-07-18T12:13:04Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=592</id>
		<title>Category:HamsterAPICPPTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPICPPTest&amp;diff=592"/>
				<updated>2017-07-18T12:01:50Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: Created page with &amp;quot;== Tests in C++ ==  How our C++ tests works ?  before all test we have to be connected to the Robot so we beginning with the connection.  It is necessary to create an object h...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in C++ ==&lt;br /&gt;
&lt;br /&gt;
How our C++ tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPI&amp;diff=591</id>
		<title>Category:HamsterAPI</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPI&amp;diff=591"/>
				<updated>2017-07-18T12:00:16Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Hamster high level API (HamsterAPI)}}&lt;br /&gt;
[[Category:Hamster]]&lt;br /&gt;
=== High level overview of the HamsterAPI ===&lt;br /&gt;
&lt;br /&gt;
* HamsterAPI is a high level API used to communicate with the Hamster Robot. It is not installed by default in the current version although it might become standard in future versions.&lt;br /&gt;
* The API sits on top of ROS and enables to code without any ROS knowhow by using simple method calls available from within the Hamster class. Hence, the Hamster API allows to work with the ROS framework and all it's components without the need to install ROS or any ROS related dependencies.&lt;br /&gt;
* The Hamster API serves as a bridge to the ROS framework installed on the Hamster and enables to access data related to the Hamster vehicle such as sensor data, maps, and localization information.&lt;br /&gt;
* The Hamster API supports both C++ and Java&lt;br /&gt;
&lt;br /&gt;
== Hamster Client Server Architechture ==&lt;br /&gt;
[[File:HamsterClientServerArchitecture.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Hamster Client Server Architechture with Simulation and ROS bag ==&lt;br /&gt;
[[File:HamsterClientServerRosbag.png|400px]]==&lt;br /&gt;
&lt;br /&gt;
* Bag file recoreded: Records chosen messages by subscribing to a ROS topic. Configured from within the ROS framework with $rosbag.&lt;br /&gt;
* The Gazebo client displays actual 3D view simulation.&lt;br /&gt;
* The Gazebo Server is connected ro ROS and runs the simulation updaing the Gazebo Client.&lt;br /&gt;
&lt;br /&gt;
[[Category:HamsterAPIJavaTest]]&lt;br /&gt;
[[Category:HamsterAPICPPTest]]&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=590</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=590"/>
				<updated>2017-07-09T13:33:12Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=589</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=589"/>
				<updated>2017-07-09T13:32:39Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	tryThe purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach its goal the second robot does not go towards are objectives.&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of this test is to make two hamster go towards a definite goal one after the other.&lt;br /&gt;
As long as the first did not reach his goal the second robot does not go towards his objectives.&amp;lt;/br&amp;gt;&lt;br /&gt;
For this, first we initialize the positions of each robot and then we impose the goal for each of them.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=588</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=588"/>
				<updated>2017-07-09T13:26:53Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
				&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=587</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=587"/>
				<updated>2017-07-09T13:25:14Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TwoHamsterTwoGoal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class TwoHamsterTwoGoalGlobal {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
		&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
				&lt;br /&gt;
	try&lt;br /&gt;
	{&lt;br /&gt;
	// Init hamster with the agent id number and port&lt;br /&gt;
	HamsterClientParameters params7 = new HamsterClientParameters();&lt;br /&gt;
	// set port for agent 7&lt;br /&gt;
	params7.port = 8107;&lt;br /&gt;
	// set the base address&lt;br /&gt;
	params7.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster7 = new Hamster(7,params7);&lt;br /&gt;
					&lt;br /&gt;
	HamsterClientParameters params8 = new HamsterClientParameters();&lt;br /&gt;
	params8.port = 8108;&lt;br /&gt;
	params8.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
	Hamster hamster8 = new Hamster(8,params8);&lt;br /&gt;
								&lt;br /&gt;
	if(hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{&lt;br /&gt;
	// if hamster 7 is connected&lt;br /&gt;
	// DEF Initial position hamster 7 &amp;amp; 8&lt;br /&gt;
		Pose p = new Pose();&lt;br /&gt;
		p.setX(5.96f);&lt;br /&gt;
		p.setY(2.06f);&lt;br /&gt;
		p.setHeading(-135.0f);&lt;br /&gt;
		hamster7.setInitialPose(p);&lt;br /&gt;
		p.setX(7.1f);&lt;br /&gt;
		p.setY(1.30f);&lt;br /&gt;
		hamster8.setInitialPose(p);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
			//just for know if i come inside this if			&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ???? \n&amp;quot;);&lt;br /&gt;
		// goal and navigation for hamster 7 &lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// POSITION OF THE GOAL&lt;br /&gt;
		g.setX(3.55f);&lt;br /&gt;
		g.setY(-2.44f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		// GOAL TYPE IS GLOBAL&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 7 navigate from initial pose to goal&lt;br /&gt;
		hamster7.navigateTo(g);&lt;br /&gt;
	&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// status of navigation hamster 7&lt;br /&gt;
					&lt;br /&gt;
	while(hamster7.isConnected())&lt;br /&gt;
	{	&lt;br /&gt;
		// during hamster 7 is connected get the navigation state &lt;br /&gt;
		NavigationState state = hamster7.getNavigationState();&lt;br /&gt;
		// if the state is in progress, the navigation continue&lt;br /&gt;
		if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
			continue;&lt;br /&gt;
		else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
		{	&lt;br /&gt;
			// if the navigation state is reach so the goal is reach and we disconnect the hamster &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 7 !&amp;quot;);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			// else the goal failed and we print it &lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 7 &amp;quot;);&lt;br /&gt;
			break;		&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
	// deconnection hamster 7&lt;br /&gt;
	hamster7.disconnect();&lt;br /&gt;
					&lt;br /&gt;
	if(!hamster7.isConnected() &amp;amp;&amp;amp; hamster8.isConnected())&lt;br /&gt;
	{					&lt;br /&gt;
		// if goal hamster 7 is reach  or failed and hamster 8 is conected &lt;br /&gt;
		// define goal for hamster 8 and navigate to the position &lt;br /&gt;
			&lt;br /&gt;
		//just for know if i come inside this if&lt;br /&gt;
		//System.out.print(&amp;quot;---------- Tu passe par la ? &amp;quot;);&lt;br /&gt;
						&lt;br /&gt;
						&lt;br /&gt;
		Goal g = new Goal();&lt;br /&gt;
		// set the  position of the goal for hamster 8&lt;br /&gt;
		g.setX(4.01f);&lt;br /&gt;
		g.setY(-0.948f);&lt;br /&gt;
		g.setHeading(135.0f);&lt;br /&gt;
		//define type of goal for hamster 8 : global&lt;br /&gt;
		g.setGoalType(GoalType.GT_GLOBAL_GOAL);&lt;br /&gt;
		//tell to hamster 8 navigate from initial pose to goal&lt;br /&gt;
		hamster8.navigateTo(g);&lt;br /&gt;
	}&lt;br /&gt;
				&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		Thread.sleep(500);&lt;br /&gt;
	} catch (InterruptedException e) {&lt;br /&gt;
		// TODO Auto-generated catch block&lt;br /&gt;
		e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
					&lt;br /&gt;
		while(hamster8.isConnected())&lt;br /&gt;
		{&lt;br /&gt;
			// status of navigation Hamster 8&lt;br /&gt;
			NavigationState state = hamster8.getNavigationState();&lt;br /&gt;
			// if it's in progress so the hamster continue the navigation &lt;br /&gt;
			if(state.getStatus() == NavigationStatus.NS_IN_PROGRESS)&lt;br /&gt;
				continue;&lt;br /&gt;
			else if(state.getStatus() == NavigationStatus.NS_REACHED_GOAL)&lt;br /&gt;
			{	&lt;br /&gt;
				// if the navigation state is reach so the goal is reach and we disconnect the hamster&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Reached Goal : Hamster 8 !&amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				// else the goal failed and we print it &lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Goal Failed : Hamster 8 &amp;quot;);&lt;br /&gt;
				break;&lt;br /&gt;
			&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// disconnection Hamster 8&lt;br /&gt;
		hamster8.disconnect();&lt;br /&gt;
	}&lt;br /&gt;
	// Connection Issue&lt;br /&gt;
	catch(HamsterError connection_error)&lt;br /&gt;
				{&lt;br /&gt;
					Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
				}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=586</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=586"/>
				<updated>2017-07-09T13:19:03Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=585</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=585"/>
				<updated>2017-07-09T13:17:45Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: /* ReceiveDataMess */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
&lt;br /&gt;
      while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                         }&lt;br /&gt;
       }&lt;br /&gt;
		         &lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=584</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=584"/>
				<updated>2017-07-09T13:16:27Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {}&lt;br /&gt;
		}&lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
&lt;br /&gt;
     while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		  }&lt;br /&gt;
	  }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=583</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=583"/>
				<updated>2017-07-09T13:15:37Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {}&lt;br /&gt;
		}&lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8107;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(7,params);&lt;br /&gt;
while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		        }&lt;br /&gt;
	             }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=582</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=582"/>
				<updated>2017-07-09T13:14:26Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {}&lt;br /&gt;
		}&lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		        }&lt;br /&gt;
	             }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		           Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	               }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=581</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=581"/>
				<updated>2017-07-09T13:13:15Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {}&lt;br /&gt;
		}&lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SendDataMessage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
               while(hamster.isConnected()){&lt;br /&gt;
&lt;br /&gt;
			// define a new message &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			DataMessage sender_msg = new DataMessage(&amp;quot;Salut&amp;quot;,7,8);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;);&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, sender_msg.toString());// print &amp;quot;Sending data message&amp;quot; on the console &lt;br /&gt;
			hamster.sendDataMessage(sender_msg);// we print all information about the message : &amp;quot;Salut&amp;quot; send by 7 to 8&lt;br /&gt;
			&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Receiver to send msg&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			while(!hamster.hasDataMessages())&lt;br /&gt;
			{&lt;br /&gt;
				try &lt;br /&gt;
				{&lt;br /&gt;
					Thread.sleep(1000);&lt;br /&gt;
				} &lt;br /&gt;
				catch (InterruptedException e) &lt;br /&gt;
				{&lt;br /&gt;
					continue;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;); // print &amp;quot;got message &amp;quot;&lt;br /&gt;
&lt;br /&gt;
			DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); // print source ID message = message ex : 8=coucou &lt;br /&gt;
		     }&lt;br /&gt;
	           }&lt;br /&gt;
	                // Connection Issue&lt;br /&gt;
	               catch(HamsterError connection_error)&lt;br /&gt;
	              {&lt;br /&gt;
		       Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
	              }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=580</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=580"/>
				<updated>2017-07-09T13:10:45Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
=== ReceiveDataMess ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=579</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=579"/>
				<updated>2017-07-09T13:09:17Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
                                // print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
                                }&lt;br /&gt;
		         }&lt;br /&gt;
		                  // Connection Issue&lt;br /&gt;
		                catch(HamsterError connection_error)&lt;br /&gt;
		                {&lt;br /&gt;
			          Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		                 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=578</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=578"/>
				<updated>2017-07-09T13:04:57Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=577</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=577"/>
				<updated>2017-07-09T12:59:48Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have cr&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]eated a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
public class ReceiveDataMess {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		// TODO Auto-generated method stub&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			// Init the hamster with agent ID number and port &lt;br /&gt;
			HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
			params.port = 8108;&lt;br /&gt;
			params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
			Hamster hamster = new Hamster(8,params);&lt;br /&gt;
			while(hamster.isConnected())&lt;br /&gt;
			{&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Waiting for Sender to send msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				while(!hamster.hasDataMessages())&lt;br /&gt;
				{&lt;br /&gt;
					try &lt;br /&gt;
					{&lt;br /&gt;
						Thread.sleep(1000);&lt;br /&gt;
					} &lt;br /&gt;
					catch (InterruptedException e) &lt;br /&gt;
					{&lt;br /&gt;
						continue;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
				// print GOT msg&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Got msg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
				DataMessage msg = hamster.popLatestDataMessage();&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;&amp;quot; + msg.getSourceAgentID() + &amp;quot;=&amp;quot; + msg.getStringData()); //print ID source = message ex: 7=salut&lt;br /&gt;
&lt;br /&gt;
				// create new message to answer to the sender &lt;br /&gt;
				DataMessage receiver_msg = new DataMessage(&amp;quot;coucou&amp;quot;,8,7);&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, &amp;quot;Sending Data Message&amp;quot;); // print &amp;quot;sending Data Message&amp;quot;&lt;br /&gt;
				Log.i(&amp;quot;Client&amp;quot;, receiver_msg.toString()); // print information about the message&lt;br /&gt;
				hamster.sendDataMessage(receiver_msg);&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		// Connection Issue&lt;br /&gt;
		catch(HamsterError connection_error)&lt;br /&gt;
		{&lt;br /&gt;
			Log.i(&amp;quot;Client&amp;quot;,connection_error.what());&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=File:ReceiverDataMess.png&amp;diff=576</id>
		<title>File:ReceiverDataMess.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=File:ReceiverDataMess.png&amp;diff=576"/>
				<updated>2017-07-09T12:32:53Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: Irebot uploaded a new version of File:ReceiverDataMess.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ReceiverDataMess connects to the robot and waits for the message to send it to be able to respond.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=File:ReceiverDataMess.png&amp;diff=575</id>
		<title>File:ReceiverDataMess.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=File:ReceiverDataMess.png&amp;diff=575"/>
				<updated>2017-07-09T12:32:16Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: ReceiverDataMess connects to the robot and waits for the message to send it to be able to respond.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ReceiverDataMess connects to the robot and waits for the message to send it to be able to respond.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=574</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=574"/>
				<updated>2017-07-09T11:47:20Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To check the communication between two hamster we have developed two programs one for the sending of data and the other for the reception and the answer.&amp;lt;br&amp;gt;&lt;br /&gt;
We first run the ReceiveDataMess program before the SendDataMessage program because we need the receiver connected to be able to send a message to it.&lt;br /&gt;
&lt;br /&gt;
[[File:ReceiverDataMess|thumb|/Users/ilanrebot/Desktop/Capture d’écran 2017-07-09 à 14.32.02.png]]&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=573</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=573"/>
				<updated>2017-07-09T09:17:29Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void speedAndPosition(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function that recovers speed and position as long as we are connected to the robot.&lt;br /&gt;
The aim of this test is to verify the speed variations of the robots with respect to the position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void navigationTest(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We created a function for the robot to navigate from point A to point B.&lt;br /&gt;
To be done: &amp;lt;br&amp;gt;&lt;br /&gt;
-First define the point A as the initial points and therefore define the initial position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Pose initial = new pose; &lt;br /&gt;
initial.setX(4.0f);&lt;br /&gt;
initial.setY(2.0f);&lt;br /&gt;
initial.setHeading(120.0f);&lt;br /&gt;
hamster.setInitialPose(initial);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- In second time set goal to reach with position &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
Goal goal = new goal; &lt;br /&gt;
goal.setX(4.0f);&lt;br /&gt;
goal.setY(2.0f);&lt;br /&gt;
goal.setHeading(120.0f);&lt;br /&gt;
hamster.navigateTo(goal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Between the initial position and the goal we have to insert a thread.sleep().&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=572</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=572"/>
				<updated>2017-07-09T08:52:16Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the tests we created a test file where each test corresponds to a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
@Test&lt;br /&gt;
public void positionCompareTopics(){&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have created a function to get the position of the robot and print it as long as we are connected.&lt;br /&gt;
In a second time we start the topic on ROS and we compare the values.&lt;br /&gt;
The purpose of this test is to verify that the positioning of the robot makes sense&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=571</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=571"/>
				<updated>2017-07-09T08:16:04Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;br /&gt;
&lt;br /&gt;
To make the tests on the robots we use a software allowing us to know all the parameters of the robot such as the position on a map for example.&lt;br /&gt;
To launch this software type the following command lines :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 export ROS_MASTER_URI=http://10.0.2.1:11311&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The address after http correspond to the robot's base address.&lt;br /&gt;
&lt;br /&gt;
Now do an ifconfig and find the ip address that has just been added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
ROS_IP=10.0.2.     your address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then launch rviz.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=570</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=570"/>
				<updated>2017-07-09T07:58:18Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test with robots ==&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=569</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=569"/>
				<updated>2017-07-09T07:55:44Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
HamsterClientParameters params = new HamsterClientParameters();&lt;br /&gt;
params.port = 8101;&lt;br /&gt;
params.base_address = &amp;quot;10.0.2&amp;quot;;&lt;br /&gt;
Hamster hamster = new Hamster(1,params);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=568</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=568"/>
				<updated>2017-07-09T07:50:45Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
cd hamster_ws&lt;br /&gt;
source devel/setup.bash &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then launch Gazebo : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp hamster_api_simulation_server_and_gazbo_and_algs.launch &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=567</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=567"/>
				<updated>2017-07-09T07:47:24Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
roslaunch hamster_api_server_cpp    hamster_api_simulation_server_and_gazbo_and_algs.launch: 'slam'&amp;quot;&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=566</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=566"/>
				<updated>2017-07-09T07:45:24Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
rostopic pub /mapping_command std_msgs/String &amp;quot;data: 'slam'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use roslaunch hamster_api_server_cpp    hamster_api_simulation_server_and_gazbo_and_algs.launch&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=565</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=565"/>
				<updated>2017-07-09T07:44:28Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use roslaunch hamster_api_server_cpp    hamster_api_simulation_server_and_gazbo_and_algs.launch&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=564</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=564"/>
				<updated>2017-06-27T13:16:41Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== Test with simulation ==&lt;br /&gt;
&lt;br /&gt;
Before launch our test we have to launch our simulation software Gazebo.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=563</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=563"/>
				<updated>2017-06-27T13:07:16Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
== The tests we have done ==&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=562</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=562"/>
				<updated>2017-06-27T13:06:36Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;br /&gt;
&lt;br /&gt;
The tests we have done&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=561</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=561"/>
				<updated>2017-06-27T13:05:12Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will failed.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=560</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=560"/>
				<updated>2017-06-27T13:04:22Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will be failed.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=559</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=559"/>
				<updated>2017-06-27T13:04:07Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will be failed.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=558</id>
		<title>Category:HamsterAPIJavaTest</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPIJavaTest&amp;diff=558"/>
				<updated>2017-06-27T13:03:23Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: Created page with &amp;quot;== Tests in Java ==  How our Java tests works ?  before all test we have to be connected to the Robot so we beginning with the connection.  It is necessary to create an object...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tests in Java ==&lt;br /&gt;
&lt;br /&gt;
How our Java tests works ?&lt;br /&gt;
&lt;br /&gt;
before all test we have to be connected to the Robot so we beginning with the connection.&lt;br /&gt;
&lt;br /&gt;
It is necessary to create an object hamster and it use all information about the Hamster class.&lt;br /&gt;
Then we use we create a new HamsterClientParameters. It use to initialize the port and the base address of the Robot.&lt;br /&gt;
and now we use the object Hamster that we created before with two parameters :&lt;br /&gt;
1- number agent of the robot&lt;br /&gt;
2- the name of the HamsterClientParameters that we created before.&lt;br /&gt;
&lt;br /&gt;
We put this little function in a try catch of function with throws exception because if we can't be connected to the robot all the test after will be failed.&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=Category:HamsterAPI&amp;diff=557</id>
		<title>Category:HamsterAPI</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=Category:HamsterAPI&amp;diff=557"/>
				<updated>2017-06-27T13:02:27Z</updated>
		
		<summary type="html">&lt;p&gt;Irebot: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Hamster high level API (HamsterAPI)}}&lt;br /&gt;
[[Category:Hamster]]&lt;br /&gt;
=== High level overview of the HamsterAPI ===&lt;br /&gt;
&lt;br /&gt;
* HamsterAPI is a high level API used to communicate with the Hamster Robot. It is not installed by default in the current version although it might become standard in future versions.&lt;br /&gt;
* The API sits on top of ROS and enables to code without any ROS knowhow by using simple method calls available from within the Hamster class. Hence, the Hamster API allows to work with the ROS framework and all it's components without the need to install ROS or any ROS related dependencies.&lt;br /&gt;
* The Hamster API serves as a bridge to the ROS framework installed on the Hamster and enables to access data related to the Hamster vehicle such as sensor data, maps, and localization information.&lt;br /&gt;
* The Hamster API supports both C++ and Java&lt;br /&gt;
&lt;br /&gt;
== Hamster Client Server Architechture ==&lt;br /&gt;
[[File:HamsterClientServerArchitecture.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Hamster Client Server Architechture with Simulation and ROS bag ==&lt;br /&gt;
[[File:HamsterClientServerRosbag.png|400px]]==&lt;br /&gt;
&lt;br /&gt;
* Bag file recoreded: Records chosen messages by subscribing to a ROS topic. Configured from within the ROS framework with $rosbag.&lt;br /&gt;
* The Gazebo client displays actual 3D view simulation.&lt;br /&gt;
* The Gazebo Server is connected ro ROS and runs the simulation updaing the Gazebo Client.&lt;br /&gt;
&lt;br /&gt;
[[Category:HamsterAPIJavaTest]]&lt;/div&gt;</summary>
		<author><name>Irebot</name></author>	</entry>

	</feed>