小编far*_*edo的帖子

Turtlebot订户pointcloud2在Gazebo模拟器中显示颜色,但在机器人中没有

我正在使用华硕Xtion PRO LIVE相机订阅turtlebot(深度学习版)上的主题"/camera/depth/points"和消息PointCloud2.

我在gazebo模拟器环境下使用了下面的python脚本,我可以成功接收x,y,z和rgb值.

但是,当我在机器人中运行它时,缺少rgb值.

这是我的turtlebot版本或相机的问题还是我必须指定我想要接收的地方PointCloud2 type="XYZRGB"?还是同步问题?有任何线索,谢谢!

#!/usr/bin/env python
import rospy
import struct
import ctypes
import sensor_msgs.point_cloud2 as pc2
from sensor_msgs.msg import PointCloud2

file  = open('workfile.txt', 'w')

def callback(msg):

    data_out = pc2.read_points(msg, skip_nans=True)

    loop = True
    while loop:
        try:
            int_data = next(data_out)
            s = struct.pack('>f' ,int_data[3])
            i = struct.unpack('>l',s)[0]
            pack = ctypes.c_uint32(i).value

            r = (pack & 0x00FF0000)>> 16
            g = (pack & 0x0000FF00)>> 8
            b = (pack & 0x000000FF)

            file.write(str(int_data[0])+","+str(int_data[1])+","+str(int_data[2])+","+str(r)+","+str(g)+","+str(b)+"\n")

        except Exception as e: …
Run Code Online (Sandbox Code Playgroud)

python rgb point-clouds ros point-cloud-library

6
推荐指数
1
解决办法
835
查看次数

如何设置发送带有邮件gem的HTML邮件?

我正在使用Mail gem发送电子邮件.这是我的代码:

require 'mail'
require 'net/smtp'

Mail.defaults do

delivery_method :smtp, { :address              => "smtp.arrakis.es",
                       :port                 => 587,
                       :domain               => 'webmail.arrakis.com',
                       :user_name            => 'myname@domain.com',
                       :password             => 'pass',
                       :authentication       => 'plain',
                       :enable_starttls_auto => true  }

end

Mail::ContentTypeField.new("text/html") #this doesnt work

msgstr= File.read('text2.txt')

list.each do |entity|
    begin
        Mail.deliver do
            from    'myname@domain.com'
            to      "#{entity}"
            subject 'a good subject'
            body   msgstr
        end
    rescue => e
    end

end
end
Run Code Online (Sandbox Code Playgroud)

我不知道如何设置内容类型,以便我可以将我的电子邮件格式化为html.虽然我实际上只是希望能够像我的电子邮件客户端那样定义粗体文本:粗体文本.有没有人知道我需要指定哪种内容类型才能实现这一目标,以及如何使用邮件实现它?

只需注意,上面的代码适用于发送纯文本电子邮件.

html ruby email mime-types

5
推荐指数
1
解决办法
6693
查看次数

使用ruby创建sqlite数据库需要很长时间

我使用sqlite-ruby将txt文件传输到sqlite3数据库,每个txt文件大约3,5 MB,ruby读取速度非常快,但填充数据库每个文件需要10分钟以上.我不知道这是否正常,我猜不是.有人可以告诉我一个更快的方法来做这个或者如果我做一些疯狂的事情吗?下面的代码和txt方案,谢谢.

编辑:每个文件超过30分钟...

require 'sqlite3'

db = SQLite3::Database.new( "firstTest.db" )

filename="file1.txt" # this file is 3.5 MB

streetArray=[]
mothertablename="tmother"
coordstablename="tcoords"

db.execute("create table '#{mothertablename}' (id INTEGER,stName TEXT,stBC TEXT,stPrice INTEGER,stUrl TEXT);")
db.execute("create table '#{coordstablename}' (id INTEGER,num INTEGER,xcoord DOUBLE,ycoord DOUBLE);")

f=[]
File.open("_history/" + "#{filename}").each{|line| f.push(line)}

counter=0

for i in 1...f.length
    f[i].gsub!("'","") #get rid of comma character
    ptsArray=f[i].split(';')

    if ptsArray[0]==ptsArray[1]
        streetArray.push(f[i])
    end

    if ptsArray[0]=="next\n"
        counter +=1
        namestreetArray=f[i-1].split(';')
        stname=nil
        stprice=nil
        stbc=nil
        sturl=nil
        if namestreetArray[0]=="name"
            stname=namestreetArray[1]
            if namestreetArray.length>2
                stprice=namestreetArray.last
            else
                stprice=nil
            end
        end

        db.execute(  "insert into …
Run Code Online (Sandbox Code Playgroud)

ruby sqlite

3
推荐指数
1
解决办法
2560
查看次数

如何在nokogiri css选择器中使用ruby表达式插值"#{var}"?

我一直在使用nokogiri css一段时间,我希望能够在css选择器中使用ruby表达式插值,但它不起作用.这是我想要使用的代码:

doc = Nokogiri::HTML(open('http://www.somepage.com'))
keys=["BHiuG", "hUYtb4F", "jefHUY78i"]
keys.each do |k|
    keyvalue = doc.css('span[class="#{k}"]').children
    puts keyvalue
end
Run Code Online (Sandbox Code Playgroud)

有没有办法让类似的语法工作?

css ruby nokogiri

2
推荐指数
1
解决办法
399
查看次数