版主: wanchong , wangyu , eepwwp , firedom |
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
最后面的打开网络,有点麻烦,每次都有手动敲两个命令 其实可以通过配置文件自动完成,编辑/etc/network/interfaces文件
root@qomo-galileo:~# vim /etc/network/interfaces 然后可以重启网络,使用新的配置,也可以重启机器,这里只是重启网络就好了
root@qomo-galileo:~# /etc/init.d/networking restart 然后看看网络情况,可以获取IP了
|
此帖由qomoliao于2014-08-25 11:04:19最后编辑
|
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
参考: - http://github.liaoxuefeng.com/sinaweibopy/ - https://github.com/michaelliao/sinaweibopy/wiki/OAuth2-HOWTO - http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#.E7.A7.BB.E5.8A.A8.E5.BA.94.E7.94.A8.E7.9A.84.E9.AA.8C.E8.AF.81.E6.8E.88.E6.9D.83 一、安装 安装pip
qomo@qomo-galileo:~$ sudo apt-get install python-pip 安装新浪微博SDK
qomo@qomo-galileo:~$ sudo pip install sinaweibopy 二、申请微博开发平台 我只告诉你网址,要怎么做,相信大家都知道。http://open.weibo.com/index.php 三、创建应用 我选择的是其他应用
应用地址应该是无所谓的 然后填写一些必填的项目,保存 然后是设置授权和授权回调页,授权回调页是官方提供的一个地址
取消授权回调页不知道填什么,我就填了个一样的
最后还需要添加测试账号,要不然是不能够获得授权的,只有测试账号的用户能够使用这个应用。
四、python发微博 ssh或者通过串口登陆伽利略开发板,进入python命令行 输入图片中的命令
其中APP_KEY、APP_SECRET在应用基本信息里可以查到。 CALLBACK_URL(回调地址)用我们之前设置的
复制最后生成的URL,在浏览器里打开,然后点击授权,会跳转到如下页面 记下地址栏里code=后面的字符串
最后,运行下面代码
我们可以开始发第一条Hello World了
|
此帖由qomoliao于2014-08-27 19:09:51最后编辑
|
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
至于其他微博命令,就参考我给的两个链接好了
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
pyGalileo库:https://github.com/galileo-chofrock/pyGalileo 舵机:http://www.guokr.com/article/5292/ http://www.geek-workshop.com/thread-70-1-1.html 之前玩arduino的盾板,刚好可以用上 通过盾板和3Pin线与热释红外传感器,与舵机进行连接,非常方便 这里只是测试对这两个模块的使用,所以就随便摆放着,没有做什么架子之类的东西,这个以后在做
再来一张热释红外的特写,可以看到两个变阻器。 通过后面的测试发现,这两个旋钮貌似分别调节灵敏度和探测角度的
一、 Hello pyGalileo pyGalileo是一个python库,通过这个库可以用与arduino非常相似的代码进行编程 它实际上操作的是GPIO,这个在前面的某楼有提到过 到这个网站(https://github.com/galileo-chofrock/pyGalileo)把库程序下载下来,然后通过任何办法拷贝到galileo里 我是把galileo做成了个samba服务器,文件的上传下载都非常方便 这个不需要按github上的安装方法,拷贝到你需要它的目录下就可以了 因为当前路径本来就是python搜索库文件的路径之一 对于arduino来说,Hello World就是Blink,我们看看它的blink程序 #!/usr/bin/env python import sys #galileo_path = "/media/mmcblk0p1/"; #我们把这个程序 # 放在pyGalileo所在的目录下,它是能够找到pyGalileo库的,就不必用这三句添加库所在的路径了 #if galileo_path not in sys.path: # sys.path.append(galileo_path); from pyGalileo import * '''/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ ''' #// the setup routine runs once when you press reset: def setup(): pinMode(led, OUTPUT); def loop(): digitalWrite(led, HIGH); #// turn the LED on (HIGH is the voltage level) delay(1000); #// wait for a second digitalWrite(led, LOW); #// turn the LED off by making the voltage LOW delay(1000); #// wait for a second #When the file is run from the command line, this fucntion will execute. #This function just calls setup once, then calls loop over and over. if __name__ == "__main__": led = 13; setup(); while(1): loop(); 保存代码后,在命令行运行 qomo@qomo-galileo:~$ sudo python blink.py 就可以看到盾板上的LED灯在闪烁,注意:galileo板上的LED是不闪的,因为那个LED并不是接着13号接口对应的GPIO上???这一句是我的揣度,望高手澄清一下 看视频说话
二、热释红外探测器 热释红外探测器能够探测人或者动物的走动 当它探测到的红外热有变化时,就会产生一个高电平信号,我们用digitalRead就能够把这个信号读出来 下面是代码,修改至pyGalileo的Example里的Button.py
#!/usr/bin/env python import sys #galileo_path = "/media/mmcblk0p1/"; #if galileo_path not in sys.path: # sys.path.append(galileo_path); from pyGalileo import * '''/* Button Turns on and off a light emitting diode(LED) connected to digital pin 13, when detect someone get close to the senser attached to pin 4. The circuit: * LED attached from pin 13 to ground * IRdetect senser attached to pin 2 5V and GND * Note: on most Arduinos there is already an LED on the board attached to pin 13. created 2005 by DojoDave modified 30 Aug 2011 by Tom Igoe modified 27 Aug 2014 by QomoLiao This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */''' #// constants won't change. They're used here to #// set pin numbers: #const int buttonPin = 2; // the number of the pushbutton pin irPin = 4; #const int ledPin = 13; // the number of the LED pin ledPin = 13; #// variables will change: #int buttonState = 0; // variable for reading the pushbutton status irState = 0; #void setup() { def setup(): #// initialize the LED pin as an output: pinMode(ledPin, OUTPUT); #// initialize the pushbutton pin as an input: pinMode(irPin, INPUT); #} #void loop(){ def loop(): while(1): #// read the state of the pushbutton value: irState = digitalRead(irPin); #// check if the pushbutton is pressed. #// if it is, the buttonState is HIGH: if (irState == HIGH):# { #// turn LED on: digitalWrite(ledPin, HIGH); #} else:# { #// turn LED off: digitalWrite(ledPin, LOW); #} #} setup(); loop()
舵机是通过脉冲控制的。 最小的角度对应1ms的脉冲、中间角度对应1.5ms脉冲,最大角对应2ms脉冲
参考上面两个图片里面的信息,写了如下的控制程序 pyGalileo里没有延迟微秒的函数,所以这里自己写了这个函数,以后会视情况看是否将他放到pyGalileo里 这个程序只是实现了对舵机的控制,还不是很方便使用 以后的修改将会把它封装到函数或者类里,通过角度参数使用
#!/usr/bin/env python # coding=utf-8 import sys from pyGalileo import * servoPin = 5 def delaymicro(mcTime): """ delaymicro(mcTime) Description: Delays the execution of the script for number of microseconds. Input: mcTime - (int) number of microseconds to delay Returns: None Example: delaymicro(500); - Delay the script for 500 microseconds. """ time.sleep(mcTime/1000000); def setup(): pinMode(servoPin, OUTPUT) def loop(): while(1): digitalWrite(servoPin, HIGH) delaymicro(1500) digitalWrite(servoPin, LOW) delay(20) setup() loop()
|
此帖由qomoliao于2014-08-28 19:12:51最后编辑
|
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
在 11~13楼:制作使用debian系统 的时候,我说
其实,后来还是碰到了这个问题,不过我也没有找到解决方案 不过,后来在这个帖子里找到了一个别人做的镜像,解决了ssh的问题 https://communities.intel.com/thread/51190?start=0&tstart=0 http://sourceforge.net/projects/galileodebian/files/SD%20card%20Image/ 而且,作者做了一个sourceforge页面分享他的作品,镜像安装过程非常简单。
最后,还有一点需要注意,你不能apt-get update和apt-get upgrade升级系统 因为我升级了之后ssh也会出现前面提到的问题,估计最新的ssh包有问题吧 |
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
qomoliao的原帖 在 11~13楼:制作使用debian系统 的时候,我说
其实,后来还是碰到了这个问题,不过我也没有找到解决方案 不过,后来在这个帖子里找到了一个别人做的镜像,解决了ssh的问题 https://communities.intel.com/thread/51190?start=0&tstart=0 http://sourceforge.net/projects/galileodebian/files/SD%20card%20Image/ 而且,作者做了一个sourceforge页面分享他的作品,镜像安装过程非常简单。
最后,还有一点需要注意,你不能apt-get update和apt-get upgrade升级系统 因为我升级了之后ssh也会出现前面提到的问题,估计最新的ssh包有问题吧 你也可以按照这个帖子里的办法,手动编译ssh 5.9 的版本,同样能够解决问题 http://wiki.ros.org/IntelGalileo/Debian |
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
你也可以按照这个帖子里的办法,手动编译ssh 5.9 的版本,同样能够解决问题 http://wiki.ros.org/IntelGalileo/Debian
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
经验丰富的人一眼应该就能够看出我之前的舵机控制是有问题的 因为delay用的是python里面的方法,这个delay毫秒还可以,但是 舵机控制里面的脉冲都是微秒计算的 所以这个方法并不能控制舵机 本来伽利略可以用arduino的库进行各个硬件模块控制的, 这个确实很方便 但是,做了debian系统后,arduino的sketch就不能上传使用了 也查了官网的论坛 :https://communities.intel.com/search.jspa?q=debian+sketch 这看起来是个硬伤,不知道“宝宝陪护机器人”的作者是如何能够操作超声波测距等模块的 应该使用的是官方的linux系统,如果不是希望能够得到分享
既然舵机无法控制了,就得寻找替代方案,用来控制喂食 我找出了个L298N电机驱动和一个直流电机作为替代
再使用两个限位开关作为,测量开门关门状态
|
qomoliao
![]()
最后登陆时间:2014-07-08 13:18:17 |
介绍一下喂猫机器人的骨架 对于没有3D打印机的屌丝创客来说,只能做到下面的样子了 本来打算用PVC管材来制作的,在购买的过程中遇到了一些挫折,就就地取材 找了一些瓶瓶罐罐DIY一个屌丝喂猫机器人吧
因为舵机控制还有一些问题,改用电机做控制猫粮的阀门 用PVC线槽剪了个门,装到电机轴上
这个电机是以前购买其他东西时,顺便购买的,正好能够用上 电机轴上有个平的切口,在这里插上一些废料,起到固定的作用,防止打滑
罐子原来是装麦片的,将一个角切开,与PVC线槽连接,用502和胶枪连接都可以
打开的状态,用的电机还不错,力矩挺大,应该不会有猫粮自动漏下来的情况发生
在门边装上一个限位开关,保证门完全闭合 本来打算还装一个开门的限位开关,后来偷懒省了,通过开门时间调试
把最关键的板子也装上,装另一面,保证重心
继续用PVC线槽DIY底座,保证罐子的出口倾斜朝下,利用重力让猫粮掉下来 没手没脚的,看起来真有点不像机器人 还希望下次MakeBlock之类的公司赞助点机械组件;-)
这样就比较稳固了 装上红外传感器和摄像头,一切就差不多了
|