Controlling Motors using C# Library from Unity 3D
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Controlling Motors using C# Library from Unity 3D
Note: The C# library has been updated(today).
The starting point is to reference the Roboclaw library.
Then derive a class from the Roboclaw class or create a Roboclaw object directly.
There is a static Find function in the Roboclaw class which will return a list of all attached Roboclaw controllers. This returns a list of strings for the Roboclaw models and their comport numbers(comport is in ()s).
When you create Roboclaw object(I'll call it "rc" from here on) you have to specify the comport, baudrate and packet serial address(eg 0x80 thru 0x87). Baudrate can be any value if you are using USB.
You then need to call rc.Open
Then you can, optionally, use the rc.GetVersion command to check the connected controller is using the correct firmware.
Then you can use any of the Packet Serial functions(eg Set and Get commands and movement commands).
There are a lot of helper functions mostly used by the library(you should mostly ignore these unless you are an advanced programmer) and there are some CANOpen handling functions(MCP only and outside this simple tutorials scope).
And that is about it. If you have specific questions please open a support ticket from the Contact Us page.
The starting point is to reference the Roboclaw library.
Then derive a class from the Roboclaw class or create a Roboclaw object directly.
There is a static Find function in the Roboclaw class which will return a list of all attached Roboclaw controllers. This returns a list of strings for the Roboclaw models and their comport numbers(comport is in ()s).
When you create Roboclaw object(I'll call it "rc" from here on) you have to specify the comport, baudrate and packet serial address(eg 0x80 thru 0x87). Baudrate can be any value if you are using USB.
You then need to call rc.Open
Then you can, optionally, use the rc.GetVersion command to check the connected controller is using the correct firmware.
Then you can use any of the Packet Serial functions(eg Set and Get commands and movement commands).
There are a lot of helper functions mostly used by the library(you should mostly ignore these unless you are an advanced programmer) and there are some CANOpen handling functions(MCP only and outside this simple tutorials scope).
And that is about it. If you have specific questions please open a support ticket from the Contact Us page.