Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Mathematica sorted by activeAn equivalent to Matlab "linspace" function
https://community.wolfram.com/groups/-/m/t/1568743
Hello
Matlab has a built in function called `linspace`, that, according to the documentation, generates a linearly spaced vector, but "gives direct control over the number of points and always includes the endpoints".
Mathematica doesn't work with vectors, rather with lists, but I wish to generate a list of numbers that start from `x1` and ends at `x2`, with `n` points in between (such that the spacing between the points is (x2-x1)/(n-1).
I couldn't find help with `Table`. `Table` generates a list of numbers with a starting point and an end point, with an extra option for the intervals, but I want to have `n` numbers in between.
Is there any work around?Ehud Behar2018-12-10T17:48:09ZWhy does the program result in error messages Set::write and General::stop?
https://community.wolfram.com/groups/-/m/t/1568580
Can someone explain to me the error messages of the following program? I'm new to Mathematica and can't figure out what am I assigning wrong. How can I fix it? I'm getting the errors "Set::write: Tag Rational in (1/5)[0] is Protected" and "General::stop: Further output of Set::write will be suppressed during this calculation". Probably there is a problem with the assignment Do[delta[k] = x[k + 1] - x[k], {k, 0, n - 1}]; but I can't find it. Thanks in advance for the help!S. Werner2018-12-10T13:35:20ZRaspberryPi 3 Model B+ and I2C issue
https://community.wolfram.com/groups/-/m/t/1431827
Hello,
I have been struggling with SenseHAT and Mathematica. First Mathematica was not able to find SenseHAT at all even than I followed I2C setup guide but eventually after adding following line to /boot/config.txt I was able to make some progress:
dtparam=i2c0=on
After that there is two i2c buses in the system:
pi@raspberrypi:~ $ ls -l /dev/i2c-*
crw-rw---- 1 root i2c 89, 0 Aug 30 21:34 /dev/i2c-0
crw-rw---- 1 root i2c 89, 1 Aug 30 21:34 /dev/i2c-1
However Mathematica reports variety I2C errors:
pi@raspberrypi:~ $ wolfram
Wolfram Language 11.3.0 Engine for Linux ARM (32-bit)
Copyright 1988-2018 Wolfram Research, Inc.
In[1]:= sensehat = DeviceOpen["SenseHAT"]
Out[1]= DeviceObject[{SenseHAT, 1}]
In[2]:= DeviceRead[sensehat, "Temperature"]
DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.
DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.
DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.
General::stop: Further output of DeviceWrite::unknownMRAAWriteError
will be suppressed during this calculation.
Out[2]= 42.4979 degrees Celsius
when investigating further linux journal it seems that libmraa (presumably of Mathematica MRAALink) tries to use I2C-0 bus:
Aug 30 21:38:05 raspberrypi libmraa[1037]: libmraa version v1.6.1 initialised by user 'pi' with EUID 100
Aug 30 21:38:05 raspberrypi libmraa[1037]: libmraa initialised for platform 'Raspberry Pi Model B Rev 1'
Aug 30 21:38:05 raspberrypi libmraa[1037]: i2c_init: Selected bus 0
Aug 30 21:38:22 raspberrypi libmraa[1037]: i2c0: write: Access error: Remote I/O error
Aug 30 21:38:22 raspberrypi libmraa[1037]: i2c0: write: Access error: Remote I/O error
However as far as I can tell the SenseHAT is in i2c bus 1. So I removed "dtparam=i2c0=on" and after reboot added symbolic link for i2c-0 from i2c-1:
pi@raspberrypi:/ $ ls -la /dev/i2c-*
lrwxrwxrwx 1 root root 10 Aug 30 21:43 /dev/i2c-0 -> /dev/i2c-1
crw-rw---- 1 root i2c 89, 1 Aug 30 21:41 /dev/i2c-1
and tried again SenseHAT in Mathematica which seems to work now:
pi@raspberrypi:/ $ wolfram
Wolfram Language 11.3.0 Engine for Linux ARM (32-bit)
Copyright 1988-2018 Wolfram Research, Inc.
In[1]:= sensehat = DeviceOpen["SenseHAT"]
Out[1]= DeviceObject[{SenseHAT, 1}]
In[2]:= DeviceRead[sensehat, "Temperature"]
Out[2]= 38.9896 degrees Celsius
So for me it looks that Matkematica uses wrong I2C bus at least in this particular model:
pi@raspberrypi:/dev $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Plus Rev 1.3
pi@raspberrypi:/ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
I think this should be fixed to Mathematica.Teemu Ahola2018-08-30T18:49:14ZWhere can I find documentation on "StyleHints"?
https://community.wolfram.com/groups/-/m/t/1557788
I've done some searching but I can't seem to find any documentation on "StyleHints". I'm using 11.3 on OS X High Sierra and there doesn't seem to be any built-in documentation. A search on this site also didn't turn up much. Is there any formal documentation? Has anyone posted a tutorial somewhere?
Thanks.Andrew2018-11-22T22:15:46ZFormat the line spacing of an input cell?
https://community.wolfram.com/groups/-/m/t/1558301
In 11.3 on OS X High Sierra, if I want to change the font size of the code in an input cell, I can easily do that with the notebook's stylesheet by choosing the "Input" style and using the Option Inspector to change the font size.
However, when I try to adjust the line spacing, the same approach does not work (it's as if the LineSpacing option under "Text Layout Options" has no effect).
I can change the line spacing by editing the cell directly, using Cell->Show Expression and manually typing in the option
LineSpacing->{1,0}
But I don't want to do this manually for all Input cells. I suspect there must be some other way to control the line spacing for all Input Cells in a notebook, but I can't find where it is documented. Any pointers would be appreciated.
Thanks.Andrew2018-11-22T23:06:12ZFind "CDF Export" in File submenu in MMA 11.3 (Windows)?
https://community.wolfram.com/groups/-/m/t/1568136
I am new to Mathematica, and I am using Mathematica 11.3 (Windows). The documentation refers to a "CDF Export" sub menu item from the file menu.( File --> CDF Export). I do not have a CDF export menu as a submenu on my File menu. Thanks for any heip.Thomas Seibel2018-12-08T16:05:41ZUse CUDA functions in Mathematica 11.3?
https://community.wolfram.com/groups/-/m/t/1567399
Hi,
I previously had Mathematica 11.0.0 and I successfully used it with my NVIDIA GT 630M GPU on my DELL Inspiron through CUDALINK. I am using Windows 10 Professional.
I now have installed Mathematica 11.3. To my surprise, CUDA functions have stopped working.
Although `CUDAQ[]` Returns `True` and `CUDAResourcesInformation[]` returns:
CUDAResourcesInformation[]
{{"Name" -> "CUDAResources", "Version" -> "11.3.82",
"BuildNumber" -> "", "Qualifier" -> "Win64",
"WolframVersion" -> "11.2,11.3", "SystemID" -> {"Windows-x86-64"},
"Description" -> "{ToolkitVersion -> v9.1, MinimumDriver -> 290}",
"Category" -> "", "Creator" -> "", "Publisher" -> "",
"Support" -> "", "Internal" -> False,
"Location" ->
"C:\\Users\\DELL\\AppData\\Roaming\\Mathematica\\Paclets\\\
Repository\\CUDAResources-Win64-11.3.82", "Context" -> {},
"Enabled" -> True, "Loading" -> Manual,
"Hash" -> "8e54b1af34017668d20caeae2d6e364d"}}
The graphics card driver is the latest for my card:
CUDADriverVersion[]
391.35
Running, for example, `CUDADot[]` gives an error
CUDADot[{1,2,3},{3,4,5}]
CUDAQ::internal: CUDALink experienced an internal error.
What seems to be the problem here? Do I need to install and configure a C Compiler so that `CUDACCompilers[]` does not return an empty list?Hamood Khan2018-12-07T13:30:01ZMake a Sous Vide using Raspberry Pi and Mathematica?
https://community.wolfram.com/groups/-/m/t/1563105
Hello, I am trying to make a Sous Vide using Raspberry Pi and Mathematica. I am in the process of collecting everything I need but am not sure which Pi to get. Can anyone tell me what model I need? (I am following the article posted by Liz Upton)George Saucedo2018-11-30T17:56:32ZCan Wolfram´s Mathematica read CmapTools files?
https://community.wolfram.com/groups/-/m/t/1567561
Hi,
I would like to analyze CmapTools Concept Maps using Wolfram´s Mathematica. I intend to use graph theory to analyze the maps but I don´t know if Mathematica can read CmapTools files or if I have to convert them to a different format. Does anyone have experience with that or have any idea about it?
RibasJose Ribamar2018-12-07T11:30:00ZDownload manager won't start downloading and displays errors
https://community.wolfram.com/groups/-/m/t/1211541
Hello everyone!
Could anyone please help me with this situation? I am trying to download the latest version of Mathematica, but I am having this problem with download manager utility and I can't find any solution. The download process nevers starts and I only see those error messages...
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=helpmeifyoucan.png&userId=1211525
I would really appreciate some explanation for fixing this, thanks a lot :)
(2 hours after creating this thread Update) - **Timeout in I/O** has just been replaced by **Socket error** :(Samuel Čech2017-10-31T18:31:36ZImplementation of topology optimization algorithms in Wolfram Mathematica
https://community.wolfram.com/groups/-/m/t/1566977
----------
## One year ago ##
One year ago I posted my first [publication][1] about implementation the topology optimization algorithms in Wolfram Mathematica by using my own finite element method. I want to continue this post by presenting new results, which I received during year.
----------
## Introduction ##
It is really important problem in aircraft and spacecraft engineering. Why? Because the main goal of using topology optimization algorithms in such spheres is a decreasing the weight of any construction. As example - full optimization of the aircraft wing:![enter image description here][2]
Results of this optimization presented by Niels Aage, Erik Andreassen, Boyan S. Lazarov and Ole Sigmund in their paper ["Giga-voxel computational morphogenesis for
structural design"][3]. They achieived the 20-40% saving of weight with saving the durability with using SIMP (Solid Isotropical Material with Penalization) method. It is incredible result because of it is the first paper about optimizing object of such scale. It is important to say that now it is not fantastic idea to optimize multiscale objects or object with huge amount of components. Many commercial products realized their own algorithms.
----------
## What did I do? ##
- SIMP 2D algorithm (not my own)
- SIMP 2D modification (my own realization by **FindMinumum** function, but not effective in comparison with traditional algorithm, but I can use any type of elements)
- SIMP 3D algoritm (not my own)
- Level-set 2D algorithm (not my own)
- Level-set 3D algorithm based on 2D (my own)
- Modifications in methods for better quality of solutions (my own)
SIMP 3D algorithm in Matlab was written by Kai Liu and Andres Tovar in paper ["An efficient 3D topology optimization code written in MATLAB"][4]. It should be mentioned that [Ole Sigmund][5] and [Martin Philip Bendsoe][6] were first men who published effective numerical algorithm of first topology optimization algorithms.
Level-set 2D algorithm was written by Vivien J. Challis in paper ["A discrete level-set topology optimization code written in MATLAB"][7].
It was a little sad that most of realizations of topology optimization algorithm were written in MATLAB. I found only one implementation of SIMP method in Wolfram Mathematica written by Vladimir Uskov.
----------
## SIMP ##
So I realized these algorithms in Wolfram Mathematica. Both of them have a simple implementation of FEM. In 2D case we have quad elements with first order interpolation, and in 3D case - hexahedron elements with first order interpolation. It should be mentioned that also I realized not effective topology optimization algorithm based on Wolfram Mathematica function **FindMinimum** and **NDSolve\`FEM\`** module in Mathematica. This function has a solver for constrained optimization problem based on Interior point method of Narendra Karmarkar. Here some solutions of traditional topology optimization problem I received by using this function:
![enter image description here][8]
Graphical formulation of topology optimization problem.
![enter image description here][9]
First order element with first order penalty function
![enter image description here][10]
Second order element with first order penalty function
![enter image description here][11]
Second order element with second order penalty function
![enter image description here][12]
Second order quad element with second order penalty function
All results and code you can look on my [GitHub][13] page in file **TopOpt2.nb**.
SIMP 3D implementation results you can look below:
![enter image description here][14]
Algorithm realization you can look also on my [GitHub][15] page in file **SIMP3D.nb**.
----------
## Level-set ##
I translated the educational code of Vivien J. Challis from MATLAB code to Wolfram Mathematica with saving the names of variables for better understanding by my readers. You can look all meanings of all variables in his publication ["A discrete level-set topology optimization code written in MATLAB"][16]. I decided that it will be good to make an animation for any future user of level-set topology optimization for clear understanding of the idea:
![enter image description here][17]
Here we can see the how we receive the solution of problem by level-set algorithm. It is interesing that the same method is used for receiving 3D model from Magnetic resonance imaging. Hamilton-Jacobi equation and volume constraints, which describe our optimization problem define by itself 3D surface in 2D case problem. In 3D problem it will be 4D surface. And algorithm only move the plane through this surface until it receives the correct solution. Below 3D case is presented:
![enter image description here][18]
Here you can see the possible solution of 3D case problem. But the main difference between SIMP and Level-set is a possibility to modify internal domain. Without topology sensitivites in 2D and 3D level-set method - internal domain modification forbidded. We can make an initial hole inside the body for overwhelming this forbid. FEM implementation of voxel mesh was taken from paper Kai Liu and Andres Tovar. Idea of realization 3D Level-set was taken from paper Vivien J. Challis. In my research I tried to change the algorithm of satisfying constrained optimization from Lagrange multiplier method to something heuristic algorithm. The main Idea was avoiding of seeking right values of Lagrange multipliers. Standard and modificated algorithms were realized and compared. I received the longer convergence of algorithm, but I need only 1 run for any optimization problem. Standard and modificated realization and comparison you also can look on [GitHub][13] page in file **Level-set3D.nb**.
----------
## Further Exploration ##
Now is appeared a new implementation of Level-set algorithm based on reaction-diffusion equation. The main advantage of this is an independence level-set function on nucleation process. Possibly all implementations will be united in mini-extension of Wolfram Mathematica.
----------
## Acknowledgements ##
I want to thank Dr. Vivien Challis from The University of Queensland for clear explanations and helpful conversation about 3D Level-set method implementation.
[1]: https://community.wolfram.com/groups/-/m/t/1163322
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[3]: https://www.nature.com/articles/nature23911
[4]: https://link.springer.com/article/10.1007/s00158-014-1107-x
[5]: http://www.dtu.dk/english/service/phonebook/person?id=2278
[6]: https://www.dtu.dk/english/service/phonebook/person?id=165&tab=1
[7]: https://link.springer.com/article/10.1007/s00158-009-0430-0
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10361%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1552%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=9214%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2031%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1927%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG&userId=1083954
[13]: https://github.com/AndreyKrotkikh/TopologyOptimization
[14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animate2.gif&userId=1083954
[15]: https://github.com/AndreyKrotkikh/TopologyOptimization
[16]: https://link.springer.com/article/10.1007/s00158-009-0430-0
[17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animate.gif&userId=1083954
[18]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animate3.gif&userId=1083954Andrey Krotkikh2018-12-07T00:06:08ZOpen a hidden folder from Mathematica frontend?
https://community.wolfram.com/groups/-/m/t/1564012
Hello.
How to open a hidden folder, for example ~/.WolframEngine, from the Mathematica 11.0.1 frontend?Pierre Albarède2018-12-03T00:04:25ZMy Robots and Mathematica
https://community.wolfram.com/groups/-/m/t/1153218
Hi there, (Sharing an idea)
I am a hobbyist user of Mathematica. I am using it to control my three robot systems. Firstly there is Jeeves. It is a modified Meccano G15 KS. The Meccano control system has been removed and replaced with another control system (EZ-Robot). This new controller and its PC based control software is capable of starting an external program. In my case that external program is Mathematica. The sensors on the robot read in data and pass these data onto the PC based control software which then fires up Mathematica which in turn carries out some computation and passes a result back to the PC based control software. Data is stored in files. Using this set up means there can be latency. Sometimes quite a bit. For me this is not a problem as the robot is mainly used to test algorithms. Waiting a minute for a result is not an issue.
![Modified Meccano G15 KS][1]
This robot can read text from a sheet of paper or screen and then repeat what it has seen. It can also read text and evaluate it. For example given the question, “What is the capital of England” the robot will reply “London”. It can recognise objects in an image(potentially thousands). By reading in text similar to the following “AABBCCD”, it will play sounds relating to the musical notes. All this is made possible because of Mathematica. As stated above I use this robot for algorithm testing. In this case Mathematica is used indirectly.
My second robot is a small 16 DOF humanoid robot. This robot is controlled by a 24 channel Pololu Maestro servo controller.
![Modified EZ-Robot][2]
![Rear of modified EZ][3]
Now this robot is controlled directly by Mathematica. All code is contained in a notebook and uses all the features of connected devices contained within Mathematica. Data can be read from and sent to the robot. Just by using the Manipulate function every servo in the robot can be controlled by Mathematica. I have not done so at the moment but to create a robot animation system using Mathematica would only be a few dozen lines of code. That is one of my first tasks. This robot is a modified EZ-Robot now totally under the control of Mathematica.
My third robot is a robot workbench. Built by me to test more complex algorithms. This is controlled by a 24 channel Pololu Maestro servo controller. In turn controlled completely by, you guessed Mathematica.
![Robot Workbench 1][4]
![Robot Workbench 2][5]
![Robot Workbench 3][6]
![Robot Workbench 4][7]
![Robot Workbench 5][8]
The robot workbench only has a servo control program written at the moment. This control program makes use of the Manipulate function. I have some great plans for this workbench in the future. Under the control of Mathematica it will perform tasks using all the power of the neural networks and machine learning. Image and text processing. To name but a few.
My big goal is to create a Robot Operating System that will contain all the code required for the robots to carry out complex tasks. This would include features such as inverse and forward kinematics. I want to achieve this using only Mathematica.
My reason for putting my robots on the forum is simply to see if anyone is doing anything similar. With only a few lines of Mathematica code I have been able to get the robots to read text and interpret it. I am sure that my Robot Operating System will be thousands of lines of code. I plan to write it in two parts. A front end to carry out general robot tasks, such as movement and manipulation, data processing from sensors and the solving of problems using neural nets and machine learning. A back end that can be made to match up to a specific controller or micro controller. That is my plan. Any code I produce will be made available to this forum.
Well I had better get back to coding.
----------
# CODE
----------
The code for the G15 KS simply performs a task and returns a result to the control software of the robot. There is no direct control. The humanoid robot and the workbench code have direct control.
The following is the code that allows the modified G15 KS to read text and repeat what it has seen.
str = TextRecognize[Import["C:\\mathscripts\\images\\img3.jpg"], Language -> "English"];
str = StringReplace[str, Whitespace -> " "];
str
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output.txt"]]
WriteLine[s, str];
Close[s];
Here the image taken by the robots camera is picked up by mathematica and the TextRecognize function gets the text from the image and stores it in a file ready to be used by the robots control system. Pretty simple coding to get a robot to read text.
The following code allows the G15 KS to read text, evaluate it.
str = TextRecognize[Import["C:\\mathscripts\\images\\img3.jpg"], Language -> "English"];
str = StringReplace[str, Whitespace -> " "];
str
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output2.txt"]]
res = Interpreter["SemanticExpression"][str];
If[NumericQ[res], res = N[res], res]
WriteLine[s, ToString[res]];
Close[s];
The following code allows the G15 KS to identify an object within an image. Actually thousands of objects'
txt = ImageIdentify[Import["C:\\mathscripts\\images\\img3.jpg"]]
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output3.txt"]]
WriteLine[s, ToString[CommonName[txt]]];
Close[s];
The following code allows the G15 KS to read text relating to geographic location. This was used by the robot to read the text generated by a mobile phone app and speak the result.
str = TextRecognize[Import["C:\\mathscripts\\images\\img3.jpg"], Language -> "English"];
str = StringReplace[str, Whitespace -> " "];
str = StringSplit[str];
If[NumberQ[ToExpression[str[[1]]]] && NumberQ[ToExpression[str[[2]]]],
$GeoLocation =
GeoPosition[{ToExpression[str[[1]]], ToExpression[str[[2]]]}];
country = CountryData[$GeoLocationCountry, "Name"];
citytown = CityData[$GeoLocationCity, "Name"];
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output4.txt"]];
WriteLine[s, country <> " is the country I am in and the nearest town or city is called " \<> citytown];
Close[s];,
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output4.txt"]];
WriteLine[s, "Invalid input Please try again " ];
Close[s];];
The following code allows the robot to play a tune. The text the robot must read is as follows: AABBCCD
str = TextRecognize[Import["C:\\mathscripts\\images\\img3.jpg"], Language -> "English"];
str = StringReplace[str, Whitespace -> ""];
str
s = OpenWrite[File["C:\\mathscripts\\jeeves\\output5.txt"]]
WriteLine[s, str];
Close[s];
It can be seen from the code that most of the work is passing data in files. The code to carry text and image analysis is simply one line of code. It can not get better than that.
The code that follows is the code the is used to control all of the humanoid and workbench servo. Firstly the workbench.
Button["Open connection to Maestro", dev = DeviceOpen["Serial", "COM5"]]
Manipulate[
DeviceWriteBuffer[
dev, {132, 1, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1224, "Right Base"},
496, 2016, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 0, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1224, "Left Base"},
496, 2016, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 3, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1216, "Right Pivot"},
1008, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 2, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1216, "Left Pivot"},
1008, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 4, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1216, "Right Elbow"},
1024, 2144, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 5, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1270, "Left Elbow"},
1024, 2144, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 14, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1240, "Right Wrist"},
496, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 15, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1182, "Left Wrist"},
496, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 7, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1200,
"Right Gripper"}, 1024, 1296, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 6, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1200,
"Left Gripper"}, 1024, 1296, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 8, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1480, "Turn Table"},
992, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 10, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1240,
"Move Vertical"}, 496, 2000, 1}]
Manipulate[
DeviceWriteBuffer[
dev, {132, 11, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}], {{a, 1200,
"Move Horizontal"}, 800, 1600, 1}]
CloseDevice[dev];
Now the code to move the humanoid servos using Manipulate.
dev = DeviceOpen["Serial", "COM5"]
Manipulate[
DeviceWriteBuffer[
dev, {132, 0, BitAnd[a*4, 127],
BitAnd[BitShiftRight[(a*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 1, BitAnd[b*4, 127],
BitAnd[BitShiftRight[(b*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 2, BitAnd[c*4, 127],
BitAnd[BitShiftRight[(c*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 3, BitAnd[d*4, 127],
BitAnd[BitShiftRight[(d*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 5, BitAnd[e*4, 127],
BitAnd[BitShiftRight[(e*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 4, BitAnd[f*4, 127],
BitAnd[BitShiftRight[(f*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 6, BitAnd[g*4, 127],
BitAnd[BitShiftRight[(g*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 7, BitAnd[h*4, 127],
BitAnd[BitShiftRight[(h*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 15, BitAnd[l*4, 127],
BitAnd[BitShiftRight[(l*4), 7] , 127]}];
DeviceWriteBuffer[
dev, {132, 14, BitAnd[k*4, 127],
BitAnd[BitShiftRight[(k*4), 7] , 127]}], {{a, 1224, "Left Base"},
496, 2016, 1}, {{b, 1224, "Right Base"}, 496, 2016,
1}, {{c, 1216, "Left Pivot"}, 1008, 2000,
1}, {{d, 1216, "Right Pivot"}, 1008, 2000,
1}, {{e, 1270, "Left Elbow"}, 1024, 2144,
1}, {{f, 1270, "Right Elbow"}, 1024, 2144,
1}, {{k, 1024, "Right Wrist"}, 496, 2000,
1}, {{l, 1024, "Left Wrist"}, 496, 2000,
1}, {{g, 1200, "Left Gripper"}, 1024, 1296,
1}, {{h, 1200, "Right Gripper"}, 1024, 1296, 1}]
That's all for now at a later date there will be a lot more to come. It can be seen from above that very little code is required to get a great deal of functionality.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_204150%282%29.jpg&userId=1152078
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210215%282%29.jpg&userId=1152078
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210324%283%29.jpg&userId=1152078
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205616%282%29.jpg&userId=1152078
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205908%282%29.jpg&userId=1152078
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210128%283%29.jpg&userId=1152078
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_204931%282%29.jpg&userId=1152078
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205445%282%29.jpg&userId=1152078Terence Smith2017-07-26T17:11:41Z