<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.cognimbus.com/index.php?action=history&amp;feed=atom&amp;title=HamsterPythonExample3</id>
		<title>HamsterPythonExample3 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.cognimbus.com/index.php?action=history&amp;feed=atom&amp;title=HamsterPythonExample3"/>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=HamsterPythonExample3&amp;action=history"/>
		<updated>2026-06-14T21:48:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.28.2</generator>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=HamsterPythonExample3&amp;diff=882&amp;oldid=prev</id>
		<title>Ariy at 09:18, 24 March 2019</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=HamsterPythonExample3&amp;diff=882&amp;oldid=prev"/>
				<updated>2019-03-24T09:18:47Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 09:18, 24 March 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l54&quot; &gt;Line 54:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 54:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; $ python example3.py&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; $ python example3.py&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Ex 3 ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* change this program to continue moving while trying to avoid obstacles&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key cogniteam_wiki:diff:version:1.11a:oldid:878:newid:882 --&gt;
&lt;/table&gt;</summary>
		<author><name>Ariy</name></author>	</entry>

	<entry>
		<id>http://wiki.cognimbus.com/index.php?title=HamsterPythonExample3&amp;diff=878&amp;oldid=prev</id>
		<title>Ariy: Created page with &quot;=== Python Example 3 === File:VID_20190319_171636.mp4  * The Hamster robot is a Ackermann steering system https://en.wikipedia.org/wiki/Ackermann_steering_geometry  *...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.cognimbus.com/index.php?title=HamsterPythonExample3&amp;diff=878&amp;oldid=prev"/>
				<updated>2019-03-24T09:04:59Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== Python Example 3 === &lt;a href=&quot;/index.php/File:VID_20190319_171636.mp4&quot; title=&quot;File:VID 20190319 171636.mp4&quot;&gt;File:VID_20190319_171636.mp4&lt;/a&gt;  * The Hamster robot is a Ackermann steering system &lt;a href=&quot;/index.php?title=Https://en.wikipedia.org/wiki/Ackermann_steering_geometry&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Https://en.wikipedia.org/wiki/Ackermann steering geometry (page does not exist)&quot;&gt;https://en.wikipedia.org/wiki/Ackermann_steering_geometry&lt;/a&gt;  *...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Python Example 3 ===&lt;br /&gt;
[[File:VID_20190319_171636.mp4]]&lt;br /&gt;
&lt;br /&gt;
* The Hamster robot is a Ackermann steering system [[https://en.wikipedia.org/wiki/Ackermann_steering_geometry]] &lt;br /&gt;
* This example drives the robot forward until it senses from the Lidar that there is less than a meter free ahead of it&lt;br /&gt;
* Motion commands should be usually published at 10Hz.&lt;br /&gt;
* If no motion command arrives to the robot after a second (10 messages period) the robot will stop&lt;br /&gt;
* Hence we send an empty message (with speed 0) to stop the robot immediately once the area is blocked ahead of it, otherwise it would stop closer to the obstacle due to the delay &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line='line'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from sensor_msgs.msg import LaserScan&lt;br /&gt;
from ackermann_msgs.msg import AckermannDriveStamped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pub = rospy.Publisher('/agent14/ackermann_cmd',AckermannDriveStamped, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
def is_free(ranges ,start_index, end_index ,min_distance):&lt;br /&gt;
	#sub array from angle to angle&lt;br /&gt;
	s_ranges = ranges[start_index:end_index]&lt;br /&gt;
	#filter the array &lt;br /&gt;
	b_ranges = filter(lambda x: x &amp;lt;= min_distance, s_ranges)&lt;br /&gt;
	return len(b_ranges) == 0&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
def callback(msg):&lt;br /&gt;
	global pub		    &lt;br /&gt;
	if is_free(msg.ranges,160,200,1):&lt;br /&gt;
	    ack_msg = AckermannDriveStamped()&lt;br /&gt;
	    ack_msg.header.stamp = rospy.Time.now()&lt;br /&gt;
	    ack_msg.header.frame_id = 'your_frame_here'&lt;br /&gt;
	    ack_msg.drive.steering_angle = 0&lt;br /&gt;
	    ack_msg.drive.speed = 1&lt;br /&gt;
	    pub.publish(ack_msg)&lt;br /&gt;
	else:&lt;br /&gt;
	    ack_msg = AckermannDriveStamped()&lt;br /&gt;
	    pub.publish(ack_msg)&lt;br /&gt;
	    &lt;br /&gt;
rospy.init_node('driving_hamster')&lt;br /&gt;
&lt;br /&gt;
#Put your Hamster number instead of agent&amp;lt;number&amp;gt;&lt;br /&gt;
#The agent number is printed on the Hamster cover &lt;br /&gt;
sub = rospy.Subscriber('/agent14/scan', LaserScan, callback)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
rospy.spin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To execute save this example in example3.py and type in the terminal &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line='line'&amp;gt;&lt;br /&gt;
 $ python example3.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ariy</name></author>	</entry>

	</feed>