
夹爪控制方式
使用 pyRobotiqGripper
但是只兼容 linux 电脑的串口,所以部署在笔记本上并且创建一个局域网服务器供台式机调用。
1 | import pyRobotiqGripper |
1 | (base) cyl@arch ~/450> python gripper_test.py |
台式机通过
1 | # 定义要发送的命令和URL |
来控制
使用 pyRobotiqGripper
但是只兼容 linux 电脑的串口,所以部署在笔记本上并且创建一个局域网服务器供台式机调用。
1 | import pyRobotiqGripper |
1 | (base) cyl@arch ~/450> python gripper_test.py |
台式机通过
1 | # 定义要发送的命令和URL |
来控制
通过接通现有大模型的方式,创建一个微信的问答机器人
由于没有白名单地区的手机号,所以无法申请chatgpt的api,之后经道听途说,阿里云的通义千问有不错的问答能力,且api调用价格较为低廉(一次问答几分钱?一开始会送2M tokens)。综上,决定使用通义千问。
申请/管理地址
设置API KEY (设为环境变量)
1 | export DASHSCOPE_API_KEY=YOUR_DASHSCOPE_API_KEY |
先安装阿里云的dashscope package
1 | pip install dashscope |
因为需要问答,属于多轮会话
以下为官网提供的多轮会话的示例代码
1 | from http import HTTPStatus |
基本的包以及api-key指定:
1 | from http import HTTPStatus |
创建初始message:
1 | messages = [Message(Role.SYSTEM, 'you are a cyl家的小女仆口牙')] |
提问#1:
1 | messages.append(Message(Role.USER, 'how to install archlinux')) |
1 | response |
1 | GenerationResponse(status_code=<HTTPStatus.OK: 200>, request_id='dcf58c98-17c0-95fd-80c1-3f88fc8dd9db', code='', message='', output=GenerationOutput(text=None, choices=[Choice(finish_reason='stop', message=Message({'role': 'assistant', 'content': 'Installing Arch Linux can be done in several steps, ... Remember to read the Arch Linux documentation for further guidance and troubleshooting: [https://wiki.archlinux.org/](https://wiki.archlinux.org/)'}))], finish_reason=None), usage=GenerationUsage(input_tokens=24, output_tokens=687)) |
接收回答:
1 | if response.status_code == HTTPStatus.OK: |
将回答整合进上下文:
1 | messages.append(Message(response.output.choices[0]['message']['role'], |
然后可以重新回到提问#1环节
1 | from http import HTTPStatus |
1 | {"role": "assistant", "content": "我是陈语林家的可 |
因为博主准备在wsl2中使用wechaty,而wechaty需要先启动Puppet的docker服务,所以安装Docker Desktop Windows
要在wsl2中使用docker的话需要更改一下用户组
1 | sudo usermod -a -G docker chenyulin |
然后重启一下wsl2,重新启动一下Docker Desktop服务
wsl2更新并开启服务:
1 | docker pull wechaty/wechaty:latest |
安装wechaty python对应的包:
1 | pip install wechaty -i https://pypi.tuna.tsinghua.edu.cn/simple/ |
tnnd突然发现有个简化版的wechaty用起来更方便
简化版的wechaty
经了解,wechatbot需要实名账号,且存在封控风险,qq同理,故暂且CLOSE本博客,可能后续会考虑转成网页端的问答
咱就是,感觉可以用qq救一下,况且qq也小号free,干就完了!
[]
1 | import pandas as pd |
1 | df.loc[0:4,"Year":"Party"] |
1 | df['column_name'] = df['column_name'].astype(int) |
1 | df.groupby('column_name').agg(['sum', 'mean', 'max', 'min']) |
Extracting the top 20 categories from a DataFrame using groupby:
Use the groupby and size methods to calculate the size of each group:
1 | group_sizes = df.groupby('category').size() |
Use the head method to extract the top 20 categories:
1 | top_20 = sorted_groups.head(20) |
isin method to filter the original DataFrame to only include rows with the top 20 categories:1 | df_filtered = df[df['category'].isin(top_20.index)] |
This will extract the top 20 categories from the ‘category’ column of the DataFrame and create a new DataFrame that only includes rows with those categories.
1 | soup = bs4.BeautifulSoup(text) |
1 | soup.find("div", attrs={"id":"..."}) |
1 | soup.find("...").next_sibling |
1 | soup(class_=re.compile('item-')) |
1 | re.sub(pattern,repl,str) |
1 | df['column_name'].str.contains('pattern') |
Extracting room numbers from a ‘Description’ column in a DataFrame using regular expressions:
Import the re module:
1 | import re |
Use the apply() method to apply the function to the ‘Description’ column and create a new ‘RoomNumber’ column:
1 | df['RoomNumber'] = df['Description'].apply(extract_room_number) |
This will extract the room number from the ‘Description’ column and store it in the new ‘RoomNumber’ column.
File Path: catkin_ws/src/test/script/env_pkl_generator.py
1 | cd ~ |
It will open Gazebo and RViz and display the robotic arm on both sofware.
1 | cd ~ |
向日葵
识别吗
341 866 266
ge6v9Q
magma-nvim
Magma is a NeoVim plugin for running code interactively with Jupyter.
Jupynium.nvim
It’s just like a markdown live preview, but it’s Jupyter Notebook live preview!
Jupynium uses Selenium to automate Jupyter Notebook, synchronising everything you type on Neovim.
Never leave Neovim. Switch tabs on the browser as you switch files on Neovim.
CADC Ground Investigation Visual Solution
We want to apply computer vision to the plane to fullfill ground investigation task automatically.
The input image looks like this:
And we hope the output prediction to be 56.
(requirment.txt will be added afterwards)
Basic OpenCV methods is required.
Recommended learning site:
Source code
in detect.py, there are two large function
1 | def detect_target(image): |
detect_target receive image data(three channels, BGR), detect the colored targets and returns the index of them.
index:
rect, indicating the information of the minimum bounding rectangleNote: What is Box2D type rect?
| index | description |
|---|---|
| rect[0] | the location of the box’s center (x,y) |
| rect[1][0] | width of the box(the length of the side which will be first reached by the horizontal line when rotating counter-clockwise) |
| rect[1][1] | height |
| rect[2] | rotation angle |
First we need to convert the color layout from BGR to HSV, which is easier to judge color.
1 | image_hsv=cv2.cvtColor(image_cut,cv2.COLOR_BGR2HSV) |
Then define a mask that filter the color(hue) range from 160-179 or 0-10 (red),
1 | red1=np.array([0,100,100]) |
And apply the mask to the picture
1 | after_mask=cv2.add(image_cut, np.zeros(np.shape(image_cut), dtype=np.uint8), mask=mask) |
Turn the after mask image into binary image and adapt close and open processing to fill holes and cancel noise.
1 | kernel=np.ones([3,3],np.uint8) |
Then, find the contours of the processed image.
For each contour, adapt filters such as area, the ratio of the height and width of bounding rectangle.
If these restrictions are fullfilled, append the index of bounding rectangle and min area rectangle to two lists respectively, and return the lists.
1 | contours, hier=cv2.findContours(Open,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE) |