Writing a Path in ROS - ros

The path below is where the file that I want to upload is.
I am new to Programming and ROS.
cwd_path = os.path.dirname(os.path.realpath('__file__'))
If I want to get the file uploaded in ROS, would it be written like that :
rospack = rospkg.RosPack()
pkg_path = rospack.get_path('__file__')
OR
pkg_path = rospack.get_path(os.path.realpath('__file__'))

Related

Not able to manipulate the image after uploading it on Telegram

I'm trying to build a telegram bot for resizing image. I'm using Python for coding and using the pyTelegramBotAPI as the wrapper. The issue that I'm facing is that I'm not able to manipulate the image after I upload it on Telegram. I'm trying to use Pillow module for image manipulation. As fas as I understand as of now, the bot API is providing the "file ID" of the image instead of the image itself, due to which the Pillow module is not able to do anything about it. Here's the function that I've written so far:
# Handles all sent image files
#bot.message_handler(content_types=['photo'])
def image_resize(message):
sent_photo = message.photo[-1].file_id
bot.send_message(message.chat.id, "Enter the desired dimensions (WIDTHxHEIGHT), for example 300x150.")
#bot.message_handler(content_types=['text'])
def resize(message):
width, height = message.text.split("x")
im = Image.open(sent_photo)
resized_img = im.resize((width, height))
bot.send_photo(message.chat.id, resized_img)
The error that I'm getting:
im = Image.open(sent_photo)
File "/home/runner/imageResizertb/venv/lib/python3.8/site-packages/PIL/Image.py", line 3068, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'AgACAgUAAxkBAANyYnk0JGdGDY1_NbbYlfiYamTyrYMAAtmwMRvHg8lXDixv48nY6SYBAAMCAAN5AAMkBA'
Can anybody help me understanding how the API is handling the image file and how to manipulate it?
You are sending the File/Image ID to pillow. You'll need to save the file name somewhere or download the file into memory as such:
from io import BytesIO
#bot.message_handler(content_types=['text'])
def resize(message):
file = bot.get_file(sent_photo)
download_file = bot.download_file(file.file_path)
f = BytesIO(download_file)
im = Image.open(f)
resized_img = im.resize((width, height))
bot.send_photo(message.chat.id, resized_img)

Missing files in Yocto SDK

I have some files downloaded by a certain recipe during an Yocto image build. I want to include them in the SDK of the same image.
I add this recipe in TOOLCHAIN_TARGET_TASK.
When I build the SDK based on the my custom image(populate_sdk) these files are missing from the resulting SDK. I can see only some certain header files made for that particular recipe.
I want to know how I can include these files in the SDK build. I didn't find any commands that does that for files for SDKs.
For reference, the files are downloaded by the recipe from this git:
https://github.com/dji-sdk/Onboard-SDK/archive/3.6.zip
The Recipe:
SUMMARY = "DJI Onboard SDK"
SECTION = "libs"
LICENSE_FLAGS = "osdk"
LICENSE = "CLOSED"
PV = "3.6"
SRC_URI = "https://github.com/dji-sdk/Onboard-SDK/archive/${PV}.zip"
FILESEXTRAPATHS_prepend := "${THISDIR}/Onboard-SDK-${PV}:"
TOOLCHAIN_TARGET_TASK_append = " osdk"
S="${WORKDIR}/Onboard-SDK-${PV}"
INSANE_SKIP_${PN} = "dev-so"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
inherit pkgconfig cmake
FILES_${PN} = "usr/lib/* usr/share/*"
FILES_${PN}-dev = "usr/include/*"
Could you please:
- Give us the recipe
- Tell us how you have populated TOOLCHAIN_TARGET_TASK variable ?
Should be something like that:
TOOLCHAIN_TARGET_TASK_append = " <recipename>-staticdev"
Have you add (inside the recipe):
BBCLASSEXTEND = "native nativesdk"
So we need more info to help you :)

Read a parameter from a file

I am trying to find out how can I read from a file, for example test environment.
The file contains:
test_env1 = "http://test.com"
test_env2 = "http://test2.com"1
Is possible to read from this file for test_env1 to visit the assigned URL.

FTPHelper library not working iOS

Hello I have this code and don't download anything...
FTPHelper *ftp;
ftp.urlString = #"ftp.marignal.com";
ftp.uname = #"whttpapp.marignal.com";
ftp.pword = #"hidden";
ftp.filePath = #"Barcos/Imagenes";
[ftp download:#"catlanza.bmp"];
I'm using this lib: https://github.com/erica/iphone-3.0-cookbook-/tree/master/C13-Networking/15-FTP%20Helper
That method download, It suppose to install the selected file in Documents directory...
Look in the simulator for the path it copied to.
Likely you need to tack on Documents:
ftp.filePath = #"Documents/Barcos/Imagenes";
Or get the path programmatically:
What is the documents directory (NSDocumentDirectory)?

How to call input file which is qlready in the package

In my Hadoop Map Reduce application I have one input file.I want that when I execute the jar of my application, then the input file will automatically be called.To do this I code one class to specify the input,output and file itself but from where I am calling the file, there I want to specify the file path. To do that I have used this code:
QueriesTest.class.getResourceAsStream("/src/main/resources/test")
but it is not working (cannot read the input file from the generated jar)
so I have used this one
URL url = this.getClass().getResource("/src/main/resources/test") here I am getting the problem of URL. So please help me out. I am using Hadoop 0.21.
I'm not sure what you want to tell us with your resource loading, but the usual way to add an input file is this:
Configuration conf = new Configuration();
Job job = new Job(conf);
Path in = new Path("YOUR_PATH_IN_HDFS");
FileInputFormat.addInputPath(job, in);
job.setInputFormatClass(TextInputFormat.class); // could be a sequencefile also
// set the other stuff
job.waitForCompletion(true);
Make sure your file resides in HDFS then.

Resources