Help in breaking down bytes into bits through Masking and Shifting in Python [closed]

asked 2020-11-10 20:34:07 -0500

kamui123 gravatar image

Hi all, I am new to Python programming and I need some help. I am currently working on a project for robots and I am being tasked by my supervisor to work on the number of bytes that we are going to transmit. I have a base station to send data to the robot.

So, I am sending cmd_vel which consists of linear and angular velocity. I have calculated the number of bits for each. They are both 7 bits. (X(3 bits). X (4bits)) (The first X values are from 0 to 2 (2 bits) and I used 1 bit as a sign bit to represent +/-)(For the second X value, it is from 0-9 (4 bits)). So in total, that would be 14 bits, so I have to use 1 byte for each.

The problem now is that my supervisor wants me to put these values into Python. He also wants me to send these data as bytes to the robot, and when the robot receives these data, he wants the bytes to be broken down into bits through masking and shifting.

I have no clue on how to do it and I would really appreciate if someone could help me out.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2020-11-11 02:28:28.242553

Comments

I'm sorry, but this does not seem to be a ROS question.

As you write yourself:

I am new to Python programming

I would recommend you post your question on a more appropriate forum.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-11 02:29:52 -0500 )edit