Documentation ¶
Index ¶
- Variables
- func GenerateToken() string
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(apiHost string, apiPath string, apiProto string, hmc chan HandlerMessage, ...) *mux.Router
- func RobotHandler(w http.ResponseWriter, r *http.Request)
- func UserHandler(w http.ResponseWriter, r *http.Request)
- type HandlerMessage
- type HandlerMessageType
- type JointInfo
- type PostureCommand
- type RobotCommand
- type RobotPose
- type Route
- type Routes
- type Token
- type User
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // APIBasePath is the path to the API APIBasePath string // APIHost is the hostname APIHost string // APIProto for API access protocol APIProto string // HandlerChannel is used to communicate between the router and other application logic HandlerChannel chan HandlerMessage )
Functions ¶
func NewRouter ¶
func NewRouter(apiHost string, apiPath string, apiProto string, hmc chan HandlerMessage, ver string) *mux.Router
NewRouter creats a new instance of Router
func RobotHandler ¶ added in v1.2.4
func RobotHandler(w http.ResponseWriter, r *http.Request)
RobotHandler process the request to /base
func UserHandler ¶ added in v1.2.4
func UserHandler(w http.ResponseWriter, r *http.Request)
UserHandler process the requests on the user
Types ¶
type HandlerMessage ¶
type HandlerMessage struct { Type HandlerMessageType Value []interface{} }
HandlerMessage contains the payload for the command messages
type HandlerMessageType ¶
type HandlerMessageType int
HandlerMessageType is the type for HandlerMessage
const ( // TypeAddUser is to add a user TypeAddUser HandlerMessageType = iota // TypeUserAdded says the user is added TypeUserAdded // TypeUserExisted says a user already exists TypeUserExisted // TypeInvalidUserInfo says something wrong about the user to be added TypeInvalidUserInfo // TypeDeleteUser is to delete a user TypeDeleteUser // TypeUserDeleted says the user is deleted TypeUserDeleted // TypeUserNotFound says no such user exists TypeUserNotFound // TypeGetUser is to get the current user TypeGetUser // TypeCurrentUser has the current user info TypeCurrentUser // TypeGetBase is to get Base TypeGetBase // TypeGetShoulder is to get Shoulder TypeGetShoulder // TypeGetElbow is to get Elbow TypeGetElbow // TypeGetWristAngle is to get WristAngle TypeGetWristAngle // TypeGetWristRotation is to get WristRotation TypeGetWristRotation // TypeGetGripper is to get Gripper TypeGetGripper // TypeGetPosture is to get a posture TypeGetPosture // TypeCurrentBase returns Base TypeCurrentBase // TypeCurrentShoulder returns Shoulder TypeCurrentShoulder // TypeCurrentElbow returns Elbow TypeCurrentElbow // TypeCurrentWristAngle returns WristAngle TypeCurrentWristAngle // TypeCurrentWristRotation returns WristRotation TypeCurrentWristRotation // TypeCurrentGripper returns Gripper TypeCurrentGripper // TypeCurrentPosture returns Posture TypeCurrentPosture // TypePutBase is to change Base TypePutBase // TypePutShoulder is to change Shoulder TypePutShoulder // TypePutElbow is to change Elbow TypePutElbow // TypePutWristAngle is to change WristAngle TypePutWristAngle // TypePutWristRotation is to change WristRotation TypePutWristRotation // TypePutGripper is to change Gripper TypePutGripper // TypePutPosture is to set a posture TypePutPosture // TypePutReset is to reset Leubot TypePutReset // TypePutSleep is to sleep Leubot TypePutSleep // TypeActionPerformed says the action was performed TypeActionPerformed // TypeInvalidToken says something is wrong with Token TypeInvalidToken // TypeInvalidCommand says no such command TypeInvalidCommand // TypeSomethingWentWrong says it didn't go well TypeSomethingWentWrong )
func (HandlerMessageType) String ¶ added in v1.2.4
func (hmt HandlerMessageType) String() string
type PostureCommand ¶ added in v1.1.1
type PostureCommand struct { Token string `json:"token"` Base uint16 `json:"base"` Shoulder uint16 `json:"shoulder"` Elbow uint16 `json:"elbow"` WristAngle uint16 `json:"wristAngle"` WristRotation uint16 `json:"wristRotation"` Gripper uint16 `json:"gripper"` Delta uint8 `json:"delta"` }
PostureCommand is a struct for a posture
type RobotCommand ¶
RobotCommand is a struct for each command
type RobotPose ¶ added in v1.2.2
type RobotPose struct { Base uint16 Shoulder uint16 Elbow uint16 WristAngle uint16 WristRotation uint16 Gripper uint16 }
RobotPose stores the rotations of each joint
func (*RobotPose) BuildArmLinkPacket ¶ added in v1.2.2
func (rp *RobotPose) BuildArmLinkPacket(delta uint8) *armlink.ArmLinkPacket
BuildArmLinkPacket creates a new ArmLinkPacket
type Route ¶
type Route struct { Name string Methods []string Pattern string HandlerFunc http.HandlerFunc }
Route is a basic pattern of the rounting
Click to show internal directories.
Click to hide internal directories.