Skip to content

make smallcircle.py and add comment in detail #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dxl_armed_turtlebot/launch/smallcircle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python

import rospy #rosにおけるpythonのクライアントライブラリ
from opencv_apps.msg import RotatedRectStamped #opencv_apps/RotatedRectStampedのメッセージタイプを配信に再利用できる
from image_view2.msg import ImageMarker2 #image_view2/ImageMarker2のメッセージタイプを配信に再利用できる
from geometry_msgs.msg import Point #geometry_msgs/Pointのメッセージタイプを配信に再利用できる

def cb(msg):
print msg.rect #受け取ったメッセージの矩形情報を垂れ流す
marker = ImageMarker2() #小さい丸のマーカーの型を作る
marker.type = 0 #マーカーの種類を決定
marker.position = Point(msg.rect.center.x, msg.rect.center.y, 0) #マーカーの位置を決定
pub.publish(marker) #作成されたメッセージ(marker)を現在のトピック(/Image_marker)に送信する

rospy.init_node('client') #rospyにノード名をclientとして通知する
rospy.Subscriber('/camshift/track_box', RotatedRectStamped, cb) #ノードがopencv_apps.RotatedRectStampedの方のcbトピックから購読することを宣言している
pub = rospy.Publisher('/image_marker', ImageMarker2) #ノードが/image_markerのトピックにImageMarker2の型でメッセージを送っている
rospy.spin() #プロセスが終了するまで、ずっとノードを保持する
24 changes: 24 additions & 0 deletions dxl_armed_turtlebot/task/task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Joy
from kobuki_msgs.msg import Led

pub = rospy.Publisher('/mobile_base/commands/led1', Led)
def callback(data):
print(rospy.get_caller_id()+"joy\n %s", data.buttons)
if data.buttons[5] == 1:
pub.publish(data.buttons[4]+1)
return


def joy():
rospy.init_node('myJoy', anonymous=True)
rospy.Subscriber("/joy", Joy, callback)

print("spin")
rospy.spin()

if __name__ == "__main__":
print("main")
joy()
18 changes: 18 additions & 0 deletions dxl_armed_turtlebot/task/task5.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(load "package://dxl_armed_turtlebot/euslisp/dxl-armed-turtlebot-interface.l")
(dxl-armed-turtlebot-init)

(ros::load-ros-manifest "sensor_msgs")
(ros::roseus "joylistener" :anonymous t)

(defun joy-cb (msg)
(let ((buttons))
(progn
(print (list 'joy (send msg :buttons)))
(setq buttons (send msg:buttons))
(cond
(= buttons aref(buttons 4))
(send *ri* :go-velocity 0.1 0 0)
)
)
)

19 changes: 19 additions & 0 deletions lisp/#listener.l#
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env roseus

(ros::load-ros-manifest "kobuki_msgs")
(ros::roseus "listener" :anonymous t)

;; callback function
(defun imudata-cb (msg)
(print (list 'button (send msg :button)))
(print (list 'state (send msg :state)))
)
(ros::subscribe "/mobile_base/events/button" kobuki_msgs::ButtonEvent #'imudata-cb)



(ros::rate 10)
(do-until-key
(ros::sleep)
(ros::spin-once))
(exit)
19 changes: 19 additions & 0 deletions lisp/listener.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env roseus

(ros::load-ros-manifest "kobuki_msgs")
(ros::roseus "listener" :anonymous t)

;; callback function
(defun imudata-cb (msg)
(print (list 'button (send msg :button)))
(print (list 'state (send msg :state)))
)
(ros::subscribe "/mobile_base/events/button" kobuki_msgs::ButtonEvent #'imudata-cb)



(ros::rate 10)
(do-until-key
(ros::sleep)
(ros::spin-once))
(exit)
19 changes: 19 additions & 0 deletions turtleboteus/euslisp/listener.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env roseus

(ros::load-ros-manifest "kobuki_msgs")
(ros::roseus "listener" :anonymous t)

;; callback function
(defun imudata-cb (msg)
(print (list 'button (send msg :button)))
(print (list 'state (send msg :state)))
)
(ros::subscribe "/mobile_base/events/button" kobuki_msgs::ButtonEvent #'imudata-cb)



(ros::rate 10)
(do-until-key
(ros::sleep)
(ros::spin-once))
(exit)
55 changes: 55 additions & 0 deletions turtleboteus/euslisp/task3.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(turtlebot-init)

(ros::load-ros-manifest "sensor_msgs")
(ros::roseus "listener" :anonymous t)

;; callback function
(defun battery-cb (msg)
(progn
(print (list 'laptopcharge (send msg :percentage)))
(when (< 50 (send msg :percentage))
(send *ri* :publish-sound :error)
)))

(ros::subscribe "/laptop_charge" sensor_msgs::BatteryState #'battery-cb)



(setq state 0)
(setq wait 0)
(ros::rate 100)
(progn
(while t
;(print (send *ri* :laptop-charge))
(ros::spin-once)
;(print "here")
(cond
((= state 0)
(if (equal (send *ri* :state :bumper-vector) #f(0.0 0.0 0.0))
(send *ri* :go-velocity 0 0 0)
(setq state 1)
)
)
((= state 1)
(if (> wait 100)
(progn
(setq state 0)
(setq wait 0)
)
(progn
(send *ri* :go-velocity -0.1 0 30)
(setq wait (+ wait 1))
)
)
)
(t
(print "default")
)
)
)
(send *ri* :go-velocity 0 0 0)
)